Skip to content

Commit 00ffcd5

Browse files
committed
chore: 내부서버 배포 파이프라인 구성
1 parent bad18b4 commit 00ffcd5

File tree

6 files changed

+131
-78
lines changed

6 files changed

+131
-78
lines changed

.github/workflows/autoReviewers.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/autoSync-develop.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/autoSync-main.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/deploy-dev.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy to Development
2+
3+
on:
4+
push:
5+
branches:
6+
- chore/#142-cicd-migration
7+
8+
env:
9+
DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/billilge-client
10+
CAPROVER_APP: dev
11+
12+
jobs:
13+
build-and-deploy:
14+
runs-on: ubuntu-latest
15+
environment: development
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Create .env file
22+
run: echo "${{ secrets.DEV_ENV_FILE }}" > .env.production
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Login to Docker Hub
28+
uses: docker/login-action@v3
29+
with:
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_PASSWORD }}
32+
33+
- name: Build and Push
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
push: true
38+
tags: |
39+
${{ env.DOCKER_IMAGE }}:dev
40+
${{ env.DOCKER_IMAGE }}:dev-${{ github.sha }}
41+
cache-from: type=gha,scope=dev
42+
cache-to: type=gha,mode=max,scope=dev
43+
44+
- name: Deploy to CapRover
45+
uses: caprover/[email protected]
46+
with:
47+
server: ${{ secrets.CAPROVER_SERVER }}
48+
app: ${{ env.CAPROVER_APP }}
49+
token: ${{ secrets.CAPROVER_DEV_APP_TOKEN }}
50+
image: ${{ env.DOCKER_IMAGE }}:dev

.github/workflows/deploy-prod.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy to Production
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/billilge-client
10+
CAPROVER_APP: app
11+
12+
jobs:
13+
build-and-deploy:
14+
runs-on: ubuntu-latest
15+
environment: production
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Create .env file
22+
run: echo "${{ secrets.PROD_ENV_FILE }}" > .env.production
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Login to Docker Hub
28+
uses: docker/login-action@v3
29+
with:
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_PASSWORD }}
32+
33+
- name: Build and Push
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
push: true
38+
tags: |
39+
${{ env.DOCKER_IMAGE }}:prod
40+
${{ env.DOCKER_IMAGE }}:prod-${{ github.sha }}
41+
${{ env.DOCKER_IMAGE }}:latest
42+
cache-from: type=gha,scope=prod
43+
cache-to: type=gha,mode=max,scope=prod
44+
45+
- name: Deploy to CapRover
46+
uses: caprover/[email protected]
47+
with:
48+
server: ${{ secrets.CAPROVER_SERVER }}
49+
app: ${{ env.CAPROVER_APP }}
50+
token: ${{ secrets.CAPROVER_PROD_APP_TOKEN }}
51+
image: ${{ env.DOCKER_IMAGE }}:prod

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Build stage
2+
FROM node:20-alpine AS builder
3+
WORKDIR /app
4+
5+
COPY package.json yarn.lock ./
6+
RUN yarn install --frozen-lockfile
7+
8+
COPY . .
9+
RUN yarn build
10+
11+
# Production stage
12+
FROM node:20-alpine AS runner
13+
WORKDIR /app
14+
15+
ENV NODE_ENV=production
16+
17+
RUN addgroup --system --gid 1001 nodejs
18+
RUN adduser --system --uid 1001 nextjs
19+
20+
COPY --from=builder /app/public ./public
21+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
22+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
23+
24+
USER nextjs
25+
26+
EXPOSE 3000
27+
ENV PORT=3000
28+
ENV HOSTNAME="0.0.0.0"
29+
30+
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)