Skip to content

Commit 87a1f99

Browse files
Merge pull request #4 from dlsrks1021/main
chore: Docker Image 자동 빌드를 위한 Github Action과 Dockerfile 추가
2 parents aace72c + d379755 commit 87a1f99

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
9+
10+
jobs:
11+
tagging:
12+
name: 태깅 및 릴리즈
13+
runs-on: ubuntu-latest
14+
outputs:
15+
tag_name: ${{ steps.tag_version.outputs.new_tag }}
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: versioning and tagging
21+
id: tag_version
22+
uses: mathieudutour/[email protected]
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: releasing
27+
uses: ncipollo/release-action@v1
28+
with:
29+
tag: ${{ steps.tag_version.outputs.new_tag }}
30+
name: ${{ steps.tag_version.outputs.new_tag }}
31+
body: ${{ steps.tag_version.outputs.changelog }}
32+
33+
build-image:
34+
name: 도커 이미지 빌드
35+
runs-on: ubuntu-latest
36+
needs: tagging
37+
38+
permissions:
39+
contents: read
40+
packages: write
41+
attestations: write
42+
id-token: write
43+
44+
steps:
45+
- name: Check out Repository
46+
uses: actions/checkout@v4
47+
48+
- name: Sign in github container registry
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ${{ env.REGISTRY }}
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Extract metadata
56+
id: meta
57+
uses: docker/metadata-action@v5
58+
with:
59+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60+
tags: |
61+
type=sha
62+
type=raw,value=${{ needs.tagging.outputs.tag_name }}
63+
type=raw,value=latest
64+
65+
- name: Build and Push Image
66+
uses: docker/build-push-action@v6
67+
with:
68+
context: .
69+
push: true
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:19.9.0 AS builder
2+
WORKDIR /app
3+
4+
COPY package*.json ./
5+
RUN npm install
6+
7+
COPY . .
8+
RUN npm run build
9+
10+
FROM node:19.9.0
11+
12+
WORKDIR /app
13+
COPY package*.json ./
14+
RUN npm install --omit=dev
15+
16+
COPY server.js ./
17+
COPY --from=builder /app/build ./build
18+
19+
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)