From bb5e6831ab2aafe96085a8d92d857a99f7e960f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Ignacio=20Torres?= Date: Fri, 15 May 2026 23:23:44 -0700 Subject: [PATCH] feat: setup Docker container --- .dockerignore | 16 ++++++++++++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ README.md | 9 +++++++++ docker-compose.yml | 10 ++++++---- 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6db6efe --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +.git +.gitignore +.github +.vscode +.githooks +logs +var/cache +vendor +tests +.phpunit.cache +.phpunit.result.cache +.env +.env.* +docker-compose.yml +README.md +LICENSE diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f27ff36 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM composer:latest AS deps + +WORKDIR /app + +COPY composer.json composer.lock* ./ +RUN composer install \ + --no-interaction \ + --no-progress \ + --prefer-dist \ + --no-dev \ + --optimize-autoloader + +FROM php:8.5-cli-alpine AS app + +WORKDIR /var/www + +ENV APP_ENV=production +ENV PORT=8080 + +COPY --from=deps /app/vendor ./vendor +COPY . . + +RUN mkdir -p /var/www/logs /var/www/var/cache \ + && chown -R www-data:www-data /var/www/logs /var/www/var + +USER www-data + +EXPOSE 8080 + +CMD ["sh", "-c", "php -S 0.0.0.0:${PORT:-8080} -t public"] diff --git a/README.md b/README.md index 287e4ac..4cc5260 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,15 @@ Then: * Point your virtual host document root to `phpds`'s `public/` directory. * Ensure `logs/` is web writable. +### Docker + +You can also run the application with `docker`: + +```bash +docker build -t phpds . +docker run -p 8080:8080 phpds +``` + ## Development To run the application in development, you can run these commands diff --git a/docker-compose.yml b/docker-compose.yml index f7a5b04..27eaa76 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,13 +6,15 @@ volumes: services: slim: - image: php:8.5-alpine - working_dir: /var/www - command: php -S 0.0.0.0:8080 -t public + build: + context: . + dockerfile: Dockerfile + image: phpds:local environment: + APP_ENV: production + PORT: 8080 docker: "true" ports: - "8080:8080" volumes: - - .:/var/www - logs:/var/www/logs -- 2.51.2