Skip to content

Instantly share code, notes, and snippets.

@jlainezs
Created May 2, 2024 09:00
Show Gist options
  • Save jlainezs/cd5ed84e048c3e168f69b1614a807b37 to your computer and use it in GitHub Desktop.
Save jlainezs/cd5ed84e048c3e168f69b1614a807b37 to your computer and use it in GitHub Desktop.
Cloud SQL proxy in a docker compose file
# ---------------------------------------------------------------
# add the service in the docker-compose.yml file
# use .env file to define
# CLOUD_SQL_INSTANCE
# CLOUD_SQL_PORT
# GC_SQL_SERVICE_CREDENTIALS_FILE
#
# @link https://cloud.google.com/sql/docs/sqlserver/connect-docker
# ----------------------------------------------------------------
cloud_sql_service:
container_name: cloudsql-proxy
env_file:
- .env
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.11.0
command: ${CLOUD_SQL_INSTANCE} --address 0.0.0.0 --port ${CLOUD_SQL_PORT} --credentials-file /var/credentials-file.json
ports:
- ${CLOUD_SQL_PORT}:${CLOUD_SQL_PORT}
volumes:
- ${GC_SQL_SERVICE_CREDENTIALS_FILE}:/var/credentials-file.json
networks:
- the_network
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment