8000 doc: add information about building production image (#752) · dunglas/symfony-docker@4b3dd9a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b3dd9a

Browse files
tcoch7-zete-7maxhelias
authored
doc: add information about building production image (#752)
* Add information about building production image * add informations about deploying in production * Fix typo * Remove logs * Maintain common command format Co-authored-by: Stanislau Kviatkouski <7-zete-7@users.noreply.github.com> * Add link about how Docker Compose config file merge works Co-authored-by: Stanislau Kviatkouski <7-zete-7@users.noreply.github.com> * Maintain common command format Co-authored-by: Stanislau Kviatkouski <7-zete-7@users.noreply.github.com> * Maintain common command format Co-authored-by: Maxime Helias <maximehelias16@gmail.com> * Fix to build command Co-authored-by: Stanislau Kviatkouski <7-zete-7@users.noreply.github.com> --------- Co-authored-by: Stanislau Kviatkouski <7-zete-7@users.noreply.github.com> Co-authored-by: Maxime Helias <maximehelias16@gmail.com>
1 parent 65676b9 commit 4b3dd9a

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

docs/production.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ git clone git@github.com:<username>/<project-name>.git
6060
Go into the directory containing your project (`<project-name>`), and start the app in production mode:
6161

6262
```console
63+
# Build fresh production image
64+
docker compose -f compose.yaml -f compose.prod.yaml build --no-cache
65+
66+
# Start container
6367
SERVER_NAME=your-domain-name.example.com \
6468
APP_SECRET=ChangeMe \
6569
CADDY_MERCURE_JWT_SECRET=ChangeThisMercureHubJWTSecretKey \

docs/troubleshooting.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,67 @@ If you work on linux and cannot edit some of the project files right after the f
77
## TLS/HTTPS Issues
88

99
See more in the [TLS section](tls.md)
10+
11+
## Production issues
12+
13+
### How to properly build fresh images for production use
14+
15+
Remember that, by default, if you run `docker compose up -d`, only the files `compose.yaml` and `compose.override.yaml` will be used.
16+
See https://docs.docker.com/compose/intro/compose-application-model and https://docs.docker.com/compose/how-tos/multiple-compose-files/merge.
17+
18+
If you need to build images for production environment, you have to use the following command:
19+
20+
```console
21+
docker compose -f compose.yaml -f compose.prod.yaml build --no-cache
22+
```
23+
24+
### Why application outputs `phpinfo()`
25+
26+
Both dev and prod images have the same image tag (`<...>app-php:latest`). This can cause confusion when working with images.
27+
It is important to make sure that your image is the appropriate one for the current environment.
28+
29+
If you are not careful about this, and try to run your production container(s) with
30+
`docker compose -f compose.yaml -f compose.prod.yaml up -d`
31+
without the right build process beforehand, your application **will still launch**, but will be displaying an output of `phpinfo()` (or possibly even a HTTP 500 error page).
32+
33+
See details below.
34+
35+
<details>
36+
37+
<summary>Output of a basic build process</summary>
38+
39+
In the case of a dev image, you need the `compose.yaml` and `compose.override.yaml` files. Which are the default files for Docker Compose.
40+
This means that running `docker compose <command>` or `docker compose -f compose.yaml -f compose.override.yaml <command>` is the same thing.
41+
42+
And in doing so, images `frankenphp_base` and `frankenphp_dev` are built. And not `frankenphp_prod`.
43+
Which is good enough for dev purposes.
44+
45+
Then, you can start your dev container(s) by running:
46+
47+
```console
48+
docker compose up -d
49+
```
50+
51+
52+
</details>
53+
54+
<br>
55+
56+
<details>
57+
58+
<summary>Output expected for the production build process</summary>
59+
60+
To build the production image, you <ins>have to</ins> specify the `compose.yaml` and `compose.prod.yaml` files.
61+
This means you have to run: `docker compose -f compose.yaml -f compose.prod.yaml build` in order to build your image
62+
(careful: the order of `-f` arguments is important).
63+
64+
That way, you will see that `frankenphp_base` and `frankenphp_prod` are built this time, which is what you will need for production purposes.
65+
66+
You can finally start your prod container(s) by running:
67+
68+
```console
69+
docker compose -f compose.yaml -f compose.prod.yaml up -d
70+
```
71+
72+
</details>
73+

0 commit comments

Comments
 (0)
0