Skip to content

Commit ef6cfe0

Browse files
authored
chore: link to documentation page
1 parent d9aa877 commit ef6cfe0

1 file changed

Lines changed: 1 addition & 294 deletions

File tree

README.md

Lines changed: 1 addition & 294 deletions
Original file line numberDiff line numberDiff line change
@@ -2,297 +2,4 @@
22

33
This repository contains a base image with Alpine + PHP + (Caddy or Nginx), which you can use to build your docker image with your code.
44

5-
> [!NOTE]
6-
> This docker image expects that you install all extensions using Composer. Otherwise, you will get `The class X is not found` errors. See [docs for more information](https://developer.shopware.com/docs/guides/hosting/installation-updates/extension-managment.html)
7-
8-
## Getting Started
9-
10-
Create a Dockerfile in your project like:
11-
12-
```dockerfile
13-
#syntax=docker/dockerfile:1.4
14-
15-
# pin versions
16-
FROM ghcr.io/shopware/docker-base:8.2-nginx as base-image
17-
FROM ghcr.io/friendsofshopware/shopware-cli:latest-php-8.2 as shopware-cli
18-
19-
# build
20-
21-
FROM shopware-cli as build
22-
23-
COPY --link . /src
24-
WORKDIR /src
25-
26-
RUN --mount=type=secret,id=composer_auth,dst=/src/auth.json \
27-
--mount=type=cache,target=/root/.composer \
28-
--mount=type=cache,target=/root/.npm \
29-
/usr/local/bin/entrypoint.sh shopware-cli project ci /src
30-
31-
# build final image
32-
33-
FROM base-image
34-
35-
COPY --from=build --chown=www-data /src /var/www/html
36-
```
37-
38-
or better run `composer req shopware/docker` to install the Symfony Recipe.
39-
40-
In the stage `build` we are using shopware-cli to build the Shopware files:
41-
42-
- Composer installs
43-
- Build Administration and Storefront with Extensions if needed
44-
- Strip some files of vendor to make the layer small
45-
- Merge administration snippets into one file
46-
47-
Refer to [shopware-cli](https://github.com/FriendsOfShopware/shopware-cli) to learn more about `shopware-cli project ci`
48-
49-
## Building docker image
50-
51-
You build your individual docker image with the source code in your CI pipeline and push it to your Container Registry. Later on can you use this image inside example docker-compose / kubernetes / etc.
52-
53-
<details>
54-
<summary>Example Github Action to build the image</summary>
55-
56-
```yaml
57-
name: Build Docker Image
58-
59-
on:
60-
push:
61-
branches:
62-
- main
63-
64-
jobs:
65-
build:
66-
runs-on: ubuntu-latest
67-
steps:
68-
- name: Checkout Repository
69-
uses: actions/checkout@v3
70-
71-
- name: Set up Docker Buildx
72-
uses: docker/setup-buildx-action@v2
73-
74-
- name: Login into Github Docker Registery
75-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
76-
77-
- name: Build and push
78-
uses: docker/build-push-action@v4
79-
with:
80-
context: .
81-
file: ./docker/Dockerfile
82-
push: true
83-
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
84-
```
85-
86-
</details>
87-
88-
## Running the container
89-
90-
<details>
91-
<summary>Example docker-compose</summary>
92-
93-
94-
**CAUTION**
95-
The config below does not share var/log or var/cache. For Caching you should consider to uses Redis and logs should be forwarded to stderr so they are inside the container logs.
96-
97-
```yaml
98-
version: "3.8"
99-
services:
100-
db:
101-
image: mysql:8.0
102-
environment:
103-
MYSQL_ROOT_PASSWORD: 'shopware'
104-
MYSQL_USER: shopware
105-
MYSQL_PASSWORD: shopware
106-
MYSQL_DATABASE: shopware
107-
volumes:
108-
- mysql-data:/var/lib/mysql
109-
110-
init-perm:
111-
image: alpine
112-
volumes:
113-
- files:/var/www/html/files
114-
- theme:/var/www/html/public/theme
115-
- media:/var/www/html/public/media
116-
- thumbnail:/var/www/html/public/thumbnail
117-
- sitemap:/var/www/html/public/sitemap
118-
command: chown 82:82 /var/www/html/files /var/www/html/public/theme /var/www/html/public/media /var/www/html/public/thumbnail /var/www/html/public/sitemap
119-
120-
init:
121-
image: local
122-
build:
123-
context: .
124-
env_file: .app.env
125-
entrypoint: /setup
126-
volumes:
127-
- files:/var/www/html/files
128-
- theme:/var/www/html/public/theme
129-
- media:/var/www/html/public/media
130-
- thumbnail:/var/www/html/public/thumbnail
131-
- sitemap:/var/www/html/public/sitemap
132-
depends_on:
133-
db:
134-
condition: service_started
135-
init-perm:
136-
condition: service_completed_successfully
137-
web:
138-
image: local
139-
build:
140-
context: .
141-
volumes:
142-
- files:/var/www/html/files
143-
- theme:/var/www/html/public/theme
144-
- media:/var/www/html/public/media
145-
- thumbnail:/var/www/html/public/thumbnail
146-
- sitemap:/var/www/html/public/sitemap
147-
depends_on:
148-
init:
149-
condition: service_completed_successfully
150-
env_file: .app.env
151-
ports:
152-
- 8000:8000
153-
154-
worker:
155-
image: local
156-
restart: unless-stopped
157-
build:
158-
context: .
159-
volumes:
160-
- files:/var/www/html/files
161-
- theme:/var/www/html/public/theme
162-
- media:/var/www/html/public/media
163-
- thumbnail:/var/www/html/public/thumbnail
164-
- sitemap:/var/www/html/public/sitemap
165-
depends_on:
166-
init:
167-
condition: service_completed_successfully
168-
env_file: .app.env
169-
entrypoint: [ "php", "bin/console", "messenger:consume", "async", "low_priority", "--time-limit=300", "--memory-limit=512M" ]
170-
deploy:
171-
replicas: 3
172-
173-
scheduler:
174-
image: local
175-
restart: unless-stopped
176-
build:
177-
context: .
178-
volumes:
179-
- files:/var/www/html/files
180-
- theme:/var/www/html/public/theme
181-
- media:/var/www/html/public/media
182-
- thumbnail:/var/www/html/public/thumbnail
183-
- sitemap:/var/www/html/public/sitemap
184-
depends_on:
185-
init:
186-
condition: service_completed_successfully
187-
env_file: .app.env
188-
entrypoint: [ "php", "bin/console", "scheduled-task:run" ]
189-
190-
volumes:
191-
mysql-data:
192-
files:
193-
theme:
194-
media:
195-
thumbnail:
196-
sitemap:
197-
```
198-
199-
</details>
200-
201-
In your setup you should have always an "init" container which does basic stuff like extension updates, theme compile etc with entrypoint `/setup`.
202-
When this container exits, you can start your actual app / worker containers. See docker-compose example above for details.
203-
204-
## Environment variables
205-
206-
| Variable | Default Value | Description |
207-
|--------------------------------------|------------------|------------------------------------------------------------------------------------------|
208-
| APP_ENV | prod | Environment |
209-
| APP_SECRET | (empty) | Can be generated with `openssl rand -hex 32` |
210-
| INSTANCE_ID | (empty) | Unique Identifier for the Store: Can be generated with `openssl rand -hex 32` |
211-
| JWT_PRIVATE_KEY | (empty) | Can be generated with `shopware-cli project generate-jwt --env` |
212-
| JWT_PUBLIC_KEY | (empty) | Can be generated with `shopware-cli project generate-jwt --env` |
213-
| LOCK_DSN | flock | DSN for Symfony locking |
214-
| APP_URL | (empty) | Where Shopware will be accessible |
215-
| DATABASE_HOST | (empty) | Host of MySQL (needed for for checking is MySQL alive) |
216-
| DATABASE_PORT | 3306 | Host of MySQL (needed for for checking is MySQL alive) |
217-
| BLUE_GREEN_DEPLOYMENT | 0 | This needs super priviledge to create trigger |
218-
| DATABASE_URL | (empty) | MySQL credentials as DSN |
219-
| DATABASE_SSL_CA | (empty) | Path to SSL CA file (needs to be readable for uid 512) |
220-
| DATABASE_SSL_CERT | (empty) | Path to SSL Cert file (needs to be readable for uid 512) |
221-
| DATABASE_SSL_KEY | (empty) | Path to SSL Key file (needs to be readable for uid 512) |
222-
| DATABASE_SSL_DONT_VERIFY_SERVER_CERT | (empty) | Disables verification of the server certificate (1 disables it) |
223-
| MAILER_DSN | null://localhost | Mailer DSN (Admin Configuration overwrites this) |
224-
| OPENSEARCH_URL | (empty) | OpenSearch Hosts |
225-
| SHOPWARE_ES_ENABLED | 0 | OpenSearch Support Enabled? |
226-
| SHOPWARE_ES_INDEXING_ENABLED | 0 | OpenSearch Indexing Enabled? |
227-
| SHOPWARE_ES_INDEX_PREFIX | (empty) | OpenSearch Index Prefix |
228-
| COMPOSER_HOME | /tmp/composer | Caching for the Plugin Manager |
229-
| SHOPWARE_HTTP_CACHE_ENABLED | 1 | Is HTTP Cache enabled? |
230-
| SHOPWARE_HTTP_DEFAULT_TTL | 7200 | Default TTL for Http Cache |
231-
| MESSENGER_TRANSPORT_DSN | (empty) | DSN for default async queue (example: `amqp://guest:guest@localhost:5672/%2f/default` |
232-
| MESSENGER_TRANSPORT_LOW_PRIORITY_DSN | (empty) | DSN for low priority queue (example: `amqp://guest:guest@localhost:5672/%2f/low_prio` |
233-
| MESSENGER_TRANSPORT_FAILURE_DSN | (empty) | DSN for failed messages queue (example: `amqp://guest:guest@localhost:5672/%2f/failure` |
234-
| COMPOSER_PLUGIN_LOADER | 1 | [When enabled, disables dynamic plugin loading all plugins needs to be installed with Composer](https://developer.shopware.com/docs/guides/hosting/installation-updates/cluster-setup.html#composer-plugin-loader)
235-
| INSTALL_LOCALE | en-GB | Default locale for the Shop |
236-
| INSTALL_CURRENCY | EUR | Default currency for the Shop |
237-
| INSTALL_ADMIN_USERNAME | admin | Default admin username |
238-
| INSTALL_ADMIN_PASSWORD | shopware | Default admin password |
239-
| PHP_SESSION_COOKIE_LIFETIME | 0 | [See PHP FPM documentation](https://www.php.net/manual/en/session.configuration.php) |
240-
| PHP_SESSION_GC_MAXLIFETIME | 1440 | [See PHP FPM documentation](https://www.php.net/manual/en/session.configuration.php) |
241-
| PHP_SESSION_HANDLER | files | Set to `redis` for redis session |
242-
| PHP_SESSION_SAVE_PATH | (empty) | Set to `tcp://redis:6379` for redis session |
243-
| PHP_MAX_UPLOAD_SIZE | 128m | See PHP documentation |
244-
| PHP_MAX_EXECUTION_TIME | 300 | See PHP documentation |
245-
| PHP_MEMORY_LIMIT | 512m | See PHP documentation |
246-
| FPM_PM | dynamic | [See PHP FPM documentation](https://www.php.net/manual/en/install.fpm.configuration.php) |
247-
| FPM_PM_MAX_CHILDREN | 5 | [See PHP FPM documentation](https://www.php.net/manual/en/install.fpm.configuration.php) |
248-
| FPM_PM_START_SERVERS | 2 | [See PHP FPM documentation](https://www.php.net/manual/en/install.fpm.configuration.php) |
249-
| FPM_PM_MIN_SPARE_SERVERS | 1 | [See PHP FPM documentation](https://www.php.net/manual/en/install.fpm.configuration.php) |
250-
| FPM_PM_MAX_SPARE_SERVERS | 3 | [See PHP FPM documentation](https://www.php.net/manual/en/install.fpm.configuration.php) |
251-
252-
There are even more environment variables, that affect a running container as our [deployment helper](https://github.com/shopware/deployment-helper) is used.
253-
Read more about its configuration, usage and possible configuration in the [Deployment Helper section of our documentation](https://developer.shopware.com/docs/guides/hosting/installation-updates/deployments/deployment-helper.html).
254-
255-
## Volumes
256-
257-
In a very basic setup when all files are stored locally you need 5 volumes:
258-
259-
| Usage | Path |
260-
|------------------------|--------------------------------|
261-
| invoices/private files | /var/www/html/files |
262-
| theme files | /var/www/html/public/theme |
263-
| images | /var/www/html/public/media |
264-
| image thumbnails | /var/www/html/public/thumbnail |
265-
| generated sitemap | /var/www/html/public/sitemap |
266-
267-
It is recommanded to use an external storage provider when possible to store the files. With an external storage provider you won't need any mounts. Refer to [official Shopware docs for setup](https://developer.shopware.com/docs/guides/hosting/infrastructure/filesystem).
268-
269-
## FAQ
270-
271-
<details>
272-
<summary>Use Redis for sessions</summary>
273-
274-
You can set `PHP_SESSION_HANDLER` to `redis` and `PHP_SESSION_SAVE_PATH` to any redis path like `tcp://redis:6379`
275-
</details>
276-
277-
## Known issues
278-
279-
<details>
280-
<summary>Assets are stored locally, but asset-manifest.json tries to write to external location</summary>
281-
282-
Override the filesystem of asset-manifest.json to temporary filesystem:
283-
284-
```yaml
285-
# config/packages/prod/asset-overwrite.yaml
286-
services:
287-
Shopware\Core\Framework\Plugin\Util\AssetService:
288-
arguments:
289-
- '@shopware.filesystem.asset'
290-
- '@shopware.filesystem.temp'
291-
- '@kernel'
292-
- '@Shopware\Core\Framework\Plugin\KernelPluginLoader\KernelPluginLoader'
293-
- '@Shopware\Core\Framework\Adapter\Cache\CacheInvalidator'
294-
- '@Shopware\Core\Framework\App\Lifecycle\AppLoader'
295-
- '@parameter_bag'
296-
```
297-
298-
</details>
5+
[Documentation can be found here](https://developer.shopware.com/docs/guides/hosting/installation-updates/docker.html)

0 commit comments

Comments
 (0)