Skip to content

Commit

Permalink
[feat] 운영 서버 배포 준비 (#111)
Browse files Browse the repository at this point in the history
* [feat] #110 create Dockerfile-prod

* [feat] #110 create prod-ci and prod-cd

* [feat] #110 add discord webhook prod version

* [feat] #110 update server_yml
  • Loading branch information
chaewonni authored Aug 26, 2024
1 parent ccbd657 commit 0f94720
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 1 deletion.
62 changes: 62 additions & 0 deletions .github/workflows/prod-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: prod-CD
on:
push:
branches: [ "main" ]

jobs:
ci:
runs-on: ubuntu-22.04
env:
working-directory: .


steps:
- name: checkout
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.SUBMODULE_TOKEN }}

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'

- name: build
run: |
chmod +x gradlew
./gradlew build -x test
shell: bash

- name: docker login
uses: docker/[email protected]

- name: login docker hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_LOGIN_USERNAME }}
password: ${{ secrets.DOCKER_LOGIN_ACCESSTOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile-prod
push: true
tags: ${{ secrets.DOCKER_LOGIN_USERNAME }}/${{ secrets.PROD_REPONAME }}

cd:
needs: ci
runs-on: ubuntu-22.04

steps:
- name: docker container run
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PROD_SERVER_IP }}
username: ${{ secrets.PROD_SERVER_USER }}
key: ${{ secrets.PROD_SERVER_KEY }}
script: |
cd ~
./deploy.sh
28 changes: 28 additions & 0 deletions .github/workflows/prod-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: prod-CI

on:
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-22.04

steps:
- name: checkout
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.SUBMODULE_TOKEN }}

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'

- name: build
run: |
chmod +x gradlew
./gradlew build -x test
shell: bash
4 changes: 4 additions & 0 deletions Dockerfile-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM amd64/amazoncorretto:17
WORKDIR /app
COPY ./build/libs/server-0.0.1-SNAPSHOT.jar /app/KKUM-SERVER.jar
CMD ["java", "-Duser.timezone=Asia/Seoul", "-jar", "-Dspring.profiles.active=prod", "KKUM-SERVER.jar"]
2 changes: 1 addition & 1 deletion SERVER_YML
8 changes: 8 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@
<appender-ref ref="ASYNC_DISCORD" />
</root>
</springProfile>
<springProfile name="prod">
<include resource="console-appender.xml"/>
<include resource="discord-appender.xml"/>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ASYNC_DISCORD" />
</root>
</springProfile>
</configuration>

0 comments on commit 0f94720

Please sign in to comment.