Skip to content

Commit

Permalink
[FEAT] nginx & docker-compose 무중단 배포 (#184)
Browse files Browse the repository at this point in the history
* 무중단배포 테스트

* 무중단 배포 테스트

* feat: main.yml 수정

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* feat: docker build and push script 작성

* git actions & docker TEST

* git actions & docker TEST

* git actions & docker TEST

* self-hosted runners & docker compose test

* self-hosted runners & docker compose test

* self-hosted runners & docker compose test

* self-hosted runners & docker compose test

* docker compose & nginx test

* 최종 테스트

* 최종 테스트

* 최종 테스트

* 최종 테스트

* 최종 테스트

* 테스트

* feat: 무중단 배포 적용 완료

* feat: 무중단 배포 적용 완료

* feat: 무중단 배포 적용 완료
  • Loading branch information
kimdozzi authored May 28, 2024
1 parent f167233 commit 9c99f5d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 62 deletions.
49 changes: 17 additions & 32 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
name: Build and Deploy to EC2

on:
push:
branches: [ "production" ]
pull_request:
branches: [ "production" ]

env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: gitget-bucket-hey
AWS_CODE_DEPLOY_APPLICATION: GitGet-Application-HEY
AWS_CODE_DEPLOY_GROUP: GitGet-CICD-group-hey

jobs:
deploy:
build-docker-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -49,32 +38,28 @@ jobs:
echo "${{ secrets.APPLICATION_TEST }}" > ./application.yml
echo "${{ secrets.TEST }}" > ./application-test.yml
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash

- name: Build with Gradle
run: ./gradlew clean build

- name: Build with Gradle # and Test
run: ./gradlew clean build -x test #./gradlew build test


- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip .
shell: bash


- name: Deliver to AWS S3 (AWS credential 설정)
uses: aws-actions/configure-aws-credentials@v1
- name: docker login
uses: docker /login-action@v2
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY_HEY }}
aws-secret-access-key: ${{ secrets.CICD_SECRET_KEY_HEY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: docker image build
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/gitget-application .

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$AWS_S3_BUCKET/$GITHUB_SHA.zip
- name: dockerhub push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/gitget-application


- name: Code Deploy (EC2에 배포)
run: aws deploy create-deployment --application-name GitGet-Application-HEY --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name GitGet-CICD-group-hey --s3-location bucket=$AWS_S3_BUCKET,key=$GITHUB_SHA.zip,bundleType=zip
run-docker-image-on-ec2:
needs: build-docker-image
runs-on: self-hosted
steps:
- name: execute deploy.sh
run: sh /home/ec2-user/deploy.sh
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Start with a base image containing Java runtime.
FROM openjdk:17-jdk

# The application's jar file.
ARG JAR_FILE=./build/libs/GitGetApplication.jar

# Add the application's jar to the container.
COPY ${JAR_FILE} App.jar

# Run the jar file.
CMD ["java", "-jar", "App.jar"]
28 changes: 0 additions & 28 deletions appspec.yml

This file was deleted.

1 change: 0 additions & 1 deletion scripts/health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ else
exit 1
fi


echo "> Start health check of WAS at http://localhost:${TARGET_PORT}/api/auth/health-check ..."

for RETRY_COUNT in 1 2 3 4 5 6 7 8 9 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
@RequiredArgsConstructor
@EnableWebSecurity
public class SecurityConfig {
public static final String PERMITTED_URI[] = {"/v3/**", "/swagger-ui/**", "/api/auth/**", "/login", "/favicon.ico"};
public static final String PERMITTED_URI[] = {"/v3/**", "/swagger-ui/**", "/api/auth/**", "/login",
"/favicon.ico"};
private static final String PERMITTED_ROLES[] = {"USER", "ADMIN"};
private final CustomCorsConfigurationSource customCorsConfigurationSource;
private final CustomOAuth2UserService customOAuthService;
Expand Down

0 comments on commit 9c99f5d

Please sign in to comment.