Skip to content

Commit

Permalink
feat: add Object Storage configuration based on JuiceFS
Browse files Browse the repository at this point in the history
feat: add GitHub actions configuration of Docker Compose deployment
  • Loading branch information
TechQuery committed Oct 5, 2023
1 parent d65d866 commit 8fc5dd8
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/deploy-oss.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# reference:
# 1. https://github.com/docker/build-push-action/blob/master/docs/advanced/push-multi-registries.md
# 2. https://github.com/docker/build-push-action/blob/master/docs/advanced/share-image-jobs.md

name: Deploy to Production environment
on:
push:
tags:
- v*
env:
ARTIFACT_PATH: /tmp/artifact.tar
BOX_NAME: api-service
BOX_URL: polyfiller/api-service

jobs:
deploy_docker_image:
name: Deploy Docker image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3

- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2

- name: Build Image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
tags: ${{ env.BOX_URL }}:latest
outputs: type=docker,dest=${{ env.ARTIFACT_PATH }}

- name: Pick Docker Compose
run: |
cat > .env <<EOF
${{ secrets.ENV_FILE }}
EOF
mkdir build
mv ${{ env.ARTIFACT_PATH }} docker-compose.yml .env start-docker.sh build/
- name: Transport Image
uses: garygrossgarten/github-action-scp@release
with:
local: ./build
remote: /tmp
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
privateKey: ${{ secrets.SSH_KEY }}

- name: Run Image
uses: garygrossgarten/github-action-ssh@release
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
privateKey: ${{ secrets.SSH_KEY }}
command: |
cd /tmp
mv docker-compose.yml .env start-docker.sh ~/
chmod +x ~/start-docker.sh
sudo ~/start-docker.sh ${{ env.ARTIFACT_PATH }}
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
version: '3'

volumes:
polyfill-cache:
driver: juicedata/juicefs
driver_opts:
name: polyfill-cache
metaurl: sqlite3://polyfill-cache.db
storage: ${STORAGE_TYPE}
bucket: ${BUCKET}
access-key: ${ACCESS_KEY}
secret-key: ${SECRET_KEY}

networks:
polyfiller:

Expand All @@ -10,6 +21,8 @@ services:
- NODE_ENV=production
ports:
- 3000:3000
volumes:
- polyfill-cache:/tmp/@wessberg/polyfiller
networks:
- polyfiller
restart: always
Expand Down
9 changes: 9 additions & 0 deletions start-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! /usr/bin/env bash

docker load < $1
docker image ls -a

docker compose down
docker compose up -d

docker image prune -a -f

0 comments on commit 8fc5dd8

Please sign in to comment.