aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2023-09-27 14:33:20 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2023-09-27 14:33:20 +0300
commitfe57e4996ec79267dffd77e503ef8164eceea229 (patch)
tree06a1298a5dc3c1e835ecadc2ee2dd3af4ae3b07c
parent7991ad93470cf42b9c4c96477fc920bbb8899eee (diff)
Remove GCP references, use self-hosted registry
-rw-r--r--.github/workflows/hommabot2.yml88
-rwxr-xr-xbuild-and-push.sh7
-rw-r--r--docker-compose.yml2
3 files changed, 8 insertions, 89 deletions
diff --git a/.github/workflows/hommabot2.yml b/.github/workflows/hommabot2.yml
deleted file mode 100644
index dd01614..0000000
--- a/.github/workflows/hommabot2.yml
+++ /dev/null
@@ -1,88 +0,0 @@
-name: Deploy Hommabot2 to GCP
-on:
- push:
- branches:
- - main
-
-env:
- IMAGE: eu.gcr.io/jan-systems/hommabot2
- GCP_PROJECT: jan-systems
- GCR_SERVICE: hommabot
- GCR_PORT: 8080 # Not used in service, but GCR requires a port
- GCR_PLATFORM: managed
- GCR_REGION: europe-north1
- CLOUDSQL_INSTANCES: jan-systems:europe-north1:pg1
- VPC_CONNECTOR: connector1
- # Env vars (normally) comma separated. Use @ as separator since TELEGRAM_USER_IDS has commas.
- GCR_ENV_VARS: "^&^SHEETS_SPREADSHEET_ID=1eKEcFRQBdM2b-pPxnSUEilAKdHnMUNXZljO_I6iqwBw\
- &SHEETS_RANGE=Aikataulu!A4:C999\
- &TELEGRAM_BOT_TOKEN=1617681735:AAFr1314RVQt7giW82yh0DYQKqGl4m_B8gM\
- &TELEGRAM_WEBHOOK_URL=https://hommabot.jan.systems/webhook/telegram\
- &PG_CONNECTION_URI=postgresql://hommabot_user:${{ secrets.DATABASE_PASSWORD }}@10.24.240.3/hommabot\
- &G_SA_JSON_B64=${{ secrets.G_SA_JSON_B64 }}"
-
-jobs:
- website:
- name: Build, Push, and Deploy Hommabot
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- # Build image tag from the commit SHA
- - name: Define image tag
- run: echo "TAG=$(date +'%Y.%m.%d')_${GITHUB_SHA:0:6}" >> $GITHUB_ENV
-
- - name: Define full image identifier
- run: echo "IMAGE_AND_TAG=${IMAGE}:${TAG}" >> $GITHUB_ENV
-
- # Define revision suffix
- - name: Define revision suffix
- run: echo "GCR_REVISION_SUFFIX=$(echo ${TAG} | sed 's/\./-/g' | sed 's/_/-/g')" >> $GITHUB_ENV
-
- # Setup gcloud CLI
- - name: Set up gcloud CLI
- uses: google-github-actions/setup-gcloud@v0.2.0
- with:
- service_account_key: ${{ secrets.GCP_SA_KEY }}
- project_id: ${{ env.GCP_PROJECT }}
- export_default_credentials: true
-
- # Configure Docker to use the gcloud command-line tool as a credential
- # helper for authentication
- - name: Configure Docker authentication
- run: gcloud --quiet auth configure-docker
-
- # In this step, this action saves a list of existing images,
- # the cache is created without them in the post run.
- # It also restores the cache if it exists.
- - name: Restore Docker cache
- uses: satackey/action-docker-layer-caching@v0.0.11
- # Ignore the failure of a step and avoid terminating the job.
- continue-on-error: true
- with:
- key: hommabot-docker-cache-{hash}
- restore-keys: |
- hommabot-docker-cache-
-
- # Build the Docker image
- - name: Build image
- run: docker build -t ${IMAGE_AND_TAG} .
-
- # Push the Docker image to Google Container Registry
- - name: Push image to registry
- run: docker push ${IMAGE_AND_TAG}
-
- # Deploy to Google Cloud Run
- - name: Deploy to Cloud Run
- run: |-
- gcloud run deploy ${GCR_SERVICE} \
- --region=${GCR_REGION} \
- --platform=${GCR_PLATFORM} \
- --port=${GCR_PORT} \
- --revision-suffix=${GCR_REVISION_SUFFIX} \
- --set-env-vars=${GCR_ENV_VARS} \
- --image=${IMAGE_AND_TAG} \
- --set-cloudsql-instances=${CLOUDSQL_INSTANCES} \
- --vpc-connector=${VPC_CONNECTOR}
diff --git a/build-and-push.sh b/build-and-push.sh
new file mode 100755
index 0000000..dbecd87
--- /dev/null
+++ b/build-and-push.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+IMAGE=registry.jan.systems/hommabot2:latest
+
+set -euxo pipefail
+docker build --platform linux/amd64 -t $IMAGE .
+docker push $IMAGE
diff --git a/docker-compose.yml b/docker-compose.yml
index d82dd22..b8306fa 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -12,7 +12,7 @@ services:
- ./sql:/sql
hommabot2:
build: .
- image: registry.digitalocean.com/jan-systems-registry/hommabot2:latest
+ image: registry.jan.systems/hommabot2:latest
env_file: .env
environment:
PORT: 3000