-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/pink-boss/joosum-web into main
- Loading branch information
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# 문서 파일 | ||
LICENSE | ||
README.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build_and_push_docker_image: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Generate Date | ||
id: date | ||
run: echo "date=$(date +'%y%m%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install Dependencies | ||
run: npm ci | ||
|
||
- name: Create .env | ||
run: | | ||
echo "${{ secrets.ENV }}" > ./.env | ||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Docker Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: joosum.kr.ncr.ntruss.com | ||
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} | ||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | ||
|
||
- name: Build and Push Docker Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: ./ | ||
file: ./Dockerfile | ||
platforms: linux/amd64 | ||
tags: joosum.kr.ncr.ntruss.com/joosum-frontend:${{ steps.date.outputs.date }} | ||
push: true | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build_and_push_docker_image | ||
if: github.ref == 'refs/heads/main' | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Generate Date | ||
id: date | ||
run: echo "date=$(date +'%y%m%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.VM_HOST_IP }} | ||
username: root | ||
password: ${{ secrets.VM_PASSWORD }} | ||
script: | | ||
docker pull joosum.kr.ncr.ntruss.com/joosum-frontend:${{ steps.date.outputs.date }} | ||
docker stop frontend || true | ||
docker run --rm -d -p 3000:3000 \ | ||
--log-opt max-size=10k --log-opt max-file=3 \ | ||
--name frontend joosum.kr.ncr.ntruss.com/joosum-frontend:${{ steps.date.outputs.date }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use Node.js LTS version | ||
FROM node:18-alpine | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json | ||
COPY package.json package-lock.json* ./ | ||
|
||
# Install dependencies | ||
RUN npm ci | ||
|
||
# Copy the rest of the application code | ||
COPY . . | ||
|
||
# Expose the port Next.js dev server runs on | ||
EXPOSE 3000 | ||
|
||
# Start the application in development mode | ||
CMD ["npm", "run", "dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Dockerfile | ||
|
||
# Stage 1: Install Dependencies | ||
FROM node:18-alpine AS deps | ||
WORKDIR /app | ||
COPY package.json package-lock.json* ./ | ||
RUN npm ci | ||
|
||
# Stage 2: Build | ||
FROM node:18-alpine AS builder | ||
WORKDIR /app | ||
|
||
# 필요한 파일만 복사 | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
# .env.prod 파일을 .env.production으로 복사 | ||
COPY .env.prod ./.env.production | ||
|
||
# 빌드 실행 | ||
RUN npm run build | ||
|
||
# Stage 3: Production Image | ||
FROM node:18-alpine AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
|
||
# 프로덕션 의존성만 설치 | ||
COPY package.json package-lock.json* ./ | ||
RUN npm ci --only=production | ||
|
||
# 빌드 결과물 복사 | ||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/.next ./.next | ||
COPY --from=builder /app/next.config.mjs ./ | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm", "start"] |