Created
September 13, 2018 16:58
-
-
Save adilsoncarvalho/4c33be744ef2e879e679703efd995968 to your computer and use it in GitHub Desktop.
Example of a docker-compose.yml mounting cloud_sql_proxy as a service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
app: | |
build: . | |
# your own configurations for that app | |
depends_on: | |
- cloud-sql-proxy | |
environment: | |
# You must set an URL to access your database. On sequelize (nodejs) it follows this | |
# format: db-type://user:password@host:port/database-name | |
# the one below is for a MySQL database. | |
DATABASE_URL: mysql://dbuser:dbpassword@cloud-sql-proxy:3306/database | |
cloud-sql-proxy: | |
image: gcr.io/cloudsql-docker/gce-proxy:1.11 | |
# Port: MySQL (3306), PostgreSQL (5433) | |
command: /cloud_sql_proxy -instances=PROJECTID:ZONE:INSTANCE=tcp:0.0.0.0:3306 | |
volumes: | |
# this mounts your application default credential on the container, preventing the | |
# 'invalid json file "/config": google: read JWT from JSON credentials: 'type' field is "authorized_user" (expected "service_account")' | |
# error if you point to the actual credential file directly | |
- ~/.config:/root/.config | |
ports: | |
- 3306:3306 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment