Skip to content

Commit

Permalink
[BE] ci-cd 생성 단, aws내부에서cron설정을 하여야함
Browse files Browse the repository at this point in the history
  • Loading branch information
leedonggyu1848 committed Sep 5, 2023
1 parent fe70620 commit 9c067e9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/cron-cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,18 @@ jobs:
chmod +x gradlew
./gradlew jar
shell: bash
- name: Main S3에 업로드
if: ${{ github.ref == 'refs/heads/main' }}
run: |
cp cron/build/libs/cron-*.jar deploy-cron/build
mkdir -p deploy && cp deploy-cron/* deploy/
zip -r deploy.zip deploy
aws s3 cp deploy.zip s3://${{ secrets.AWS_S3_MAIN_BUCKET_NAME }}/deploy.zip
aws deploy create-deployment \
--application-name ${{ secrets.AWS_CODEDEPLOY_MAIN_APP_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ secrets.AWS_CODEDEPLOY_MAIN_GROUP_NAME }} \
--file-exists-behavior OVERWRITE \
--s3-location bucket=${{ secrets.AWS_S3_MAIN_BUCKET_NAME }},bundleType=zip,key=deploy.zip
10 changes: 10 additions & 0 deletions deploy-cron/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM openjdk:17-jdk-slim

WORKDIR /app

RUN apt-get update
RUN apt-get -y install cron

ADD build/cron-1.0-SNAPSHOT.jar cron.jar

CMD tail -f /var/log/cron.log
18 changes: 18 additions & 0 deletions deploy-cron/appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/cron/zip/
overwrite: yes

permissions:
- object: /
pattern: "**"
owner: ec2-user
group: ec2-user

hooks:
ApplicationStart:
- location: deploy.sh
timeout: 60
runas: ec2-user
7 changes: 7 additions & 0 deletions deploy-cron/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

mkdir -p /home/ec2-user/cron/zip
cd /home/ec2-user/cron/zip/

docker compose down --rmi all
docker compose up -d
11 changes: 11 additions & 0 deletions deploy-cron/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.6"

services:
cabi-cron:
build:
context: .
dockerfile: Dockerfile
container_name: "cabi-cron"
image: "cabi/cron"
volumes:
- ./log:/var/log/
2 changes: 2 additions & 0 deletions deploy-cron/kotlin-cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* * 1 * * /usr/bin/java -jar /app/cron.jar get-ft-token &>> /var/log/cron.log

0 comments on commit 9c067e9

Please sign in to comment.