Skip to content

Commit c7d2c82

Browse files
committed
allow runing as non-root user
1 parent bff7906 commit c7d2c82

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ HEALTH_CHECK_INTERVAL=24
7070
CLEANUP_SITE_DELAY=7
7171
# Cache time in minutes
7272
TUF_REPO_CACHETIME=5
73+
74+
# Docker config
75+
HOST_UID=0
76+
HOST_GID=0

Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
FROM dunglas/frankenphp
2+
ARG UID
3+
ARG GID
24

35
RUN apt-get update && apt-get install -y git
46

@@ -11,8 +13,10 @@ RUN install-php-extensions \
1113
curl \
1214
redis
1315

14-
COPY . /app
16+
RUN addgroup --gid $GID nonroot && adduser --uid $UID --gid $GID --disabled-password --gecos "" nonroot
17+
USER nonroot
1518

19+
COPY --chown=nonroot:nonroot . /app
1620
RUN composer install --no-dev
1721

1822
ENTRYPOINT ["php", "artisan", "octane:frankenphp"]

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This is the server for automated updates of Joomla CMS instances running on joom
44
# Deployment and usage
55
* Install docker and docker compose
66
* Check out this repo
7+
* Copy to .env.example to .env and adjust to your requirements - important: set UID and GID to user and group on the host system that you would like to use for the processes
78
* Start the webserver and DB services: `docker-compose -f docker-compose.prod.yml up -d`
89
* Apply the database migrations: `docker-compose run --entrypoint="php artisan migrate" php`
910
* Daemonize the queue worker using supervisord; the call in question is: `docker-compose run --entrypoint="php artisan horizon" php`

docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '3.1'
21
services:
32
mysql:
43
image: 'mariadb:11'
@@ -20,6 +19,9 @@ services:
2019
php:
2120
build:
2221
context: .
22+
args:
23+
UID: ${HOST_UID}
24+
GID: ${HOST_GID}
2325
entrypoint: php artisan octane:frankenphp --workers=1 --max-requests=1
2426
ports:
2527
- '21001:8000'

0 commit comments

Comments
 (0)