Skip to content

Commit d4a0079

Browse files
authored
✨ feat: Github Action 자동 도커 이미지 빌드 추가 (#30)
1 parent e468a14 commit d4a0079

File tree

4 files changed

+68
-7
lines changed

4 files changed

+68
-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: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,52 @@ 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
14+
outputs:
15+
next_version: ${{ steps.bump.outputs.next_version }}
1316
steps:
1417
- uses: actions/checkout@v4
1518
- uses: haya14busa/action-bumpr@v1
19+
id: bump
20+
21+
package:
22+
runs-on: ubuntu-latest
23+
needs: release
24+
25+
permissions:
26+
contents: read
27+
packages: write
28+
attestations: write
29+
id-token: write
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
41+
- uses: docker/metadata-action@v5
42+
id: meta
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
tags: |
46+
type=raw,value=latest
47+
type=raw,value=${{ needs.release.outputs.next_version }}
48+
49+
- uses: docker/build-push-action@v6
50+
with:
51+
context: ./backend
52+
push: true
53+
tags: ${{ steps.meta.outputs.tags }}
54+
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)