-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/Repick-official/repick-s…
…erver-v2 into develop
- Loading branch information
Showing
25 changed files
with
418 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ assignees: '' | |
|
||
--- | ||
|
||
# [Fix] <!--{ 작업 내용 }--> | ||
# [Fix] <!--{ 작업 내용 }--> | ||
|
||
### 📝 Description | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Push to ECR | ||
|
||
on: | ||
push: | ||
branches: [ "develop" ] | ||
|
||
env: | ||
AWS_REGION: ap-northeast-2 | ||
ECR_REGISTRY: 654654448479.dkr.ecr.ap-northeast-2.amazonaws.com | ||
ECR_REPOSITORY: repick-repo | ||
ZIP_FILE_NAME: deploy-package.zip | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: CI | ||
runs-on: ubuntu-latest | ||
environment: production | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Make application-secret.yml and set secrets | ||
run: | | ||
mkdir -p ./src/main/resources | ||
mkdir -p ./src/main/resources/key | ||
if [ -f ./src/main/resources/application.yml ]; then | ||
rm ./src/main/resources/application.yml | ||
fi | ||
touch ./src/main/resources/application.yml | ||
touch ./src/main/resources/${{ secrets.APPLE_AUTH_KEY_ID }}.p8 | ||
echo "${{ secrets.APPLICATION_SECRET }}" > ./src/main/resources/application.yml | ||
echo "${{ secrets.APPLE_AUTH_KEY }}" > ./src/main/resources/key/${{ secrets.APPLE_AUTH_KEY_ID }}.p8 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
## gradle build | ||
- name: Build with Gradle | ||
run: ./gradlew bootJar | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
with: | ||
mask-password: true | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
run: | | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY | ||
- name: Zip deployment files | ||
run: | | ||
zip -r ${{ env.ZIP_FILE_NAME }} ./aws/ | ||
- name: Upload AppSpec and scripts to S3 | ||
run: | | ||
aws s3 cp ${{ env.ZIP_FILE_NAME }} s3://${{ secrets.S3_BUCKET }}/${{ env.ZIP_FILE_NAME }} | ||
- name: Trigger CodeDeploy | ||
run: | | ||
aws deploy create-deployment \ | ||
--application-name repick-codedeploy-app \ | ||
--deployment-group-name repick-codedeploy-deployment-group \ | ||
--s3-location bucket=${{ secrets.S3_BUCKET }},bundleType=zip,key=${{ env.ZIP_FILE_NAME }} \ | ||
--file-exists-behavior OVERWRITE \ | ||
--ignore-application-stop-failures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: 0.0 | ||
os: linux | ||
files: | ||
- source: / | ||
destination: /home/ec2-user | ||
overwrite: yes | ||
permissions: | ||
- object: /home/ec2-user | ||
pattern: "**" | ||
owner: ec2-user | ||
group: ec2-user | ||
hooks: | ||
ApplicationStop: | ||
- location: kill_process.sh | ||
timeout: 100 | ||
runas: ec2-user | ||
ApplicationStart: | ||
- location: start_process.sh | ||
timeout: 3600 | ||
runas: ec2-user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: 0.2 | ||
|
||
env: | ||
variables: | ||
AWS_REGION: "ap-northeast-2" | ||
ECR_REPOSITORY: "repick-repo:latest" | ||
|
||
parameter-store: | ||
ECR_REGISTRY: "ECR_REGISTRY" | ||
APPLICATION_SECRET: "application-secrets" | ||
|
||
phases: | ||
install: | ||
runtime-versions: | ||
java: corretto17 | ||
pre_build: | ||
commands: | ||
- echo "Setting up resources and secrets" | ||
- mkdir -p ./src/main/resources | ||
- mkdir -p ./src/main/resources/key | ||
- rm -f ./src/main/resources/application.yml | ||
- touch ./src/main/resources/application.yml | ||
build: | ||
commands: | ||
- echo "Building application with Gradle" | ||
- ./gradlew bootJar | ||
- echo "Building Docker image" | ||
- docker build -t $ECR_REGISTRY/$ECR_REPOSITORY . | ||
|
||
post_build: | ||
commands: | ||
- echo "Logging into Amazon ECR" | ||
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY | ||
- echo "Pushing Docker image to Amazon ECR" | ||
- docker push $ECR_REGISTRY/$ECR_REPOSITORY | ||
artifacts: | ||
files: | ||
- appspec.yml | ||
- kill_process.sh | ||
- start_process.sh | ||
discard-paths: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# 실행 중이거나 중지된 컨테이너 목록을 가져옴 | ||
containers=$(docker ps -qa) | ||
|
||
# 컨테이너가 존재하면 삭제 | ||
if [ -n "$containers" ]; then | ||
sudo docker rm -f $containers | ||
else | ||
echo "No containers to remove." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
ECR_REGISTRY=$(aws ssm get-parameter --name "ECR_REGISTRY" --with-decryption --region ap-northeast-2 --query "Parameter.Value" --output text) | ||
ECR_DOCKER_TAG=latest | ||
|
||
echo $ECR_REGISTRY | ||
aws ecr get-login-password --region ap-northeast-2 | sudo docker login --username AWS --password-stdin $ECR_REGISTRY | ||
|
||
sudo docker pull $ECR_REGISTRY:$ECR_DOCKER_TAG | ||
|
||
sudo docker run -d --name dc -p 8080:8080 $ECR_REGISTRY:$ECR_DOCKER_TAG | ||
|
||
sudo docker image prune -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
FROM openjdk:17 | ||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
ENTRYPOINT ["java","-jar","-Duser.timezone=Asia/Seoul","/app.jar"] | ||
ENTRYPOINT ["java","-jar","-Duser.timezone=Asia/Seoul","/app.jar"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.