-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 2.26 KB
/
docker-build.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
name: docker-build
on:
push:
branches: ['develop']
env:
DOCKER_IMAGE: ghcr.io/devheun/ku-key
DOCKER_CONTAINER: ku-key
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
- name: Set up Docker
id: buildx
uses: docker/setup-buildx-action@v2
- name: docker login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: build and push image
id: docker_build
uses: docker/build-push-action@v3
with:
platforms: linux/amd64
push: true
tags: ${{ env.DOCKER_IMAGE }}:latest
deploy:
needs: build
runs-on: self-hosted
steps:
- name: setup .env.prod
run: |
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env.prod
echo "DB_PORT=${{ secrets.DB_PORT }}" >> .env.prod
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env.prod
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> .env.prod
echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" >> .env.prod
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env.prod
echo "EMAIL_USER=${{ secrets.EMAIL_USER }}" >> .env.prod
echo "EMAIL_PASS=${{ secrets.EMAIL_PASS }}" >> .env.prod
echo "ADMIN_ID=${{ secrets.ADMIN_ID }}" >> .env.prod
echo "ADMIN_PASSWORD=${{ secrets.ADMIN_PASSWORD }}" >> .env.prod
echo "AWS_ACCESS_KEY=${{ secrets.AWS_ACCESS_KEY }}" >> .env.prod
echo "AWS_SECRET_KEY=${{ secrets.AWS_SECRET_KEY }}" >> .env.prod
echo "AWS_BUCKET_REGION=${{ secrets.AWS_BUCKET_REGION }}" >> .env.prod
echo "AWS_BUCKET_NAME=${{ secrets.AWS_BUCKET_NAME }}" >> .env.prod
echo "DEEPL_API_KEY=${{ secrets.DEEPL_API_KEY }}" >> .env.prod
cat .env.prod
- name: Run Docker
run: |
sudo docker stop ${{ env.DOCKER_CONTAINER }} && sudo docker rm ${{ env.DOCKER_CONTAINER }} && sudo docker rmi ${{ env.DOCKER_IMAGE }}:latest
sudo docker run --env-file ./.env.prod --platform linux/amd64 -d --name ${{ env.DOCKER_CONTAINER }} --network bridge -p 3000:3000 --restart always ${{ env.DOCKER_IMAGE }}:latest