Skip to content

Commit

Permalink
Allow running as user different than root
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain committed Jan 15, 2024
1 parent 3aa273d commit fc80da3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ REVERSER_DATA_PATH=
# EXPOSED_SERVER_PORT=
# EXPOSED_POSTGRES_PORT=
# EXPOSED_VNC_PORT=
# Start the container as a different user than root.
# Use `id -u` to print the UID and `id -g` for the GID of your host user.
# HOST_UID=
# HOST_GID=
# DOCKER_USER=reverser
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ WORKDIR /app
RUN apk --no-cache add \
tzdata git \
postgresql16-client \
vips ffmpeg
vips ffmpeg \
sudo

RUN git config --global --add safe.directory /app

# Create a user with (potentially) the same id as on the host
ARG HOST_UID=1000
ARG HOST_GID=1000
RUN addgroup --gid ${HOST_GID} reverser && \
adduser -S --shell /bin/sh --uid ${HOST_UID} reverser && \
addgroup reverser wheel && \
echo "reverser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Copy native npm package binaries
COPY --from=node-downloader /usr/local/lib/node_modules/esbuild/bin/esbuild /usr/local/bin

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
reverser:
build: ./
image: reverser
user: ${DOCKER_USER:-root}
environment:
<<: *common-env
RAILS_SERVER_EXEC: bin/rails server -p ${EXPOSED_SERVER_PORT:-9000} -b 0.0.0.0 --pid /tmp/server.pid
Expand Down

0 comments on commit fc80da3

Please sign in to comment.