Skip to content

Commit 8fc5dd8

Browse files
committed
feat: add Object Storage configuration based on JuiceFS
feat: add GitHub actions configuration of Docker Compose deployment
1 parent d65d866 commit 8fc5dd8

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

.github/workflows/deploy-oss.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# reference:
2+
# 1. https://github.com/docker/build-push-action/blob/master/docs/advanced/push-multi-registries.md
3+
# 2. https://github.com/docker/build-push-action/blob/master/docs/advanced/share-image-jobs.md
4+
5+
name: Deploy to Production environment
6+
on:
7+
push:
8+
tags:
9+
- v*
10+
env:
11+
ARTIFACT_PATH: /tmp/artifact.tar
12+
BOX_NAME: api-service
13+
BOX_URL: polyfiller/api-service
14+
15+
jobs:
16+
deploy_docker_image:
17+
name: Deploy Docker image
18+
runs-on: ubuntu-latest
19+
permissions:
20+
packages: write
21+
contents: read
22+
steps:
23+
- uses: actions/checkout@v3
24+
25+
- uses: docker/setup-qemu-action@v2
26+
- uses: docker/setup-buildx-action@v2
27+
28+
- name: Build Image
29+
uses: docker/build-push-action@v3
30+
with:
31+
context: .
32+
platforms: linux/amd64
33+
tags: ${{ env.BOX_URL }}:latest
34+
outputs: type=docker,dest=${{ env.ARTIFACT_PATH }}
35+
36+
- name: Pick Docker Compose
37+
run: |
38+
cat > .env <<EOF
39+
${{ secrets.ENV_FILE }}
40+
EOF
41+
mkdir build
42+
mv ${{ env.ARTIFACT_PATH }} docker-compose.yml .env start-docker.sh build/
43+
44+
- name: Transport Image
45+
uses: garygrossgarten/github-action-scp@release
46+
with:
47+
local: ./build
48+
remote: /tmp
49+
host: ${{ secrets.HOST }}
50+
username: ${{ secrets.USER }}
51+
privateKey: ${{ secrets.SSH_KEY }}
52+
53+
- name: Run Image
54+
uses: garygrossgarten/github-action-ssh@release
55+
with:
56+
host: ${{ secrets.HOST }}
57+
username: ${{ secrets.USER }}
58+
privateKey: ${{ secrets.SSH_KEY }}
59+
command: |
60+
cd /tmp
61+
mv docker-compose.yml .env start-docker.sh ~/
62+
chmod +x ~/start-docker.sh
63+
sudo ~/start-docker.sh ${{ env.ARTIFACT_PATH }}

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
version: '3'
22

3+
volumes:
4+
polyfill-cache:
5+
driver: juicedata/juicefs
6+
driver_opts:
7+
name: polyfill-cache
8+
metaurl: sqlite3://polyfill-cache.db
9+
storage: ${STORAGE_TYPE}
10+
bucket: ${BUCKET}
11+
access-key: ${ACCESS_KEY}
12+
secret-key: ${SECRET_KEY}
13+
314
networks:
415
polyfiller:
516

@@ -10,6 +21,8 @@ services:
1021
- NODE_ENV=production
1122
ports:
1223
- 3000:3000
24+
volumes:
25+
- polyfill-cache:/tmp/@wessberg/polyfiller
1326
networks:
1427
- polyfiller
1528
restart: always

start-docker.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /usr/bin/env bash
2+
3+
docker load < $1
4+
docker image ls -a
5+
6+
docker compose down
7+
docker compose up -d
8+
9+
docker image prune -a -f

0 commit comments

Comments
 (0)