Skip to content

Commit de4ce35

Browse files
committed
feat: Github Action 자동 도커 이미지 빌드 추가
1 parent e468a14 commit de4ce35

File tree

4 files changed

+65
-7
lines changed

4 files changed

+65
-7
lines changed

.github/workflows/bump-version.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: release
2+
on:
3+
pull_request:
4+
types:
5+
- labeled
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: haya14busa/action-bumpr@v1

.github/workflows/release.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,49 @@ on:
33
push:
44
branches:
55
- main
6-
pull_request:
7-
types:
8-
- labeled
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
910

1011
jobs:
1112
release:
1213
runs-on: ubuntu-latest
1314
steps:
1415
- uses: actions/checkout@v4
1516
- uses: haya14busa/action-bumpr@v1
17+
18+
package:
19+
runs-on: ubuntu-latest
20+
needs: release
21+
22+
permissions:
23+
contents: read
24+
packages: write
25+
attestations: write
26+
id-token: write
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: docker/login-action@v3
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
38+
- uses: docker/metadata-action@v5
39+
id: meta
40+
with:
41+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
tags: |
43+
type=raw,value=latest
44+
type=raw,value=${{ needs.release.outputs.current_version }}
45+
46+
- uses: docker/build-push-action@v6
47+
with:
48+
context: ./backend
49+
push: true
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}

backend/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM gradle:jdk21 AS builder
2+
WORKDIR /app
3+
COPY . .
4+
RUN ./gradlew clean build -x test
5+
6+
FROM openjdk:21-slim
7+
WORKDIR /app
8+
COPY --from=builder /app/build/libs/*.jar app.jar
9+
ENTRYPOINT ["java", "-jar", "app.jar"]

backend/src/main/resources/application.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ spring:
1212
username: ${DB_USERNAME}
1313
password: ${DB_PASSWORD}
1414

15-
data:
16-
redis:
17-
host: ${REDIS_HOST}
18-
port: ${REDIS_PORT}
15+
# Redis 도입 시 정의
16+
# data:
17+
# redis:
18+
# host: ${REDIS_HOST}
19+
# port: ${REDIS_PORT}
1920

2021
jpa:
2122
defer-datasource-initialization: true # 현재는 data.sql 에서 더미 유저 자동 추가를 위해 넣어뒀음.

0 commit comments

Comments
 (0)