- docker env
This commit is contained in:
Jérémy Guillot
2024-06-19 18:04:30 +02:00
parent f7bb7b9148
commit c1ba9820b6
6 changed files with 37 additions and 38 deletions

View File

@@ -1,7 +1,7 @@
#syntax=docker/dockerfile:1.4 #syntax=docker/dockerfile:1.4
# Versions # Versions
FROM dunglas/frankenphp:1-alpine AS frankenphp_upstream FROM dunglas/frankenphp:1-php8.3 AS frankenphp_upstream
# The different stages of this Dockerfile are meant to be built into separate images # The different stages of this Dockerfile are meant to be built into separate images
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage # https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
@@ -13,28 +13,16 @@ FROM frankenphp_upstream AS frankenphp_base
WORKDIR /app WORKDIR /app
# persistent / runtime deps VOLUME /app/var/
# hadolint ignore=DL3018
RUN apk add --no-cache \
acl \
file \
gettext \
git \
;
# Install Node.js and npm # persistent / runtime deps
ENV CHROME_BIN="/usr/bin/chromium-browser" \ # hadolint ignore=DL3008
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true" RUN apt-get update && apt-get install -y --no-install-recommends \
RUN set -x \ acl \
&& apk update \ file \
&& apk upgrade \ gettext \
&& apk add --no-cache \ git \
nodejs \ && rm -rf /var/lib/apt/lists/*
npm \
udev \
ttf-freefont \
chromium \
&& npm install puppeteer@1.10.0
RUN set -eux; \ RUN set -eux; \
install-php-extensions \ install-php-extensions \

View File

@@ -5,6 +5,9 @@ DOCKER_COMP_EXEC:=$(DOCKER_COMP) exec
# Docker containers # Docker containers
PHP_CONT = $(DOCKER_COMP_EXEC) php PHP_CONT = $(DOCKER_COMP_EXEC) php
NODE_CONT = $(DOCKER_COMP_EXEC) node
# Executables # Executables
PHP = $(PHP_CONT) php PHP = $(PHP_CONT) php
@@ -140,10 +143,10 @@ consume: ## Consume messages
## —— Webpack Encore ————————————————————————————————————————————————————————————— ## —— Webpack Encore —————————————————————————————————————————————————————————————
npm-install: ## Install npm dependencies npm-install: ## Install npm dependencies
@$(DOCKER_COMP) exec php npm install @$(DOCKER_COMP) exec node npm install
npm-run: ## Run the dev server npm-run: ## Run the dev server
@$(DOCKER_COMP) exec php npm run dev @$(DOCKER_COMP) exec node npm run dev
npm-watch: ## Watch for changes npm-watch: ## Watch for changes
@$(DOCKER_COMP) exec php npm run watch @$(DOCKER_COMP) exec node npm run watch

View File

@@ -19,6 +19,17 @@ services:
# Ensure that host.docker.internal is correctly defined on Linux # Ensure that host.docker.internal is correctly defined on Linux
- host.docker.internal:host-gateway - host.docker.internal:host-gateway
tty: true tty: true
node:
image: node:lts-alpine
tty: true
working_dir: /app
depends_on:
- php
volumes:
- ./:/app
environment:
NODE_ENV: development
###> doctrine/doctrine-bundle ### ###> doctrine/doctrine-bundle ###
database: database:

View File

@@ -7,12 +7,12 @@ services:
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16} TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16}
TRUSTED_HOSTS: ^${SERVER_NAME:-example\.com|localhost}|php$$ TRUSTED_HOSTS: ${TRUSTED_HOSTS:-^${SERVER_NAME:-example\.com|localhost}|php$$}
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM # Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8} DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8}
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration # Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure} MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure}
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-localhost}/.well-known/mercure MERCURE_PUBLIC_URL: ${CADDY_MERCURE_PUBLIC_URL:-https://${SERVER_NAME:-localhost}/.well-known/mercure}
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
# The two next lines can be removed after initial installation # The two next lines can be removed after initial installation
SYMFONY_VERSION: ${SYMFONY_VERSION:-} SYMFONY_VERSION: ${SYMFONY_VERSION:-}
@@ -20,8 +20,6 @@ services:
volumes: volumes:
- caddy_data:/data - caddy_data:/data
- caddy_config:/config - caddy_config:/config
networks:
- mangarr_network
ports: ports:
# HTTP # HTTP
- target: 80 - target: 80
@@ -40,8 +38,8 @@ services:
###> doctrine/doctrine-bundle ### ###> doctrine/doctrine-bundle ###
database: database:
hostname: database # hostname: database
container_name: database # container_name: database
image: postgres:${POSTGRES_VERSION:-16}-alpine image: postgres:${POSTGRES_VERSION:-16}-alpine
environment: environment:
POSTGRES_DB: ${POSTGRES_DB:-app} POSTGRES_DB: ${POSTGRES_DB:-app}
@@ -50,8 +48,8 @@ services:
POSTGRES_USER: ${POSTGRES_USER:-app} POSTGRES_USER: ${POSTGRES_USER:-app}
volumes: volumes:
- database_data:/var/lib/postgresql/data:rw - database_data:/var/lib/postgresql/data:rw
networks: # networks:
- mangarr_network # - mangarr_network
ports: ports:
- '5432:5432' - '5432:5432'
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
@@ -100,6 +98,6 @@ volumes:
mercure_config: mercure_config:
###< symfony/mercure-bundle ### ###< symfony/mercure-bundle ###
###< doctrine/doctrine-bundle ### ###< doctrine/doctrine-bundle ###
networks: #networks:
mangarr_network: # mangarr_network:
external: true # external: true

View File

@@ -1,4 +1,3 @@
variables_order = EGPCS
expose_php = 0 expose_php = 0
date.timezone = UTC date.timezone = UTC
apc.enable_cli = 1 apc.enable_cli = 1

View File

@@ -49,7 +49,7 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
fi fi
if [ "$( find ./migrations -iname '*.php' -print -quit )" ]; then if [ "$( find ./migrations -iname '*.php' -print -quit )" ]; then
php bin/console doctrine:migrations:migrate --no-interaction php bin/console doctrine:migrations:migrate --no-interaction --all-or-nothing
fi fi
fi fi