-
Notifications
You must be signed in to change notification settings - Fork 6
132 lines (110 loc) · 4.3 KB
/
be-cd_test-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: BE/CD - [TEST] Build & Deploy
on:
workflow_dispatch:
push:
branches: be/main
jobs:
build:
environment: test
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set timezone to Korea
uses: szenius/set-timezone@v2.0
with:
timezoneLinux: "Asia/Seoul"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build with Gradle
run: ./gradlew bootJar
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get current date and time
id: datetime
run: |
echo "datetime=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_OUTPUT"
- name: Image build and push
run: |
docker build --build-arg PROFILE=test -t ${{ secrets.DOCKER_REPO_NAME }}/cruru:test-${{ steps.datetime.outputs.datetime }} --platform linux/arm64 .
docker push ${{ secrets.DOCKER_REPO_NAME }}/cruru:test-${{ steps.datetime.outputs.datetime }}
- name: Upload docker-compose yaml script to artifact
uses: actions/upload-artifact@v4
with:
name: docker-compose
path: |
${{ github.workspace }}/backend/docker-compose.test.yml
${{ github.workspace }}/backend/promtail-config.yml
outputs:
BUILD_VERSION: ${{ steps.datetime.outputs.datetime }}
deploy:
environment: test
runs-on: [self-hosted, be-test]
needs: build
defaults:
run:
working-directory: backend
steps:
- name: Set docker-compose YAML script to runner
uses: actions/download-artifact@v4
with:
name: docker-compose
path: ${{ github.workspace }}/backend
- name: Extract secrets as .env file
run: |
cat <<EOF > .env
# Docker Hub info from Github Secrets
DOCKER_REPO_NAME=${{ secrets.DOCKER_REPO_NAME }}
DOCKER_IMAGE_VERSION_TAG=test-${{ needs.build.outputs.BUILD_VERSION }}
# DB Configuration secrets info from Github Secrets
DB_PORT=${{ secrets.DB_PORT }}
DB_IP_ADDRESS=${{ secrets.DB_IP_ADDRESS }}
DB_URL=${{ secrets.DB_URL }}
DB_USER=${{ secrets.DB_USER }}
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
DDL_AUTO=${{ secrets.DDL_AUTO }}
# DB server configuration secrets info from Github Secrets
APP_IP_ADDRESS=${{ secrets.APP_IP_ADDRESS }}
SERVER_BINDING_PORT=${{ secrets.SERVER_BINDING_PORT }}
SERVER_PORT=${{ secrets.SERVER_PORT }}
SUBNET=${{ secrets.SUBNET }}
# Monitoring configuration server info from Github secrets
MONITORING_INSTANCE_ADDR_LOKI_PORT=${{ secrets.MONITORING_INSTANCE_ADDR_LOKI_PORT }}
MONITORING_BINDING_PORT=${{ secrets.MONITORING_BINDING_PORT }}
MONITORING_PORT=${{ secrets.MONITORING_PORT }}
MONITORING_BASE_PATH=${{ secrets.MONITORING_BASE_PATH }}
# Apply configuration server info from Github secrets
APPLY_POST_BASE_URL=${{ secrets.APPLY_POST_BASE_URL }}
# Email Auth info
EMAIL_USERNAME=${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }}
# Security settings
JWT_TOKEN_SECRET_KEY=${{ secrets.JWT_TOKEN_SECRET_KEY }}
JWT_TOKEN_EXPIRE_CYCLE=${{ secrets.JWT_TOKEN_EXPIRE_CYCLE }}
JWT_SIGN_ALGORITHM=${{ secrets.JWT_SIGN_ALGORITHM }}
# Cookie settings
COOKIE_ACCESS_TOKEN_KEY=${{ secrets.COOKIE_ACCESS_TOKEN_KEY }}
COOKIE_HTTP_ONLY=${{ secrets.COOKIE_HTTP_ONLY }}
COOKIE_SECURE=${{ secrets.COOKIE_SECURE }}
COOKIE_DOMAIN=${{ secrets.COOKIE_DOMAIN }}
COOKIE_PATH=${{ secrets.COOKIE_PATH }}
COOKIE_SAME_SITE=${{ secrets.COOKIE_SAME_SITE }}
COOKIE_MAX_AGE=${{ secrets.COOKIE_MAX_AGE }}
EOF
- name: Stop and remove existing containers
run: |
sudo docker-compose -f docker-compose.test.yml down --rmi all
- name: Deploy docker container
run: |
sudo docker-compose --env-file .env -f docker-compose.test.yml up -d