Skip to content

Commit 5f86644

Browse files
authored
Merge pull request #143 from billilge/chore/#142-cicd-migration
[Chore/#142] 학교 내부 서버 이전을 위한 배포 파이프라인 변경
2 parents bad18b4 + e01d78d commit 5f86644

File tree

7 files changed

+133
-79
lines changed

7 files changed

+133
-79
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+
- develop
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 --ignore-scripts
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"]

next.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const nextConfig = withPWA({
1212
DB_NAME: process.env.DB_NAME,
1313
},
1414
reactStrictMode: true,
15+
output: 'standalone',
1516
swcMinify: true,
1617
async redirects() {
1718
return [
@@ -34,7 +35,7 @@ const nextConfig = withPWA({
3435
images: {
3536
domains: [
3637
'github.com',
37-
'billilge-resources.s3.us-west-2.amazonaws.com', // S3 이미지 도메인 추가
38+
'minio-api.billilge.site', // 파일서버 이미지 도메인 추가
3839
],
3940
dangerouslyAllowSVG: true,
4041
contentSecurityPolicy: "default-src 'self'; img-src 'self' data: https:;",

0 commit comments

Comments
 (0)