Skip to content

Remove gosu so that ports can bind #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,57 @@ jobs:
with:
fetch-depth: '0'

- name: Build the Docker image
run: docker build -t docker-netbootxyz:${{ github.sha }} .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Login to the Docker Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to the GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Get latest Webapp release version
run: |
WEBAPP_RELEASE=$(curl -sX GET "https://api.github.com/repos/netbootxyz/webapp/releases/latest" | jq -r '. | .tag_name')
echo "WEBAPP_RELEASE=${WEBAPP_RELEASE}" >> $GITHUB_ENV

- name: Build and push PR test image
uses: docker/build-push-action@v6
with:
push: true
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
WEBAPP_VERSION=${{ env.WEBAPP_RELEASE }}
VERSION=pr-${{ github.event.number }}
BUILD_DATE=$(date +'%Y-%m-%dT%H:%M:%S')
tags: |
netbootxyz/netbootxyz:pr-${{ github.event.number }}
netbootxyz/netbootxyz:pr-${{ github.event.number }}-${{ github.sha }}
ghcr.io/netbootxyz/netbootxyz:pr-${{ github.event.number }}
ghcr.io/netbootxyz/netbootxyz:pr-${{ github.event.number }}-${{ github.sha }}
labels: |
org.opencontainers.image.title=netbootxyz
org.opencontainers.image.description=netboot.xyz PR test image
org.opencontainers.image.version=pr-${{ github.event.number }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/netbootxyz/docker-netbootxyz

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.31.0
with:
image-ref: 'docker-netbootxyz:${{ github.sha }}'
image-ref: 'ghcr.io/netbootxyz/netbootxyz:pr-${{ github.event.number }}'
format: 'table'
exit-code: '1'
ignore-unfixed: true
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ RUN apk add --no-cache \
sudo \
supervisor \
syslog-ng \
# Security tools
gosu \
# Runtime libraries
nghttp2-dev \
# Create required directories
Expand Down
6 changes: 4 additions & 2 deletions root/etc/supervisor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ logfile=/tmp/supervisord.log
pidfile=/run/supervisord.pid

[program:nginx]
command = gosu nbxyz /usr/sbin/nginx -c /config/nginx/nginx.conf
command = /usr/sbin/nginx -c /config/nginx/nginx.conf
startretries = 2
daemon=off
user=nbxyz
priority = 2
stdout_logfile=/dev/null
stderr_logfile=/dev/null

[program:webapp]
environment=NODE_ENV="production",PORT=%(ENV_WEB_APP_PORT)s
command=gosu nbxyz /usr/bin/node app.js
command=/usr/bin/node app.js
directory=/app
user=nbxyz
priority = 3
stdout_logfile=/dev/null
stderr_logfile=/dev/null
Expand Down
2 changes: 1 addition & 1 deletion root/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ echo "https://opencollective.com/netbootxyz"
echo "https://github.com/sponsors/netbootxyz"
echo

# Run supervisord as root (it will use gosu for individual programs)
# Run supervisord as root
echo "[start] Starting supervisord (programs will run as nbxyz)"
exec supervisord -c /etc/supervisor.conf
4 changes: 2 additions & 2 deletions root/usr/local/bin/dnsmasq-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ echo "[dnsmasq] TFTP root: /config/menus"
echo "[dnsmasq] TFTP security: enabled"
echo "[dnsmasq] Logging: enabled (dhcp and queries)"

# Start dnsmasq via gosu with logging to stderr (which supervisord can capture)
exec gosu nbxyz /usr/sbin/dnsmasq --port=0 --keep-in-foreground --enable-tftp --user=nbxyz --tftp-secure --tftp-root=/config/menus --log-facility=- --log-dhcp --log-queries "$@"
# Start dnsmasq as root to bind to port 69, then drop privileges to nbxyz
exec /usr/sbin/dnsmasq --port=0 --keep-in-foreground --enable-tftp --user=nbxyz --tftp-secure --tftp-root=/config/menus --log-facility=- --log-dhcp --log-queries "$@"