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.7" | |
services: | |
next-strapi-cloud-run-cloud-sql-proxy: | |
container_name: next-strapi-cloud-run-cloud-sql-proxy | |
image: gcr.io/cloudsql-docker/gce-proxy:1.19.1 | |
command: /cloud_sql_proxy -instances={Cloud SQL connnection name}=tcp:0.0.0.0:3306 -credential_file=/credentials.json | |
volumes: | |
- ./google-credentials.json:/credentials.json | |
ports: | |
- 3308:3306 |
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
#! /bin/bash | |
apt-get update && apt-get install default-mysql-client -y | |
query="SELECT count(*) AS TOTALNUMBEROFTABLES FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'production';" | |
tableCount=$(mysql -u "$DB_USERNAME" -p"$DB_PASSWORD" -h "$DB_HOST" -s -e "$query") | |
echo "" | |
echo "Starting database dump..." | |
if [[ $tableCount = "0" ]]; then |
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
output "gcp_project_id" { | |
value = google_project.project.project_id | |
} | |
output "local_database_service_account_key_json" { | |
value = base64decode(google_service_account_key.local_database.private_key) | |
} | |
output "cloud_sql_root_user_password" { | |
value = random_password.cms_sql_root_password.result |
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
#! /bin/bash | |
echo "" | |
echo "Building and deploying the CMS..." | |
cd cms || exit | |
image="eu.gcr.io/$GCLOUD_PROJECT_ID/$BITBUCKET_DEPLOYMENT_ENVIRONMENT" | |
existing_tags=$(gcloud container images list-tags --filter="tags:cms" --format=json "$image") |
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
#! /bin/bash | |
echo "" | |
echo "Building and deploying the app..." | |
cd app || exit | |
image="eu.gcr.io/$GCLOUD_PROJECT_ID/$BITBUCKET_DEPLOYMENT_ENVIRONMENT" | |
existing_tags=$(gcloud container images list-tags --filter="tags:app" --format=json "$image") |
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
#! /bin/bash | |
# Activate Google Serice Account responsible for deployments | |
echo "$GCLOUD_SERVICE_ACCOUNT_KEY" > .service-account-key.json | |
gcloud auth activate-service-account --key-file .service-account-key.json | |
# Set te project in gcloud so it knows which project to interact with | |
gcloud config set project "$GCLOUD_PROJECT_ID" | |
# Authorize docker so we can push images to Google Container Registry |
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
pipelines: | |
branches: | |
master: | |
- step: | |
name: Deploy to Production | |
deployment: production | |
image: google/cloud-sdk:latest | |
services: | |
- docker | |
caches: |
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
{ | |
"defaultConnection": "default", | |
"connections": { | |
"default": { | |
"connector": "bookshelf", | |
"settings": { | |
"client": "mysql", | |
"database": "${process.env.DB_NAME}", | |
"username": "${process.env.DB_USERNAME}", | |
"password": "${process.env.DB_PASSWORD}", |
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
FROM node:12-alpine | |
WORKDIR /usr/src/app | |
ARG CMS_GRAPHQL_URL | |
ENV CMS_GRAPHQL_URL=$CMS_GRAPHQL_URL | |
ENV NODE_ENV=production | |
COPY package*.json ./ |
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
FROM node:12-alpine | |
WORKDIR /usr/src/cms | |
ENV NODE_ENV=production | |
COPY package*.json ./ | |
RUN npm ci --production && npm cache clean --force | |
COPY . . |
NewerOlder