Skip to content
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

Add ability to set UID and GID during container runtime #105

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@ RUN rm /tmp/*.tgz

# Install runtime dependencies
RUN apk --no-cache add \
mediainfo

# Create "download" user
RUN adduser -h /home/download -s /sbin/nologin --disabled-password download

# Run as "download" user
USER download
mediainfo su-exec

# Expose port 3000
EXPOSE 3000

# Copy docker entrypoint script
COPY docker-entrypoint.sh /

# Flood
ENTRYPOINT ["flood", "--host=0.0.0.0"]
ENTRYPOINT ["/docker-entrypoint.sh", "flood", "--host=0.0.0.0"]
13 changes: 5 additions & 8 deletions Dockerfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ RUN npm i -g flood --unsafe-perm

# Install runtime dependencies
RUN apk --no-cache add \
mediainfo

# Create "download" user
RUN adduser -h /home/download -s /sbin/nologin --disabled-password download

# Run as "download" user
USER download
mediainfo su-exec

# Expose port 3000
EXPOSE 3000

# Copy docker entrypoint script
COPY docker-entrypoint.sh /

# Flood
ENTRYPOINT ["flood", "--host=0.0.0.0"]
ENTRYPOINT ["/docker-entrypoint.sh", "flood", "--host=0.0.0.0"]
16 changes: 16 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -e

FLOOD_USER=${FLOOD_USER:-download}

if [ -n "$FLOOD_UID" ]; then
OPTS="-u $FLOOD_UID"
fi

if [ -n "$FLOOD_GID" ]; then
OPTS="$OPTS -G $FLOOD_USER"
addgroup -g $FLOOD_GID $FLOOD_USER
fi

adduser -h /home/download -g $FLOOD_USER -D -s /sbin/nologin $OPTS $FLOOD_USER

exec su-exec $FLOOD_USER "$@"