From 8831150ac97eaef684130f0612654995e6c2afcf Mon Sep 17 00:00:00 2001
From: Brian Ward
Date: Wed, 18 Dec 2024 14:53:47 +0000
Subject: [PATCH] Automate docker build/deploy to ghcr.io
---
.github/workflows/docker_deploy.yml | 39 +++++++++++++++++++
.github/workflows/vercel_deploy.yml | 38 ++++++++----------
backend/build_and_push.sh | 9 -----
docs/compilation_server_setup.md | 2 +-
.../Control/CompilationServerDialog.tsx | 3 +-
5 files changed, 58 insertions(+), 33 deletions(-)
create mode 100644 .github/workflows/docker_deploy.yml
delete mode 100644 backend/build_and_push.sh
diff --git a/.github/workflows/docker_deploy.yml b/.github/workflows/docker_deploy.yml
new file mode 100644
index 00000000..a61a8670
--- /dev/null
+++ b/.github/workflows/docker_deploy.yml
@@ -0,0 +1,39 @@
+name: Docker image deploy
+
+on:
+ push:
+ branches:
+ - main
+ paths:
+ - "backend/**"
+ workflow_dispatch:
+ inputs:
+ tag:
+ description: 'Docker image tag'
+ required: true
+ default: 'latest'
+
+jobs:
+ vercel-deploy:
+ name: Vercel deploy
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Set up Docker Builder
+ uses: docker/setup-buildx-action@v3
+
+ - name: Log in to GitHub Container Registry
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Build and push
+ run: |
+ cd backend/
+ INPUT_TAG=${{ github.event.inputs.tag }}
+ TAG=${INPUT_TAG:-"latest"}
+ docker build -t ghcr.io/flatironinstitute/stan-wasm-server:$TAG .
+ docker push ghcr.io/flatironinstitute/stan-wasm-server:$TAG
diff --git a/.github/workflows/vercel_deploy.yml b/.github/workflows/vercel_deploy.yml
index 8018cfd1..8d43dc9a 100644
--- a/.github/workflows/vercel_deploy.yml
+++ b/.github/workflows/vercel_deploy.yml
@@ -4,7 +4,6 @@ on:
push:
branches:
- main
- - vercel-deploy-2 # for initial test
# manual trigger
workflow_dispatch:
@@ -13,24 +12,19 @@ jobs:
name: Vercel deploy
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- -
- name: Install Vercel CLI
- run: npm install --global vercel@latest
- -
- name: Create .vercel/project.json
- run: |
- cd gui
- mkdir -p .vercel
- echo '{"projectId":"${{ secrets.VERCEL_PROJECT_ID }}", "orgId":"${{ secrets.VERCEL_ORG_ID }}"}' > .vercel/project.json
- -
- name: Pull Vercel Environment Information
- run: |
- cd gui
- vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- -
- name: Build Project Artifacts
- run: |
- cd gui
- vercel --prod --token=${{ secrets.VERCEL_TOKEN }}
-
+ - uses: actions/checkout@v4
+ - name: Install Vercel CLI
+ run: npm install --global vercel@latest
+ - name: Create .vercel/project.json
+ run: |
+ cd gui
+ mkdir -p .vercel
+ echo '{"projectId":"${{ secrets.VERCEL_PROJECT_ID }}", "orgId":"${{ secrets.VERCEL_ORG_ID }}"}' > .vercel/project.json
+ - name: Pull Vercel Environment Information
+ run: |
+ cd gui
+ vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
+ - name: Build Project Artifacts
+ run: |
+ cd gui
+ vercel --prod --token=${{ secrets.VERCEL_TOKEN }}
diff --git a/backend/build_and_push.sh b/backend/build_and_push.sh
deleted file mode 100644
index 9d2e87e7..00000000
--- a/backend/build_and_push.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-IMAGE_NAME=magland/stan-wasm-server
-
-docker build -t $IMAGE_NAME .
-
-# prompt user to continue
-echo "Press any key to continue to push to docker hub..."
-read -n 1 -s
-
-docker push $IMAGE_NAME
diff --git a/docs/compilation_server_setup.md b/docs/compilation_server_setup.md
index 139e1435..9b814201 100644
--- a/docs/compilation_server_setup.md
+++ b/docs/compilation_server_setup.md
@@ -5,7 +5,7 @@ These instructions are only required if you want to set up your own compilation
To run your own server locally using Docker, execute the following command:
```
-docker run -p 8083:8080 -it magland/stan-wasm-server:latest
+docker run -p 8083:8080 -it ghcr.io/flatironinstitute/stan-wasm-server:latest
```
After setting up the server, navigate to https://stan-playground.flatironinstitute.org.
diff --git a/gui/src/app/Compilation/Control/CompilationServerDialog.tsx b/gui/src/app/Compilation/Control/CompilationServerDialog.tsx
index a955f1bb..9ebfe1a2 100644
--- a/gui/src/app/Compilation/Control/CompilationServerDialog.tsx
+++ b/gui/src/app/Compilation/Control/CompilationServerDialog.tsx
@@ -113,7 +113,8 @@ const ConfigureCompilationServerDialog: FunctionComponent<
- docker run -p 8083:8080 -it magland/stan-wasm-server:latest
+ docker run -p 8083:8080 -it
+ ghcr.io/flatironinstitute/stan-wasm-server:latest