I am trying to deploy api-platform docker-compose images to Cloud Run. I have that working up to the point where the image starts to run. I have the system listening on port 8080 but I cannot turn off the https redirect. So, it shuts down. Here is the message I receive:
ERROR: (gcloud.run.deploy) Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.
run: loading initial config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 0: loading handler modules: position 0: loading module 'subroute': provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module 'subroute': provision http.handlers.subroute: setting up subroutes: route 1: loading handler modules: position 0: loading module 'mercure': provision http.handlers.mercure: a JWT key for publishers must be provided
I am using Cloud Build to build the container and deploy to Run. This is kicked off through Gitlab CI.
This is my cloudbuild.yaml file.
steps:
- name: docker/compose
args: ['build']
- name: 'gcr.io/cloud-builders/docker'
args: ['tag', 'workspace_caddy:latest', 'gcr.io/$PROJECT_ID/apiplatform']
- name: docker
args: [ 'push', 'gcr.io/$PROJECT_ID/apiplatform']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['run', 'deploy', 'erp-ui', '--image', 'gcr.io/$PROJECT_ID/apiplatform', '--region', 'us-west1', '--platform', 'managed', '--allow-unauthenticated']
docker-compose.yml
version: "3.4"
services:
php:
build:
context: ./api
target: api_platform_php
depends_on:
- database
restart: unless-stopped
volumes:
- php_socket:/var/run/php
healthcheck:
interval: 10s
timeout: 3s
retries: 3
start_period: 30s
pwa:
build:
context: ./pwa
target: api_platform_pwa_prod
environment:
API_PLATFORM_CLIENT_GENERATOR_ENTRYPOINT: http://caddy
caddy:
build:
context: api/
target: api_platform_caddy
depends_on:
- php
- pwa
environment:
PWA_UPSTREAM: pwa:3000
SERVER_NAME: ${SERVER_NAME:-localhost, caddy:8080}
MERCURE_PUBLISHER_JWT_KEY: ${MERCURE_PUBLISHER_JWT_KEY:-!ChangeMe!}
MERCURE_SUBSCRIBER_JWT_KEY: ${MERCURE_SUBSCRIBER_JWT_KEY:-!ChangeMe!}
restart: unless-stopped
volumes:
- php_socket:/var/run/php
- caddy_data:/data
- caddy_config:/config
ports:
# HTTP
- target: 8080
published: 8080
protocol: tcp
database:
image: postgres:13-alpine
environment:
- POSTGRES_DB=api
- POSTGRES_PASSWORD=!ChangeMe!
- POSTGRES_USER=api-platform
volumes:
- db_data:/var/lib/postgresql/data:rw
# you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
# - ./api/docker/db/data:/var/lib/postgresql/data:rw
volumes:
php_socket:
db_data:
caddy_data:
caddy_config: