From e1686cd8c52a549c0569607217819db4c0f2fdcc Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Wed, 11 Aug 2021 22:28:48 +0200 Subject: [PATCH] Add dockerfile for local development --- Dockerfile | 6 ++++++ README.md | 14 +++++++++++++- dev.sh | 2 +- docker-compose.yaml | 21 +++++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..66baa1d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +# this is a development container, not hardened for hosting +FROM php:7.4-cli +RUN apt-get update && \ + apt-get install -y \ + sqlite \ + unzip diff --git a/README.md b/README.md index 19c83ba..f58b550 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ On Windows, you have to perform a `composer install` manually beforehand. Make s ### Dependency management `dev.sh` will ensure the git submodules have been pulled, then download the `composer` package manager to the php archive file `composer.phar` and run it. -Composer will check for the php extension `pdo_sqlite` which must be enabled on your system. This usually includes installing a php-sqlite3 package and enabling it in /etc/php/php.ini: +Composer will check for the php extension `pdo_sqlite` which must be enabled on your system. This usually includes installing a php-sqlite3 package and enabling it in `/etc/php/php.ini`: [PHP] extension=pdo_sqlite @@ -35,4 +35,16 @@ Composer is used as such: php composer.phar update php composer.phar install +### Docker + +We provide a simple docker-compose setup for local development. +First ensure that docker is running: + + sudo systemctl start docker + +then + + DOCKER_USER=$(id -u):$(id -g) docker-compose up + + ## Hosting diff --git a/dev.sh b/dev.sh index a613267..fd665d6 100755 --- a/dev.sh +++ b/dev.sh @@ -22,4 +22,4 @@ if test ! -d vendor; then ln -s ../vendor/simplesamlphp/simplesamlphp/www/ www/simplesaml fi -php -S [::1]:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/ +php -S ${DOCKER_HOST:-[::1]}:${DOCKER_PORT:-1080} -d error_reporting=E_ALL -d display_errors=1 -t www/ diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..7003545 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,21 @@ +version: "3.9" + +# cleanup: + +# docker container prune -f && docker volume prune -f +# docker system prune -a + +services: + nettside: # https://hub.docker.com/_/php + #image: php:7.4-cli + build: . + volumes: + - .:/usr/src/nettside + working_dir: /usr/src/nettside + command: ./dev.sh + environment: + - DOCKER_HOST=0.0.0.0 + - DOCKER_PORT=1080 + ports: + - 1080:1080 + user: "${DOCKER_USER}"