add docker config
This commit is contained in:
parent
17ffc11a72
commit
fe90d3d32c
22
README.md
Normal file
22
README.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Environnement de développement Docker pour démarrer un nouveau projet Symfony5
|
||||||
|
==================================
|
||||||
|
|
||||||
|
# Présentation
|
||||||
|
|
||||||
|
L'objectif de ce dépôt est de proposer et de faire évoluer une configuration de départ pour démarrer très simplement un nouveau projet Symfony dans des conteneurs Docker.
|
||||||
|
|
||||||
|
En suivant pas-à-pas les instructions à partir du chapitre "Installation", on peut démarrer en quelques minutes un nouveau projet.
|
||||||
|
|
||||||
|
Le dépôt propose plusieurs branches qui peuvent être utilisées selon le point de départ recherché:
|
||||||
|
|
||||||
|
## 1_docker_ready
|
||||||
|
|
||||||
|
La branche `1_docker_ready` fournit juste le docker-compose.yml et les Dockerfile qui permettent de construire les conteneurs.
|
||||||
|
|
||||||
|
* `$ cd my-project-dir`
|
||||||
|
* `$ docker-compose build`
|
||||||
|
* `$ docker-compose up -d`
|
||||||
|
* `$ docker-compose exec -u 1000 php bash`
|
||||||
|
|
||||||
|
A ce stade les commandes composer et symfony sont disponible pour lancer la création du projet.
|
||||||
|
Après ça on choisira dans le fichier `app/.env` le type de base de donnée. Un conteneur est prévu pour utiliser postgresql. Par défaut, Symfony proposera l'utilisation d'un fichier sqlite (`app/data/database.sqlite`).
|
37
docker-compose.yml
Normal file
37
docker-compose.yml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
version: "3.7"
|
||||||
|
services:
|
||||||
|
|
||||||
|
# By default, database is managed in a single sqlite file.
|
||||||
|
# Comment to disable db container
|
||||||
|
db:
|
||||||
|
image: postgres:12
|
||||||
|
volumes:
|
||||||
|
# comment to keep data in a docker volumes
|
||||||
|
- ./data:/var/lib/postgresql/data
|
||||||
|
- ./docker_build/db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
|
||||||
|
environment:
|
||||||
|
- "POSTGRES_USER=postgres"
|
||||||
|
- "POSTGRES_PASSWORD=secret"
|
||||||
|
- "POSTGRES_DB=postgres"
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:latest
|
||||||
|
working_dir: /var/www/app
|
||||||
|
volumes:
|
||||||
|
- ./app:/var/www/app
|
||||||
|
- ./docker_build/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
ports:
|
||||||
|
- "8000:80"
|
||||||
|
|
||||||
|
php: &php-fpm
|
||||||
|
build:
|
||||||
|
context: ./docker_build/php
|
||||||
|
args:
|
||||||
|
UID: 1000
|
||||||
|
image: php-fpm_sf5:latest
|
||||||
|
working_dir: /var/www/app
|
||||||
|
volumes:
|
||||||
|
- ./app:/var/www/app
|
||||||
|
- ./docker_build/php/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini
|
26
docker_build/nginx/nginx.conf
Normal file
26
docker_build/nginx/nginx.conf
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
server {
|
||||||
|
listen 80 default;
|
||||||
|
|
||||||
|
client_max_body_size 108M;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/app.access.log;
|
||||||
|
|
||||||
|
|
||||||
|
root /var/www/app/public;
|
||||||
|
index index.php;
|
||||||
|
|
||||||
|
if (!-e $request_filename) {
|
||||||
|
rewrite ^.*$ /index.php last;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass php:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/app_php_errors.log";
|
||||||
|
fastcgi_buffers 16 16k;
|
||||||
|
fastcgi_buffer_size 32k;
|
||||||
|
include fastcgi_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
74
docker_build/php/Dockerfile
Normal file
74
docker_build/php/Dockerfile
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
FROM php:7.3-fpm-buster
|
||||||
|
|
||||||
|
# Set the lifetime of a PHP session
|
||||||
|
ARG SESSION_LIFETIME=10800
|
||||||
|
|
||||||
|
# Set default UID for the PHP user
|
||||||
|
ARG UID=1000
|
||||||
|
ARG GID=1000
|
||||||
|
|
||||||
|
# Install postgresql client
|
||||||
|
# and compile docker php extensions
|
||||||
|
RUN apt update \
|
||||||
|
&& apt -y --no-install-recommends install \
|
||||||
|
wget \
|
||||||
|
gnupg \
|
||||||
|
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
|
||||||
|
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
|
||||||
|
&& apt update \
|
||||||
|
&& apt -y --no-install-recommends install \
|
||||||
|
libicu-dev \
|
||||||
|
g++ \
|
||||||
|
libzip-dev \
|
||||||
|
libzip4 \
|
||||||
|
unzip \
|
||||||
|
libfreetype6-dev \
|
||||||
|
libpng-dev \
|
||||||
|
libjpeg62-turbo-dev \
|
||||||
|
libpq5 \
|
||||||
|
libpq-dev \
|
||||||
|
postgresql-12 \
|
||||||
|
git \
|
||||||
|
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
|
||||||
|
&& docker-php-ext-install -j$(nproc) gd \
|
||||||
|
&& docker-php-ext-install intl pdo_pgsql mbstring zip bcmath sockets exif \
|
||||||
|
&& apt remove -y \
|
||||||
|
wget \
|
||||||
|
gnupg \
|
||||||
|
libicu-dev \
|
||||||
|
g++ \
|
||||||
|
libzip-dev \
|
||||||
|
libpq-dev \
|
||||||
|
&& apt autoremove -y \
|
||||||
|
&& apt purge -y
|
||||||
|
|
||||||
|
# Set php timezone
|
||||||
|
RUN { \
|
||||||
|
echo ""; \
|
||||||
|
echo "[Date]"; \
|
||||||
|
echo "date.timezone = Europe/Brussels"; \
|
||||||
|
echo ""; \
|
||||||
|
} >> /usr/local/etc/php/conf.d/date.ini
|
||||||
|
|
||||||
|
# Install composer
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
|
# Symfony installer
|
||||||
|
RUN curl -sS https://get.symfony.com/cli/installer -o /usr/local/bin/installer | bash \
|
||||||
|
&& chmod a+x /usr/local/bin/installer \
|
||||||
|
&& /usr/local/bin/installer \
|
||||||
|
&& mv /root/.symfony/bin/symfony /usr/local/bin/symfony \
|
||||||
|
&& chmod a+x /usr/local/bin/symfony
|
||||||
|
|
||||||
|
# Add users/groups with uid 1000
|
||||||
|
RUN groupadd --gid ${GID} "group${GID}" \
|
||||||
|
&& useradd --uid ${UID} --gid ${GID} --create-home "user${UID}"
|
||||||
|
|
||||||
|
USER ${UID}
|
||||||
|
|
||||||
|
RUN git config --global user.email "docker-php-master@champs-libres.coop" \
|
||||||
|
&& git config --global user.name "Docker PHP Master"
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
WORKDIR "/var/www/app"
|
2
docker_build/php/php-ini-overrides.ini
Normal file
2
docker_build/php/php-ini-overrides.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
upload_max_filesize = 100M
|
||||||
|
post_max_size = 108M
|
Loading…
Reference in New Issue
Block a user