build: add docker deployment files
This commit is contained in:
parent
091ef3a209
commit
27b1676c47
7 changed files with 130 additions and 0 deletions
6
.dockerignore
Normal file
6
.dockerignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
.git
|
||||
docs/superpowers/plans
|
||||
var
|
||||
vendor
|
||||
.env.local
|
||||
compose.dev.yaml
|
||||
21
compose.dev.yaml
Normal file
21
compose.dev.yaml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile
|
||||
target: app
|
||||
environment:
|
||||
APP_ENV: dev
|
||||
APP_DEBUG: "1"
|
||||
APP_SECRET: dev-secret
|
||||
DATABASE_URL: sqlite:////app/var/data/app.db
|
||||
APP_CACHE_DIR: /app/var/bootstrap-cache
|
||||
volumes:
|
||||
- .:/app
|
||||
- app-data:/app/var/data
|
||||
- app-cache:/app/var/bootstrap-cache
|
||||
|
||||
nginx:
|
||||
volumes:
|
||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- ./public:/app/public:ro
|
||||
29
compose.yaml
Normal file
29
compose.yaml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile
|
||||
target: app
|
||||
environment:
|
||||
APP_ENV: prod
|
||||
APP_DEBUG: "0"
|
||||
APP_SECRET: ${APP_SECRET:-change-me}
|
||||
DATABASE_URL: sqlite:////app/var/data/app.db
|
||||
APP_CACHE_DIR: /app/var/bootstrap-cache
|
||||
volumes:
|
||||
- app-data:/app/var/data
|
||||
- app-cache:/app/var/bootstrap-cache
|
||||
|
||||
nginx:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile
|
||||
target: web
|
||||
depends_on:
|
||||
- app
|
||||
ports:
|
||||
- "${HTTP_PORT:-8080}:80"
|
||||
|
||||
volumes:
|
||||
app-data:
|
||||
app-cache:
|
||||
31
docker/Dockerfile
Normal file
31
docker/Dockerfile
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
FROM php:8.3-fpm-alpine AS app
|
||||
|
||||
RUN apk add --no-cache bash git icu-dev sqlite-dev unzip \
|
||||
&& docker-php-ext-install intl opcache pdo pdo_sqlite
|
||||
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
RUN composer install --no-dev --prefer-dist --no-interaction --no-progress --no-scripts
|
||||
|
||||
COPY . .
|
||||
COPY docker/php/php.ini /usr/local/etc/php/conf.d/app.ini
|
||||
COPY docker/entrypoint.sh /usr/local/bin/app-entrypoint
|
||||
|
||||
RUN chmod +x /usr/local/bin/app-entrypoint \
|
||||
&& mkdir -p var/data var/bootstrap-cache \
|
||||
&& composer dump-autoload --classmap-authoritative --no-dev \
|
||||
&& composer run-script --no-dev post-install-cmd \
|
||||
&& chown -R www-data:www-data var
|
||||
|
||||
ENTRYPOINT ["app-entrypoint"]
|
||||
CMD ["php-fpm"]
|
||||
|
||||
FROM nginx:1.27-alpine AS web
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
COPY public /app/public
|
||||
11
docker/entrypoint.sh
Executable file
11
docker/entrypoint.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
mkdir -p /app/var/data /app/var/bootstrap-cache
|
||||
chown -R www-data:www-data /app/var
|
||||
|
||||
if [ "${APP_ENV:-prod}" != "test" ]; then
|
||||
php /app/bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
25
docker/nginx/default.conf
Normal file
25
docker/nginx/default.conf
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /app/public;
|
||||
index index.php;
|
||||
|
||||
client_max_body_size 2m;
|
||||
|
||||
location / {
|
||||
try_files $uri /index.php$is_args$args;
|
||||
}
|
||||
|
||||
location ~ ^/index\.php(/|$) {
|
||||
fastcgi_pass app:9000;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
fastcgi_param DOCUMENT_ROOT $realpath_root;
|
||||
internal;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
7
docker/php/php.ini
Normal file
7
docker/php/php.ini
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
date.timezone=UTC
|
||||
memory_limit=256M
|
||||
upload_max_filesize=2M
|
||||
post_max_size=2M
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=0
|
||||
opcache.validate_timestamps=0
|
||||
Loading…
Reference in a new issue