-
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 pull request #5 from softeerbootcamp4th/feature/4-infra-cicd
[infra] VPC, Subnet 설정 및 Github Actions 기반 CI/CD 파이프라인 구축 (#4)
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# CI/CD workflow | ||
name: CI/CD | ||
|
||
on: | ||
push: | ||
branches: [ "dev" ] | ||
pull_request: | ||
branches: [ "dev" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
CI: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0 | ||
|
||
# TODO: 추후 테스트코드 작성 후 테스트 실패 시 CI 불가능하도록 수정 | ||
- name: Build with Gradle | ||
run: ./gradlew build -x test | ||
|
||
- name: Docker Login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build Docker Image | ||
run: docker build --platform linux/amd64 -t ${{ secrets.DOCKERHUB_USERNAME }}/orange . | ||
|
||
- name: Push Docker Image | ||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/orange | ||
|
||
CD: | ||
if: github.event.pull_request.merged == true && github.ref == 'refs/heads/dev' | ||
runs-on: self-hosted | ||
needs: CI | ||
|
||
steps: | ||
- name: Remove Docker Container | ||
run: sudo docker rm -f orange || true | ||
|
||
- name: Run Updated Docker Container | ||
run: sudo docker run -t --env-file ./.env -d --name orange -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/orange |
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 |
---|---|---|
|
@@ -37,5 +37,7 @@ out/ | |
.vscode/ | ||
|
||
### project | ||
*.sh | ||
*.yml | ||
*.yaml | ||
*.properties |
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 @@ | ||
# Use OpenJDK 17 as the base image | ||
FROM openjdk:17 | ||
|
||
# Specify the build argument for the JAR file | ||
ARG JAR_FILE=build/libs/*.jar | ||
|
||
# Copy the JAR file into the container | ||
COPY ${JAR_FILE} app.jar | ||
|
||
# Set the entry point to run the JAR file | ||
ENTRYPOINT ["java", "-jar", "/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