Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit e95af58

Browse files
authored
Merge pull request #31 from vim/feature/deployment-vm
CI: Deploy Docker Images on remote VM
2 parents 20cbf08 + 5b7df30 commit e95af58

17 files changed

+235
-17
lines changed

.env.example

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1+
NODE_ENV=development
2+
13
DATABASE_CLIENT=mysql2
24
DATABASE_USERNAME=vim
35
DATABASE_PASSWORD=super-secret
46
DATABASE_PORT=3306
57
DATABASE_SSL=false
68

79
WEB_DATABASE_NAME=vim
8-
CMS_DATABASE_NAME=vim_cms
10+
NEXT_PRIVATE_STANDALONE=true
11+
NEXTAUTH_SECRET=testsecret
912

13+
CMS_DATABASE_NAME=vim_cms
14+
CMS_HOST=0.0.0.0
1015
CMS_PORT=1337
1116
CMS_APP_KEYS=testkey1,testkey2
1217
CMS_API_TOKEN_SALT=testtoken
1318
CMS_ADMIN_JWT_SECRET=testsecret
1419
CMS_JWT_SECRET=testsecret
1520
CMS_TRANSFER_TOKEN_SALT=testtoken
21+
CMS_DISABLE_UPDATE_NOTIFICATION=false
22+
CMS_TELEMETRY_DISABLED=true

.github/workflows/build-push-cms.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ on:
55
branches:
66
- main
77
- development
8-
paths:
9-
- cms/**
10-
workflow_dispatch:
8+
- 'feature/**'
119

1210
jobs:
1311
push_to_registries:
@@ -19,14 +17,14 @@ jobs:
1917
steps:
2018
- name: Check out the repo
2119
uses: actions/checkout@v4
22-
20+
2321
- name: Log in to the Container registry
2422
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
2523
with:
2624
registry: ghcr.io
2725
username: ${{ github.actor }}
2826
password: ${{ secrets.GITHUB_TOKEN }}
29-
27+
3028
- name: Extract metadata (tags, labels) for Docker
3129
id: meta
3230
uses: docker/metadata-action@f7b4ed12385588c3f9bc252f0a2b520d83b52d48
@@ -37,7 +35,7 @@ jobs:
3735
type=semver,pattern={{version}}
3836
images: |
3937
ghcr.io/${{ github.repository }}/cms
40-
38+
4139
- name: Build and push Docker images
4240
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25
4341
with:
@@ -46,3 +44,4 @@ jobs:
4644
push: true
4745
tags: ${{ steps.meta.outputs.tags }}
4846
labels: ${{ steps.meta.outputs.labels }}
47+
build-args: CMS_URL=${{vars.CMS_URL}}

.github/workflows/build-push-web.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ on:
55
branches:
66
- main
77
- development
8+
- 'feature/**'
89
paths:
910
- web/**
10-
workflow_dispatch:
1111

1212
jobs:
1313
push_to_registries:
@@ -19,14 +19,14 @@ jobs:
1919
steps:
2020
- name: Check out the repo
2121
uses: actions/checkout@v4
22-
22+
2323
- name: Log in to the Container registry
2424
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
2525
with:
2626
registry: ghcr.io
2727
username: ${{ github.actor }}
2828
password: ${{ secrets.GITHUB_TOKEN }}
29-
29+
3030
- name: Extract metadata (tags, labels) for Docker
3131
id: meta
3232
uses: docker/metadata-action@f7b4ed12385588c3f9bc252f0a2b520d83b52d48
@@ -37,7 +37,7 @@ jobs:
3737
type=semver,pattern={{version}}
3838
images: |
3939
ghcr.io/${{ github.repository }}/web
40-
40+
4141
- name: Build and push Docker images
4242
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25
4343
with:

.github/workflows/deploy-vm.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Deploy Docker Images
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- development
8+
workflow_run:
9+
workflows:
10+
- Build and Push Web Docker Image
11+
- Build and Push CMS Docker Image
12+
branches:
13+
- development
14+
types:
15+
- completed
16+
17+
jobs:
18+
deploy:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
26+
- name: setup environment file
27+
run: |
28+
test -f .env || cp .env.example .env
29+
30+
- name: copy files to server
31+
uses: appleboy/[email protected]
32+
with:
33+
host: ${{ secrets.SSH_HOST }}
34+
username: ${{ secrets.SSH_USER }}
35+
key: ${{ secrets.SSH_KEY }}
36+
source: "./docker-compose.dev.yml,./.env"
37+
target: "~/${{ github.event.repository.name }}/"
38+
39+
- name: pull & start container images
40+
uses: appleboy/[email protected]
41+
with:
42+
host: ${{ secrets.SSH_HOST }}
43+
username: ${{ secrets.SSH_USER }}
44+
key: ${{ secrets.SSH_KEY }}
45+
script_stop: true
46+
script: |
47+
cd ~/${{ github.event.repository.name }}/
48+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{github.actor}} --password-stdin
49+
docker compose -f docker-compose.dev.yml pull
50+
docker compose -f docker-compose.dev.yml down
51+
docker compose -f docker-compose.dev.yml up -d --wait --no-build --force-recreate
52+
docker compose -f docker-compose.dev.yml logs -t -n 50

.github/workflows/verify-cms.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
- development
8+
- 'feature/**'
89
paths:
910
- cms/**
1011
pull_request:

.github/workflows/verify-web.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ on:
55
branches:
66
- main
77
- development
8+
- 'feature/**'
89
paths:
910
- web/**
1011
pull_request:
1112
branches:
1213
- main
1314
- development
15+
- 'feature/**'
1416
paths:
1517
- web/**
1618

cms/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
STRAPI_DISABLE_UPDATE_NOTIFICATION=false
2+
STRAPI_TELEMETRY_DISABLED=true
3+
NODE_ENV=development
4+
15
HOST=0.0.0.0
26
PORT=1337
37
APP_KEYS="toBeModified1,toBeModified2"

cms/Dockerfile.prod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev l
33
ARG NODE_ENV=production
44
ENV NODE_ENV=${NODE_ENV}
55

6+
ARG CMS_URL
7+
ENV CMS_URL=${CMS_URL}
8+
RUN echo "CMS_URL=$CMS_URL"
9+
610
WORKDIR /opt/
711
COPY package.json package-lock.json ./
812
RUN npm install -g node-gyp

cms/config/admin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export default ({ env }) => ({
1111
},
1212
},
1313
flags: {
14-
nps: env.bool("FLAG_NPS", true),
14+
nps: env.bool("FLAG_NPS", false),
15+
promoteEE: env.bool("FLAG_EE", false),
1516
},
1617
watchIgnoreFiles: ["**/config/sync/**"],
1718
});

cms/config/middlewares.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = [
44
{
55
name: "strapi::cors",
66
config: {
7-
origin: ["http://localhost:3000", "http://web:3000", "http://localhost:1337", "http://cms:1337"],
7+
origin: ["http://localhost:3000", "http://web:3000", "http://localhost:1337", "http://cms:1337", "http://preview.vim.org"],
88
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"],
99
headers: ["Content-Type", "Authorization", "Origin", "Accept"],
1010
keepHeaderOnError: true,

0 commit comments

Comments
 (0)