|
| 1 | +# A Docker Compose file for running the production build locally. |
| 2 | +# Usage: |
| 3 | +# docker compose up -d --build --force-recreate |
| 4 | +services: |
| 5 | + tag-page-rendering: |
| 6 | + build: |
| 7 | + dockerfile: ./Production.dockerfile |
| 8 | + environment: |
| 9 | + NODE_ENV: production |
| 10 | + GU_STAGE: PROD |
| 11 | + GU_APP: tag-page-rendering |
| 12 | + GU_STACK: frontend |
| 13 | + |
| 14 | + # We configure Log4JS based on this environment variable. See `server/lib/logging.ts`. |
| 15 | + AWS_EXECUTION_ENV: AWS_ECS_LOCAL |
| 16 | + |
| 17 | + # Explicitly tell AWS SDK where to find credentials |
| 18 | + AWS_SHARED_CREDENTIALS_FILE: /.aws/credentials |
| 19 | + ports: |
| 20 | + - '9000:9000' |
| 21 | + |
| 22 | + # Share the host's AWS credentials with the container |
| 23 | + volumes: |
| 24 | + - ${HOME}/.aws/credentials:/.aws/credentials:ro |
| 25 | + |
| 26 | + # In Production.dockerfile, we're deliberately using a minimal image that does not have `curl` installed. |
| 27 | + # Therefore, we're using Node to make a request to the healthcheck endpoint instead of using `curl`. |
| 28 | + healthcheck: |
| 29 | + test: |
| 30 | + [ |
| 31 | + 'CMD', |
| 32 | + 'node', |
| 33 | + '-e', |
| 34 | + "fetch('http://localhost:9000/_healthcheck').then(_ => process.exit(0)).catch(_ => process.exit(1))", |
| 35 | + ] |
| 36 | + interval: 10s |
| 37 | + timeout: 5s |
| 38 | + retries: 5 |
| 39 | + |
| 40 | + # This service is used to make a sample request to tag-page-rendering only after it has started and is healthy. |
| 41 | + # It exits immediately after making the request, so it is not a long-running service. |
| 42 | + # View the logs via: |
| 43 | + # docker logs "$(docker ps -aq --filter "name=sample-request" --latest)" |
| 44 | + # The log output is the DCR response, so we can also pipe it through `jq` to pretty-print it, e.g.: |
| 45 | + # docker logs "$(docker ps -aq --filter "name=sample-request" --latest)" | jq . |
| 46 | + sample-request: |
| 47 | + image: curlimages/curl:8.21.0 |
| 48 | + depends_on: |
| 49 | + tag-page-rendering: |
| 50 | + condition: service_healthy |
| 51 | + command: | |
| 52 | + curl "https://www.theguardian.com/tone/minutebyminute.json?dcr=true" --silent > data.json && \ |
| 53 | + curl -X POST http://localhost:9000/TagPage -d @data.json -H "Content-Type: application/json" |
0 commit comments