| # Copyright 2021 The Go Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style |
| # license that can be found in the LICENSE file. |
| version: '3.4' |
| |
| x-database-variables: &database-variables |
| GO_DISCOVERY_DATABASE_HOST: db |
| GO_DISCOVERY_DATABASE_NAME: ${GO_DISCOVERY_DATABASE_NAME:-discovery-db} |
| GO_DISCOVERY_DATABASE_PASSWORD: ${GO_DISCOVERY_DATABASE_PASSWORD:-postgres} |
| GO_DISCOVERY_DATABASE_USER: ${GO_DISCOVERY_DATABASE_USER:-postgres} |
| |
| x-go-variables: &go-variables |
| GOMODCACHE: /gomodcache |
| GO_DISCOVERY_CONFIG_DYNAMIC: |
| GO_DISCOVERY_LOG_LEVEL: ${GO_DISCOVERY_LOG_LEVEL:-info} |
| GO_DISCOVERY_SERVE_STATS: "true" |
| |
| services: |
| allbash: |
| # Allocate a pseudo-tty, which sets the TERM |
| # environment variable to xterm. |
| # See |
| # https://docs.docker.com/engine/reference/run/#env-environment-variables and |
| # https://www.gnu.org/software/gettext/manual/html_node/The-TERM-variable.html. |
| # This is necessary because devtools/lib.sh uses tput. |
| tty: |
| true |
| # allbash depends only on db, since the Go tests will set up its own |
| # test databases. |
| depends_on: |
| - db |
| # This should match the version we are using on AppEngine. |
| image: golang:1.15.5 |
| environment: |
| <<: *database-variables |
| <<: *go-variables |
| GO_DISCOVERY_TESTDB: ${GO_DISCOVERY_TESTDB:-"true"} |
| # TERM is set to xterm-256color for use by devtools/lib.sh. |
| TERM: xterm-256color |
| WAITFORIT_TIMEOUT: 300 |
| entrypoint: ./third_party/wait-for-it/wait-for-it.sh db:5432 -- ./all.bash |
| volumes: |
| - ../../:/pkgsite |
| working_dir: /pkgsite |
| api: |
| image: golang:1.15.5 |
| depends_on: |
| - frontend |
| environment: |
| <<: *go-variables |
| WAITFORIT_TIMEOUT: 300 |
| entrypoint: ./third_party/wait-for-it/wait-for-it.sh frontend:8080 -- go run |
| command: "tests/api/main.go -frontend http://host.docker.internal:8080 -all compare " |
| volumes: |
| - ../../:/pkgsite |
| working_dir: /pkgsite |
| e2e: |
| image: node:14.17.0 |
| depends_on: |
| - chrome |
| - frontend |
| environment: |
| # CI is used for cleaner log output from jest and npm install |
| - CI=true |
| - GO_DISCOVERY_E2E_BASE_URL=http://frontend:8080 |
| - GO_DISCOVERY_E2E_CHROME_URL=ws://chrome:${GO_DISCOVERY_E2E_TEST_PORT:-3000} |
| - GO_DISCOVERY_E2E_ENVIRONMENT=ci |
| - WAITFORIT_TIMEOUT=300 |
| entrypoint: ./third_party/wait-for-it/wait-for-it.sh frontend:8080 -- npx jest |
| command: e2e |
| volumes: |
| - ../../:/pkgsite |
| working_dir: /pkgsite |
| frontend: |
| # This should match the version we are using on AppEngine. |
| image: golang:1.15.5 |
| depends_on: |
| - db |
| command: bash -c " |
| ./third_party/wait-for-it/wait-for-it.sh db:5432 -- |
| go run ./devtools/cmd/db/main.go create && |
| go run ./devtools/cmd/db/main.go migrate && |
| go run ./cmd/frontend -host=0.0.0.0:8080" |
| environment: |
| <<: *database-variables |
| <<: *go-variables |
| PORT: 8080 |
| WAITFORIT_TIMEOUT: 300 |
| ports: |
| - 8080:8080 |
| volumes: |
| - ../../:/pkgsite |
| - gomodcache:/gomodcache |
| working_dir: /pkgsite |
| seeddb: |
| # This should match the version we are using on AppEngine. |
| image: golang:1.15.5 |
| depends_on: |
| - db |
| # Note: technically we should check that migrations have completed before |
| # running seeddb, but in general, migrations will have completed by the |
| # time seeddb runs. If this ends up being flaky, we should add a check here. |
| command: bash -c " |
| echo GO_DISCOVERY_CONFIG_DYNAMIC=$GO_DISCOVERY_CONFIG_DYNAMIC && |
| ./third_party/wait-for-it/wait-for-it.sh db:5432 -- |
| go run ./devtools/cmd/db/main.go create && |
| go run ./devtools/cmd/db/main.go migrate && |
| go run ./devtools/cmd/seeddb/main.go -seed ${GO_DISCOVERY_SEED_DB_FILE:-seed.txt}" |
| environment: |
| <<: *database-variables |
| <<: *go-variables |
| WAITFORIT_TIMEOUT: 300 |
| volumes: |
| - ../../:/pkgsite |
| - gomodcache:/gomodcache |
| working_dir: /pkgsite |
| db: |
| image: postgres:11.12 |
| environment: |
| <<: *database-variables |
| LANG: C |
| # GO_DISCOVERY_DATABASE* variables are set so that this docker file can |
| # be used for local development. |
| POSTGRES_DB: ${GO_DISCOVERY_DATABASE_NAME:-discovery-db} |
| POSTGRES_PASSWORD: ${GO_DISCOVERY_DATABASE_PASSWORD:-postgres} |
| POSTGRES_USER: ${GO_DISCOVERY_DATABASE_USER:-postgres} |
| ports: |
| - ${GO_DISCOVERY_DATABASE_PORT:-5432}:5432 |
| nodejs: |
| image: node:14.17.0 |
| environment: |
| # Use the values set on the host machine environment. |
| - CI |
| # GO_DISCOVERY_E2E_* variables are used by the deployment script. |
| - GO_DISCOVERY_E2E_AUTHORIZATION |
| - GO_DISCOVERY_E2E_BASE_URL |
| - GO_DISCOVERY_E2E_CHROME_URL=ws://chrome:${GO_DISCOVERY_E2E_TEST_PORT:-3000} |
| - GO_DISCOVERY_E2E_QUOTA_BYPASS |
| - GO_DISCOVERY_E2E_ENVIRONMENT |
| - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD |
| volumes: |
| - ../../:/pkgsite |
| working_dir: /pkgsite |
| chrome: |
| image: browserless/chrome:1.46.0-puppeteer-10.1.0 |
| ports: |
| - 3000:3000 |
| environment: |
| - CONNECTION_TIMEOUT=240000 |
| go: |
| # This should match the version we are using on AppEngine. |
| image: golang:1.15.5 |
| entrypoint: go |
| environment: |
| <<: *database-variables |
| <<: *go-variables |
| volumes: |
| - ../../:/pkgsite |
| - gomodcache:/gomodcache |
| working_dir: /pkgsite |
| volumes: |
| gomodcache: |