Skip to content

Commit d097417

Browse files
authored
Add "make clear" command and fix dev docker environment (#358)
1 parent 45ae69e commit d097417

4 files changed

Lines changed: 25 additions & 3 deletions

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ up: ## Up the dev environment
2626
down: ## Down the dev environment
2727
$(DOCKER_COMPOSE_DEV) down --remove-orphans
2828

29+
clear: ## Remove development docker containers and volumes
30+
$(DOCKER_COMPOSE_DEV) down --volumes --remove-orphans
31+
2932
shell: ## Get into container shell
3033
$(DOCKER_COMPOSE_DEV) exec app /bin/sh
3134

docker/Dockerfile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,25 @@ RUN install-php-extensions \
2424
#
2525

2626
FROM base AS dev
27+
ARG USER_ID=10001
28+
ARG GROUP_ID=10001
29+
ARG USER_NAME=www-data
30+
ARG GROUP_NAME=www-data
31+
2732
RUN install-php-extensions \
2833
xdebug
34+
2935
COPY --from=composer /composer /usr/bin/composer
30-
USER www-data
36+
37+
# Based on https://frankenphp.dev/docs/docker/#running-as-a-non-root-user
38+
RUN \
39+
groupadd --gid ${GROUP_ID} ${GROUP_NAME}; \
40+
useradd --gid ${GROUP_ID} --uid ${USER_ID} ${GROUP_NAME}; \
41+
# Add additional capability to bind to port 80 and 443
42+
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp; \
43+
# Give write access to /data/caddy and /config/caddy
44+
chown -R ${USER_NAME}:${GROUP_NAME} /data/caddy && chown -R ${USER_NAME}:${GROUP_NAME} /config/caddy
45+
USER ${USER_NAME}
3146

3247
#
3348
# Production

docker/compose.dev.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ services:
44
dockerfile: docker/Dockerfile
55
context: ..
66
target: dev
7-
user: ${UID}:${GID}
7+
args:
8+
USER_ID: ${UID}
9+
GROUP_ID: ${GID}
810
environment:
911
XDEBUG_MODE: "${XDEBUG_MODE:-develop}"
1012
APP_ENV: "${APP_ENV:-dev}"

docker/compose.test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ services:
44
dockerfile: docker/Dockerfile
55
context: ..
66
target: dev
7-
user: ${UID}:${GID}
7+
args:
8+
USER_ID: ${UID}
9+
GROUP_ID: ${GID}
810
environment:
911
XDEBUG_MODE: "off"
1012
APP_ENV: "test"

0 commit comments

Comments
 (0)