I'm using a fairly fresh API Platform install, with all the Docker containers it comes with, however I have swapped out the Postgres service for a MySQL service, as we're connecting to an existing database.
The problem I am experiencing is that everything seems to work fine for a while (2-5 mins), and then, all of a sudden my PHP container shuts down, and even though I don't have a restart policy setup, I see several new PHP containers attempt to start up (each identified by a different colour in the docker-compose logs, which fail to do so because they don't appear to have the required env vars set in the containers, so the startup fails. As far as I can tell the original PHP container looks like it's shutting down normally, for some reason, as it reports…
php_1 | 172.25.0.5 - 11/Oct/2020:18:17:04 +0000 "GET /index.php" 200
vulcain_1 | 172.25.0.1 - - [11/Oct/2020:18:17:04 +0000] "GET /_profiler/9e2a1e HTTP/2.0" 200 41337 "https://localhost:8443/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome
/86.0.4240.75 Safari/537.36"
api_1 | 172.25.0.6 - - [11/Oct/2020:18:17:11 +0000] "GET /_profiler/9e2a1e?panel=dump HTTP/1.1" 200 125595 "https://localhost:8443/_profiler/9e2a1e" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.3
6 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
php_1 | 172.25.0.5 - 11/Oct/2020:18:17:11 +0000 "GET /index.php" 200
vulcain_1 | 172.25.0.1 - - [11/Oct/2020:18:17:11 +0000] "GET /_profiler/9e2a1e?panel=dump HTTP/2.0" 200 29094 "https://localhost:8443/_profiler/9e2a1e" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
php_1 | 127.0.0.1 - 11/Oct/2020:18:17:13 +0000 "GET /ping" 200
php_1 | 127.0.0.1 - 11/Oct/2020:18:17:23 +0000 "GET /ping" 200
php_1 | 127.0.0.1 - 11/Oct/2020:18:17:33 +0000 "GET /ping" 200
php_1 | 127.0.0.1 - 11/Oct/2020:18:17:43 +0000 "GET /ping" 200
php_1 | 127.0.0.1 - 11/Oct/2020:18:17:53 +0000 "GET /ping" 200
php_1 | 127.0.0.1 - 11/Oct/2020:18:18:03 +0000 "GET /ping" 200
php_1 | [11-Oct-2020 18:18:07] NOTICE: Finishing ...
php_1 | [11-Oct-2020 18:18:07] NOTICE: exiting, bye-bye!
goodtech_crm_api_php_1 exited with code 0
And below that are the following errors…
php_1 | WARNING: ca-certificates.crt does not contain exactly one certificate or CRL: skipping
php_1 |
php_1 |
php_1 | [UnexpectedValueException]
php_1 | Your github oauth token for github.com contains invalid characters: ""
php_1 |
php_1 |
goodtech_crm_api_php_1 exited with code 1
php_1 | WARNING: ca-certificates.crt does not contain exactly one certificate or CRL: skipping
php_1 |
php_1 |
php_1 | [UnexpectedValueException]
php_1 | Your github oauth token for github.com contains invalid characters: ""
php_1 |
php_1 |
goodtech_crm_api_php_1 exited with code 1
php_1 | WARNING: ca-certificates.crt does not contain exactly one certificate or CRL: skipping
php_1 |
php_1 |
php_1 | [UnexpectedValueException]
php_1 | Your github oauth token for github.com contains invalid characters: ""
php_1 |
php_1 |
goodtech_crm_api_php_1 exited with code 1
If I docker-composer down --remove-orphans && docker-comopse up -d
then all works fine again, for a short while.
Can anyone help me with how I can diagnose any of the following?…
- Why my initial container is terminating?
- Why docker-compose is restarting the containers without a restart policy being set? Is it because of the health check?
- Why the subsequent containers are missing the env vars they should have set? Is it because it's not starting from my shell, and therefore does not have access to my env vars?
Here is my docker-compose.yml
file…
version: '3.4'
services:
php:
image: "${PHP_IMAGE}"
healthcheck:
interval: 10s
timeout: 3s
retries: 3
start_period: 30s
depends_on:
- db
- dev-tls
volumes:
- ./api:/srv/api:rw,cached
- ./api/docker/php/conf.d/api-platform.dev.ini:/usr/local/etc/php/conf.d/api-platform.ini
# if you develop on Linux, you may use a bind-mounted host directory instead
# - ./api/var:/srv/api/var:rw
- dev-certs:/certs:ro,nocopy
environment:
- 'COMPOSER_AUTH={"github-oauth":{"github.com":"${GITHUB_COMPOSER_TOKEN}"},"gitlab-token":{"gitlab.com":"${GITLAB_COMPOSER_TOKEN}"}}'
api:
image: "${NGINX_IMAGE}"
depends_on:
- php
volumes:
- ./api/public:/srv/api/public:ro
vulcain:
image: dunglas/vulcain
environment:
- CERT_FILE=/certs/localhost.crt
- KEY_FILE=/certs/localhost.key
- UPSTREAM=http://api
depends_on:
- api
- dev-tls
volumes:
- dev-certs:/certs:ro,nocopy
ports:
- target: 443
published: 8443
protocol: tcp
db:
image: mariadb:10.1
command:
- 'mysqld'
- '--character-set-server=utf8mb4'
- '--collation-server=utf8mb4_unicode_ci'
environment:
- 'MYSQL_DATABASE=${GOODCRM_DB_DATABASE}'
- 'MYSQL_USER=${GOODCRM_DB_USER}'
- 'MYSQL_PASSWORD=${GOODCRM_DB_PASSWORD}'
- 'MYSQL_RANDOM_ROOT_PASSWORD=yes'
volumes:
# Pre-load the d/b
- ./api/data:/docker-entrypoint-initdb.d
ports:
- target: 3306
published: 13306
protocol: tcp
mercure:
image: dunglas/mercure
environment:
- ALLOW_ANONYMOUS=1
- CERT_FILE=/certs/localhost.crt
- CORS_ALLOWED_ORIGINS=*
- DEMO=1
- JWT_KEY=!ChangeMe!
- KEY_FILE=/certs/localhost.key
- PUBLISH_ALLOWED_ORIGINS=https://localhost:1337 # required for publishing from the demo page
depends_on:
- dev-tls
volumes:
- dev-certs:/certs:ro,nocopy
ports:
- target: 443
published: 1337
protocol: tcp
client:
image: "${CLIENT_IMAGE}"
tty: true # https://github.com/facebook/create-react-app/issues/8688
environment:
- API_PLATFORM_CLIENT_GENERATOR_ENTRYPOINT=http://api
- API_PLATFORM_CLIENT_GENERATOR_OUTPUT=src
depends_on:
- dev-tls
volumes:
- ./client:/usr/src/client:rw,cached
- dev-certs:/usr/src/client/node_modules/webpack-dev-server/ssl:rw,nocopy
ports:
- target: 3000
published: 443
protocol: tcp
admin:
image: "${ADMIN_IMAGE}"
tty: true # https://github.com/facebook/create-react-app/issues/8688
depends_on:
- dev-tls
volumes:
- ./admin:/usr/src/admin:rw,cached
- dev-certs:/usr/src/admin/node_modules/webpack-dev-server/ssl:rw,nocopy
ports:
- target: 3000
published: 444
protocol: tcp
dev-tls:
image: "${DEV_TLS_IMAGE}"
volumes:
- dev-certs:/certs:rw
ports:
- target: 80
published: 80
protocol: tcp
volumes:
dev-certs: {}
After a few days away from the project I've fired it up again and the problem seems to have gone away, so no idea what was causing, and can no longer diagnose since it's no longer failing.