| # 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. | |
| 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" | |
| GO_DISCOVERY_VULN_DB: | |
| 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 Cloud Run. | |
| image: golang:${GO_VERSION} | |
| 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 | |
| entrypoint: go run ./devtools/cmd/wait_available --timeout 300s db:5432 -- ./all.bash | |
| volumes: | |
| - ../../:/pkgsite | |
| working_dir: /pkgsite | |
| searchtest: | |
| image: golang:${GO_VERSION} | |
| depends_on: | |
| - frontend | |
| environment: | |
| <<: [*database-variables, *go-variables] | |
| entrypoint: go run ./devtools/cmd/wait_available --timeout 300s frontend:8080 -- go run | |
| command: "tests/search/main.go -frontend http://frontend:8080" | |
| volumes: | |
| - ../../:/pkgsite | |
| working_dir: /pkgsite | |
| api: | |
| image: golang:${GO_VERSION} | |
| depends_on: | |
| - frontend | |
| environment: | |
| <<: *go-variables | |
| entrypoint: go run ./devtools/cmd/wait_available --timeout 300s frontend:8080 -- go run | |
| command: "tests/api/main.go -frontend http://frontend:8080 -all compare " | |
| volumes: | |
| - ../../:/pkgsite | |
| working_dir: /pkgsite | |
| frontend: | |
| # This should match the version we are using on AppEngine. | |
| image: golang:${GO_VERSION} | |
| depends_on: | |
| - db | |
| command: bash -c " | |
| go run ./devtools/cmd/wait_available --timeout 300s 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 | |
| volumes: | |
| - ../../:/pkgsite | |
| - gomodcache:/gomodcache | |
| working_dir: /pkgsite | |
| seeddb: | |
| # This should match the version we are using on Cloud Run. | |
| image: golang:${GO_VERSION} | |
| 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 && | |
| GODEBUG=cmdgonetlimit=64 go run ./devtools/cmd/wait_available --timeout 300s 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] | |
| volumes: | |
| - ../../:/pkgsite | |
| - gomodcache:/gomodcache | |
| working_dir: /pkgsite | |
| db: | |
| image: pgvector/pgvector:pg14 | |
| 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} | |
| volumes: | |
| - pgdata:/var/lib/postgresql/data | |
| ports: | |
| - 127.0.0.1:5432:5432 | |
| nodejs: | |
| image: node:20 | |
| 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 | |
| chromedp: | |
| # This should match the version we are using in tests/screentest/run.sh. | |
| image: chromedp/headless-shell:131.0.6778.33 | |
| shm_size: 8G | |
| go: | |
| # This should match the version we are using on Cloud Run. | |
| image: golang:${GO_VERSION} | |
| entrypoint: go | |
| environment: | |
| <<: [*database-variables, *go-variables] | |
| volumes: | |
| - ../../:/pkgsite | |
| - gomodcache:/gomodcache | |
| working_dir: /pkgsite | |
| volumes: | |
| gomodcache: | |
| pgdata: |