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

Addressing persistent volume permissions issue and default user creation inside the image #409

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ WORKDIR /app

EXPOSE 80

RUN addgroup -g 1000 -S app && adduser -u 1000 -S app -G app
# RUN addgroup -g 1000 -S app && adduser -u 1000 -S app -G app

COPY --from=builder --chown=app:app /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder --chown=app:app /app/ /app/

# Forwards media listener logs to stdout so they can be captured in docker logs.
RUN ln -sf /dev/stdout /app/log/media_listener_production.log

USER app
# USER app

ENTRYPOINT ["docker/entrypoint.sh"]

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ docker run -p 3000:3000 ghcr.io/blackcandy-org/blackcandy:latest

### Media Files Mounts

You can mount media files from host to container and use `MEDIA_PATH` environment variable to set the media path for black candy. You can now provide the uid and gid as env arguments so that the permissions of "<your_media_data_path>" is properly aligned with media path set for black candy above.

```shell
docker run -e UID=$(id -u) -e GID=$(id -g) -v <your_media_data_path>:/media_data -e MEDIA_PATH=/media_data ghcr.io/blackcandy-org/blackcandy:latest
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider updating the docker compose example as well.

VIRTUAL_HOST: blackcandy.local

```

### Media Files Mounts

You can mount media files from host to container and use `MEDIA_PATH` environment variable to set the media path for black candy.

```shell
Expand Down
12 changes: 12 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/bin/sh

# Default to UID and GID 1000 if not provided
USER_ID=${UID:-1000}
GROUP_ID=${GID:-1000}

# Create group and user with the specified IDs
addgroup -g "$GROUP_ID" usergroup
adduser -u "$USER_ID" -G usergroup username

# Change ownership of the working directory
chown -R "$USER_ID":"$GROUP_ID" "$MEDIA_PATH"


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point the container is running as root. One of the reasons to drop root is for more security.

Perhaps we can su the exec on line 23?

if [ -z ${SECRET_KEY_BASE+x} ]; then
echo "Generating SECRET_KEY_BASE environment variable."
echo "Please attention, all old sessions will become invalid."
Expand Down