Skip to content

Commit

Permalink
[Chore] Allow setting the uid/gid of the FPM image (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
tchapi authored Feb 26, 2024
1 parent d8e9f6e commit a66a2a4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,16 @@ A `Dockerfile` is available for you to compile the image.

To build the checked out version, just run:

docker build --pull --file docker/Dockerfile --tag davis:latest .
docker build --pull --file docker/Dockerfile --tag davis:latest --build-arg fpm_user=82:82 .

> [!TIP]
>
> The `fpm_user` build arg allows to set:
> - the uid FPM will run with
> - the owner of the app folder
>
> This is helpful if you have a proxy that does not use the same default PHP Alpine uid/gid for www-data (82:82). For instance, in the docker compose file, nginx uses 101:101
>
This will build a `davis:latest` image that you can directly use. Do not forget to pass sensible environment variables to the container since the _dist_ `.env` file will take precedence if no `.env.local` or environment variable is found.

Expand Down
9 changes: 8 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM php:8.2-fpm-alpine

# https://github.com/docker-library/php/blob/master/8.2/alpine3.18/fpm/Dockerfile#L33
ARG fpm_user=82:82
ENV FPM_USER=${fpm_user}

LABEL org.opencontainers.image.authors="[email protected]"
LABEL org.opencontainers.image.url="https://github.com/tchapi/davis/pkgs/container/davis"
LABEL org.opencontainers.image.description="A simple, fully translatable admin interface for sabre/dav based on Symfony 5 and Bootstrap 4"
Expand Down Expand Up @@ -77,6 +81,9 @@ RUN curl https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/v0.5.0
RUN docker-php-source delete
RUN rm -rf /usr/local/bin/composer

RUN chown -R www-data:www-data var
# Sets the app folder owner as the FPM user
RUN chown -R ${FPM_USER} .

USER $FPM_USER

HEALTHCHECK --interval=30s --timeout=1s CMD php-fpm-healthcheck || exit 1
4 changes: 3 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: "davis-docker"
services:

nginx:
image: nginx:1.23-alpine
image: nginx:1.25-alpine
container_name: nginx
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
depends_on:
Expand Down Expand Up @@ -32,6 +32,8 @@ services:
build:
context: ../
dockerfile: ./docker/Dockerfile
args:
fpm_user: 101:101
image: davis:latest
# If you want to use a prebuilt image from Github
# image: ghcr.io/tchapi/davis:edge
Expand Down

0 comments on commit a66a2a4

Please sign in to comment.