Skip to content

Commit 29f5527

Browse files
committed
Add Google Cloud build infrastructure
1 parent 3d2c88a commit 29f5527

6 files changed

+70
-1
lines changed

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@ stop:
3030
.PHONY: rm
3131
rm rmc: stop
3232
${DC} rm -f
33+
34+
.PHONY: gcloud-deploy
35+
gcloud-deploy:
36+
docker compose -f docker-compose.yml -f docker-compose.gcloud.yml --env-file=gcloud.env up -d website
37+
docker compose -f docker-compose.yml -f docker-compose.gcloud.yml --env-file=gcloud.env ps
38+
@echo
39+
@echo 'WOM website deployed'
40+
@echo

cloudbuild.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
steps:
2+
- name: gcr.io/cloud-builders/docker
3+
args:
4+
- build
5+
- '--no-cache'
6+
- '-t'
7+
- '--build-arg ARG_GOOGLE_MAPS_API=$_GOOGLE_MAPS_API'
8+
- '--build-arg ARG_SEND_IN_BLUE_API=$_SEND_IN_BLUE_API'
9+
- '--build-arg ARG_SENTRY_DSN=$_SENTRY_DSN'
10+
- '$_GCR_HOSTNAME/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA'
11+
- './src/Website'
12+
id: Build
13+
14+
- name: gcr.io/cloud-builders/docker
15+
args:
16+
- push
17+
- '$_GCR_HOSTNAME/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA'
18+
id: Push
19+
20+
- name: 'gcr.io/cloud-builders/gcloud'
21+
entrypoint: 'bash'
22+
args:
23+
- '-c'
24+
- |
25+
mkdir -p ~/.ssh
26+
gcloud secrets versions access latest --secret=WOM_PROD_SERVER_SSH_KEY > ~/.ssh/gcloud_private_key
27+
chmod 600 ~/.ssh/gcloud_private_key
28+
29+
ssh -i ~/.ssh/gcloud_private_key -o StrictHostKeyChecking=accept-new $_WOM_PROD_SERVER_USER@$_WOM_PROD_SERVER_HOST << 'ENDSSH'
30+
cd $_WOM_PROD_SERVER_WEBSITE_PWD
31+
git checkout main
32+
git pull --ff-only origin main
33+
echo "GCLOUD_WOM_WEB_IMAGE_URL=$_GCR_HOSTNAME/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA" > gcloud.env
34+
make gcloud-deploy
35+
ENDSSH
36+
id: Deploy
37+
38+
images:
39+
- '$_GCR_HOSTNAME/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA'
40+
41+
substitutions:
42+
_GCR_HOSTNAME: eu.gcr.io
43+
_SERVICE_NAME: wom-web
44+
_WOM_PROD_SERVER_USER: user
45+
_WOM_PROD_SERVER_HOST: localhost
46+
_WOM_PROD_SERVER_WEBSITE_PWD: /path/to/wom-web
47+
_GOOGLE_MAPS_API: .
48+
_SEND_IN_BLUE_API: .
49+
_SENTRY_DSN: .
50+
51+
tags:
52+
- wom-web
53+
54+
options:
55+
logging: CLOUD_LOGGING_ONLY

docker-compose.gcloud.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
services:
2+
website:
3+
image: ${GCLOUD_WOM_WEB_IMAGE_URL}

docker-compose.local.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
services:
2+
website:
3+
build: ./src/Website

docker-compose.yml

-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ services:
2121
- "traefik.http.routers.wom-web-insecure.middlewares=wom-web-redirect"
2222
- "traefik.http.middlewares.wom-web-redirect.redirectscheme.scheme=https"
2323
- "traefik.http.middlewares.wom-web-redirect.redirectscheme.permanent=true"
24-
2524
restart: unless-stopped

gcloud.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GCLOUD_WOM_WEB_IMAGE_URL=

0 commit comments

Comments
 (0)