-
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.
🧑💻 Add dev container for vscode & github actions for CI/CD
- Loading branch information
1 parent
31853a2
commit 78e516e
Showing
5 changed files
with
161 additions
and
1 deletion.
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,25 @@ | ||
// devcontainer.json의 메타데이터는 다음 링크를 확인: https://aka.ms/devcontainer.json | ||
{ | ||
// dev container의 컨테이너 이름 설정 | ||
"name": "Spring-Boot Dev Env", | ||
// 사용할 Docker 이미지 또는 Docker-Compose 파일을 지정하기. 자세한 건 다음 링크를 확인: https://containers.dev/guide/dockerfile | ||
"image": "openjdk:11", | ||
|
||
// 간편하게 제공되는 애드온 기능들을 추가하기. 자세한 건 다음 링크를 확인: https://containers.dev/features. | ||
// 단, Github Personal Token이 없으면 동작하지 않는 것으로 확인 | ||
"features": { | ||
"ghcr.io/devcontainers/features/git:1": {} | ||
}, | ||
|
||
// 로컬 환경으로 연결할 포트 명시하기. Docker run의 -p 옵션과 동일 | ||
"forwardPorts": [8080], | ||
|
||
// IDE 별 설정 값을 지정하기. | ||
"customizations": { | ||
// 우리는 VSCode에서의 설정 값을 수정 | ||
"vscode": { | ||
// Extensions에서 원하는 Extension 클릭 후, 톱니바퀴 버튼을 눌러 Extension ID 값 복붙 | ||
"extensions": ["vscjava.vscode-java-pack", "vmware.vscode-boot-dev-pack"] | ||
} | ||
} | ||
} |
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,42 @@ | ||
# Github Action의 이름 설정 | ||
name: Spring Boot Build Test | ||
|
||
# Action의 Trigger 설정 | ||
on: pull_request | ||
|
||
# 직렬 또는 병렬적으로 실행할 작업의 집합 | ||
jobs: | ||
# 작업의 이름 | ||
build: | ||
# 작업 실행 환경 이미지 설정 | ||
runs-on: ubuntu-latest | ||
|
||
# 실행할 명령들을 순서에 맞게 나열 | ||
steps: | ||
# 현재 프로젝트로 작업영역 설정 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# Github Action Market에 등록된 Java 환경 설정 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: "temurin" | ||
java-version: "11" | ||
cache: "gradle" | ||
|
||
# Gradle Dependency 캐싱 | ||
- name: Gradle Caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
# 빌드 명령어 실행 | ||
- run: chmod +x gradlew | ||
- name: Build with Gradle | ||
run: ./gradlew clean build |
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,70 @@ | ||
# Github Action의 이름 설정 | ||
name: Publish Image on Docker Hub | ||
|
||
# Action의 Trigger 설정 | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
# 직렬 또는 병렬적으로 실행할 작업의 집합 | ||
jobs: | ||
# 작업의 이름 | ||
build: | ||
# 작업 실행 환경 이미지 설정 | ||
runs-on: ubuntu-latest | ||
|
||
# 실행할 명령들을 순서에 맞게 나열 | ||
steps: | ||
# 현재 프로젝트로 작업영역 설정 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# Github Action Market에 등록된 Java 환경 설정 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: "temurin" | ||
java-version: "11" | ||
cache: "gradle" | ||
|
||
# Gradle Dependency 캐싱 | ||
- name: Gradle Caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
# 빌드 명령어 실행 | ||
- run: chmod +x gradlew | ||
- name: Build with Gradle | ||
run: ./gradlew clean build | ||
|
||
- name: Set env | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
username: tprogramer | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
# platforms: linux/amd64 | ||
tags: | | ||
tprogramer/my-container-test:latest | ||
tprogramer/my-container-test:${{ env.RELEASE_VERSION }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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,9 @@ | ||
FROM openjdk:11 | ||
|
||
WORKDIR /workspace | ||
|
||
COPY build/libs/*.jar service.jar | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["java", "-jar", "service.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
# Template-BE | ||
시계토끼 서비스의 서버들을 위한 Template Repo 입니다. | ||
|
||
시계토끼 서비스의 Spring Boot 서버들을 위한 Template Repo 입니다.<br/> | ||
|
||
--- | ||
|
||
## Feature | ||
|
||
**Development in Container** | ||
|
||
- 컨테이너 상의 VSCode를 사용하는 개발 환경 구축을 위한 `Dev Container` 적용<br/> | ||
|
||
**Github Actions** | ||
|
||
- 브랜치에 PR 시 캐싱을 적용한 빌드 테스트 실행 | ||
- 태그를 `push` 하면 Container Registry(Docker Hub)로 Docker 이미지 build 후 push |