feat: split dev and prod docker-compose files
This commit is contained in:
parent
07e4f08f31
commit
d9554a6f00
@ -74,9 +74,6 @@ ENV PATH="${PATH}:/root/.composer/vendor/bin"
|
|||||||
|
|
||||||
WORKDIR /srv/app
|
WORKDIR /srv/app
|
||||||
|
|
||||||
# build for production
|
|
||||||
ARG APP_ENV=prod
|
|
||||||
|
|
||||||
# Allow to use development versions of Symfony
|
# Allow to use development versions of Symfony
|
||||||
ARG STABILITY="stable"
|
ARG STABILITY="stable"
|
||||||
ENV STABILITY ${STABILITY:-stable}
|
ENV STABILITY ${STABILITY:-stable}
|
||||||
|
34
README.md
34
README.md
@ -14,24 +14,22 @@ A [Docker](https://www.docker.com/)-based installer and runtime for the [Symfony
|
|||||||
|
|
||||||
Use the `SYMFONY_VERSION` environment variable to select a specific Symfony version.
|
Use the `SYMFONY_VERSION` environment variable to select a specific Symfony version.
|
||||||
|
|
||||||
For instance, use the following command to install Symfony 3.4:
|
For instance, use the following command to install Symfony 4.4:
|
||||||
|
|
||||||
`SYMFONY_VERSION=3.4.* docker-compose up --build`
|
$ SYMFONY_VERSION=4.4.* docker-compose up --build
|
||||||
|
|
||||||
To install a non-stable version of Symfony, use the `STABILITY` environment variable during the build.
|
To install a non-stable version of Symfony, use the `STABILITY` environment variable during the build.
|
||||||
The value must be [a valid Composer stability option](https://getcomposer.org/doc/04-schema.md#minimum-stability)) .
|
The value must be [a valid Composer stability option](https://getcomposer.org/doc/04-schema.md#minimum-stability)) .
|
||||||
|
|
||||||
For instance, use the following command to use the `master` branch of Symfony:
|
For instance, use the following command to use the `master` branch of Symfony:
|
||||||
|
|
||||||
```bash
|
$ STABILITY=dev docker-compose up --build
|
||||||
STABILITY=dev docker-compose up --build
|
|
||||||
```
|
|
||||||
|
|
||||||
## Customize Server Name
|
## Customize Server Name
|
||||||
|
|
||||||
Use the `SERVER_NAME` environment variable to define your custom server name.
|
Use the `SERVER_NAME` environment variable to define your custom server name.
|
||||||
|
|
||||||
`SERVER_NAME=symfony.wip docker-compose up --build`
|
$ SERVER_NAME=symfony.wip docker-compose up --build
|
||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
|
|
||||||
@ -47,7 +45,7 @@ it's recommended to add a custom stage to the end of the `Dockerfile`.
|
|||||||
# Dockerfile
|
# Dockerfile
|
||||||
FROM symfony_php as symfony_php_dev
|
FROM symfony_php as symfony_php_dev
|
||||||
|
|
||||||
ARG XDEBUG_VERSION=2.8.0
|
ARG XDEBUG_VERSION=2.9.8
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
|
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
|
||||||
pecl install xdebug-$XDEBUG_VERSION; \
|
pecl install xdebug-$XDEBUG_VERSION; \
|
||||||
@ -57,12 +55,13 @@ RUN set -eux; \
|
|||||||
|
|
||||||
### Configure Xdebug with Docker Compose Override
|
### Configure Xdebug with Docker Compose Override
|
||||||
|
|
||||||
Using an [override](https://docs.docker.com/compose/reference/overview/#specifying-multiple-compose-files) file named `docker-compose.override.yaml` ensures that the production
|
Using an [override](https://docs.docker.com/compose/reference/overview/#specifying-multiple-compose-files) file named `docker-compose.debug.yaml` ensures that the production
|
||||||
configuration remains untouched.
|
configuration remains untouched.
|
||||||
|
|
||||||
As example, an override could look like this:
|
As example, an override could look like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
# docker-compose.debug.yaml
|
||||||
version: "3.4"
|
version: "3.4"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
@ -86,22 +85,16 @@ services:
|
|||||||
|
|
||||||
Then run:
|
Then run:
|
||||||
|
|
||||||
```bash
|
$ docker-compose -f docker-compose.yml -f docker-compose.debug.yml up -d
|
||||||
docker-compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
If `docker-compose.yml` and a `docker-compose.override.yml` are present on the same directory level, Docker Compose combines the two files into a single configuration, applying the configuration in the `docker-compose.override.yml` file over and in addition to the values in the `docker-compose.yml` file.
|
|
||||||
|
|
||||||
### Troubleshooting
|
### Troubleshooting
|
||||||
|
|
||||||
Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.
|
Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.
|
||||||
|
|
||||||
```bash
|
$ docker-compose exec php php --version
|
||||||
$ docker-compose exec php php --version
|
|
||||||
|
PHP ...
|
||||||
PHP ...
|
with Xdebug v2.8.0 ...
|
||||||
with Xdebug v2.8.0 ...
|
|
||||||
```
|
|
||||||
|
|
||||||
### Editing Permissions on Linux
|
### Editing Permissions on Linux
|
||||||
|
|
||||||
@ -111,9 +104,8 @@ If you work on linux and cannot edit some of the project files right after the f
|
|||||||
|
|
||||||
If you have a SSL trust issues, download the self-signed certificate and run :
|
If you have a SSL trust issues, download the self-signed certificate and run :
|
||||||
|
|
||||||
`sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /path/to/you/certificate.cer`
|
$ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /path/to/you/certificate.cer
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
Created by [Kévin Dunglas](https://dunglas.fr), co-maintained by [Maxime Helias](https://twitter.com/maxhelias) and sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop).
|
Created by [Kévin Dunglas](https://dunglas.fr), co-maintained by [Maxime Helias](https://twitter.com/maxhelias) and sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop).
|
||||||
|
|
||||||
|
29
docker-compose.override.yml
Normal file
29
docker-compose.override.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
version: "3.4"
|
||||||
|
|
||||||
|
# Development environment override
|
||||||
|
services:
|
||||||
|
php:
|
||||||
|
volumes:
|
||||||
|
- ./:/srv/app:rw,cached
|
||||||
|
- ./docker/php/conf.d/symfony.dev.ini:/usr/local/etc/php/conf.d/symfony.ini
|
||||||
|
# If you develop on Linux, comment out the following volumes to just use bind-mounted project directory from host
|
||||||
|
# - ./api/var:/srv/app/var:rw
|
||||||
|
environment:
|
||||||
|
APP_ENV: dev
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
volumes:
|
||||||
|
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
|
||||||
|
- ./public:/srv/app/public:ro
|
||||||
|
|
||||||
|
# This HTTP/2 proxy is not secure: it should only be used in dev
|
||||||
|
h2-proxy:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: symfony_h2-proxy
|
||||||
|
depends_on:
|
||||||
|
- nginx
|
||||||
|
volumes:
|
||||||
|
- ./docker/h2-proxy/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
|
ports:
|
||||||
|
- "443:443"
|
7
docker-compose.prod.yml
Normal file
7
docker-compose.prod.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
version: "3.4"
|
||||||
|
|
||||||
|
# Production environment override
|
||||||
|
services:
|
||||||
|
php:
|
||||||
|
environment:
|
||||||
|
APP_ENV: prod
|
@ -14,14 +14,8 @@ services:
|
|||||||
timeout: 3s
|
timeout: 3s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
volumes:
|
|
||||||
# Comment out the next line in production
|
|
||||||
- ./:/srv/app:rw,cached
|
|
||||||
- ./docker/php/conf.d/symfony.dev.ini:/usr/local/etc/php/conf.d/symfony.ini
|
|
||||||
# If you develop on Linux, comment out the following volumes to just use bind-mounted project directory from host
|
|
||||||
# - ./api/var:/srv/app/var:rw
|
|
||||||
environment:
|
environment:
|
||||||
- SYMFONY_VERSION
|
SYMFONY_VERSION:
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
build:
|
build:
|
||||||
@ -29,21 +23,5 @@ services:
|
|||||||
target: symfony_nginx
|
target: symfony_nginx
|
||||||
depends_on:
|
depends_on:
|
||||||
- php
|
- php
|
||||||
volumes:
|
|
||||||
# Comment out the next line in production
|
|
||||||
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
|
|
||||||
- ./public:/srv/app/public:ro
|
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
|
|
||||||
# This HTTP/2 proxy is not secure: it should only be used in dev
|
|
||||||
h2-proxy:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
target: symfony_h2-proxy
|
|
||||||
depends_on:
|
|
||||||
- nginx
|
|
||||||
volumes:
|
|
||||||
- ./docker/h2-proxy/default.conf:/etc/nginx/conf.d/default.conf:ro
|
|
||||||
ports:
|
|
||||||
- "443:443"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user