~hokiegeek/biologist-web

ref: 21fc5e225603de84547184e7d6e82b75b4b71f05 biologist-web/.build.yml -rw-r--r-- 2.0 KiB
21fc5e22HokieGeek Deploying to Google Cloud Run now 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
image: archlinux
packages:
  - nodejs
  - npm
  - chromium
  - harfbuzz
  - nss
  - docker
  - shadow
  - google-cloud-sdk
sources:
  - https://git.sr.ht/~hokiegeek/biologist-web
environment:
  PROJ: biologist-web
  GCP_PROJ: hokiegeek-net
  GCP_RUN_SVC: life
  CI_COMMIT_TAG: $(git --work-tree=./biologist-web --git-dir=./biologist-web/.git describe)
  CI_REGISTRY: gcr.io
  CI_REGISTRY_USER: hokiegeek-net
secrets:
  - 3c7786a3-e027-4018-bc74-42a1492176d5 # gcp key
tasks:
  - docker_setup: |
      sudo mount -t tmpfs -o size=4G /dev/null /dev/shm
      sudo nohup dockerd --bip 172.18.0.1/16 </dev/null >/dev/null 2>&1 &
      sudo gpasswd -a $(whoami) docker
  - gcloud_setup: |
      gcloud auth activate-service-account --key-file=$HOME/.gcp_cloudrunner_key.json
      gcloud config set project ${GCP_PROJ}
      yes | gcloud auth configure-docker
  - install: |
      cd ${PROJ}
      npm install
  - lint: |
      cd ${PROJ}
      npm run lint
  - build: |
      cd ${PROJ}
      npm run build
      version=$(awk 'BEGIN { FS=":"; RS="," } $1 ~ /"version"/ { gsub(/( |")/, "", $0); print $2 }' package.json)
      sed -i '/^<head>$/ a\    <meta name="application-name" content="hokiegeek.net_tea" data-version="'${version}${version_suffix:+":${version_suffix}"}'" />' dist/index.html
  - test: |
      export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
      export CHROME_BIN="/usr/bin/chromium-browser"
      cd ${PROJ}
      npm run test
  - package: |
      cd ${PROJ}
      IMAGE=${CI_REGISTRY}/hokiegeek/${PROJ}
      IMAGE_TAG=${IMAGE}:${CI_COMMIT_TAG}
      IMAGE_LATEST_TAG=${IMAGE}:latest
      docker build -t $IMAGE_TAG -t $IMAGE_LATEST_TAG .
      cat $HOME/.gcp_cloudrunner_key.json | docker login -u _json_key --password-stdin https://${CI_REGISTRY}
      docker push $IMAGE_TAG
      docker push $IMAGE_LATEST_TAG
  - deploy: |
      gcloud beta run deploy ${GCP_RUN_SVC} --image ${CI_REGISTRY}/${CI_REGISTRY_USER}/${PROJ} --platform managed --region us-east1 --allow-unauthenticated --memory 512Mi