Skip to content

Commit

Permalink
Add PUID/PGID override for dev envs.
Browse files Browse the repository at this point in the history
  • Loading branch information
BusterNeece committed May 5, 2024
1 parent c0124f4 commit 395b2e6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ COPY ./build/dev/services/ /etc/supervisor.d/
COPY ./build/dev/Caddyfile /etc/Caddyfile
COPY ./build/dev/entrypoint.sh /var/app/entrypoint.sh

RUN apk add --no-cache shadow

RUN chmod a+x /var/app/entrypoint.sh

USER root
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ host OS to take advantage of this file, but all instructions are provided in bot

Copy `dev.dist.env` to `dev.env` and update it with any missing secrets.

Update `PUID` and `PGID` to your local user/group ID respectively (the values of `id -u` and `id -g`) to ensure permissions match correctly.

The database will be created from the DB migrations (in `/db/migrations`) on initial startup.

The following user accounts are created on local dev, all with the password `WaterWolf!`:
Expand Down
7 changes: 7 additions & 0 deletions build/dev/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash

# Set UID/GID
PUID="${PUID:-1000}"
PGID="${PGID:-1000}"

groupmod -o -g "$PGID" app
usermod -o -u "$PUID" app

# Write environment variables to script
declare -p | grep -Ev 'BASHOPTS|BASH_VERSINFO|EUID|PPID|SHELLOPTS|UID' > /container.env
chmod 744 /container.env
Expand Down
3 changes: 3 additions & 0 deletions dev.dist.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# The passwords are randomly generated, but things like MariaDB are never exposed
# to the web in local

PUID=1000
PGID=1000

# Database username used by the app
MARIADB_USER="web"

Expand Down

0 comments on commit 395b2e6

Please sign in to comment.