Skip to content

Commit 52a7ee9

Browse files
committed
[Update] CI/CD scripts update #1
1 parent d4d7ced commit 52a7ee9

File tree

5 files changed

+27
-29
lines changed

5 files changed

+27
-29
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ jobs:
2727

2828
- name: Build and Push Docker Image
2929
run: |
30-
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/gdgoc-solution-gallery:latest .
31-
docker run --rm ${{ secrets.DOCKER_HUB_USERNAME }}/gdgoc-solution-gallery:latest ls -la /app
32-
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/gdgoc-solution-gallery:latest
30+
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/gdgoc-solution-fe-app:latest .
31+
docker run --rm ${{ secrets.DOCKER_HUB_USERNAME }}/gdgoc-solution-fe-app:latest ls -la /app
32+
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/gdgoc-solution-fe-app:latest
3333
3434
- name: Create Deployment Package
3535
run: |
3636
cp scripts/deploy.sh ./deploy.sh
3737
zip -r deploy.zip .env docker-compose.yml deploy.sh appspec.yml \
38-
Dockerfile package.json package-lock.json next.config.ts \
38+
Dockerfile package.json package-lock.json next.config.mjs \
3939
pages public .next
4040
4141
- name: Configure AWS credentials
@@ -46,7 +46,7 @@ jobs:
4646
4747
- name: Upload Deployment Package to S3
4848
run: |
49-
aws s3 cp deploy.zip s3://${{ secrets.AWS_S3_BUCKET }}/deploy.zip
49+
aws s3 cp deploy.zip s3://${{ secrets.AWS_S3_BUCKET }}/solution-deploy.zip
5050
5151
- name: Trigger CodeDeploy (CLI)
5252
env:
@@ -57,5 +57,5 @@ jobs:
5757
aws deploy create-deployment \
5858
--application-name ${{ secrets.AWS_CODEDEPLOY_APP }} \
5959
--deployment-group-name ${{ secrets.AWS_CODEDEPLOY_GROUP }} \
60-
--s3-location bucket=${{ secrets.S3_BUCKET }},bundleType=zip,key=deploy.zip \
60+
--s3-location bucket=${{ secrets.S3_BUCKET }},bundleType=zip,key=solution-deploy.zip \
6161
--file-exists-behavior OVERWRITE

Dockerfile

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# 1단계: 빌드 환경
22
FROM node:18 AS builder
33

4-
ARG APP_DIR=/app
5-
WORKDIR ${APP_DIR}
4+
WORKDIR /app
65

76
# package.json과 package-lock.json을 먼저 복사하고, npm install 실행
87
COPY package.json package-lock.json ./
@@ -14,23 +13,22 @@ COPY .env ./
1413
# 이후 전체 파일 복사
1514
COPY . .
1615

17-
# next.config.ts 확인
18-
RUN cat next.config.ts
16+
# next.config.mjs 확인
17+
RUN cat next.config.mjs
1918

2019
# 빌드 실행 (output: export가 있는지 확인)
2120
# 명시적으로 next build 명령 사용
2221
RUN npx next build
2322

2423
# 빌드 결과 확인
25-
RUN ls -la ${APP_DIR}
26-
RUN ls -la ${APP_DIR}/.next || echo ".next 디렉토리가 없습니다"
27-
RUN ls -la ${APP_DIR}/out || echo "out 디렉토리가 없습니다"
24+
RUN ls -la /app
25+
RUN ls -la /app/.next || echo ".next 디렉토리가 없습니다"
26+
RUN ls -la /app/out || echo "out 디렉토리가 없습니다"
2827

2928
# 2단계: 실행 환경
3029
FROM node:18
3130

32-
ARG APP_DIR=/app
33-
WORKDIR ${APP_DIR}
31+
WORKDIR /app
3432

3533
# 프로덕션 의존성만 가져오기
3634
COPY package*.json ./
@@ -40,17 +38,17 @@ RUN npm install --omit=dev
4038
COPY .env ./
4139

4240
# 빌드된 결과물 가져오기
43-
COPY --from=builder ${APP_DIR}/.next ./.next
44-
COPY --from=builder ${APP_DIR}/public ./public
45-
COPY --from=builder ${APP_DIR}/node_modules ./node_modules
46-
COPY --from=builder ${APP_DIR}/package.json ./package.json
47-
COPY --from=builder ${APP_DIR}/next.config.ts ./next.config.ts
41+
COPY --from=builder /app/.next ./.next
42+
COPY --from=builder /app/public ./public
43+
COPY --from=builder /app/node_modules ./node_modules
44+
COPY --from=builder /app/package.json ./package.json
45+
COPY --from=builder /app/next.config.mjs ./next.config.mjs
4846

4947
# 실행환경 확인
50-
RUN ls -la ${APP_DIR}
51-
RUN ls -la ${APP_DIR}/.next || echo ".next 디렉토리가 없습니다"
48+
RUN ls -la /app
49+
RUN ls -la /app/.next || echo ".next 디렉토리가 없습니다"
5250

53-
EXPOSE 3001
51+
EXPOSE 3000
5452

5553
# Next.js 서버 시작
5654
CMD ["npm", "run", "start"]

appspec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 0.0
22
os: linux
33
files:
44
- source: /
5-
destination: /home/ubuntu/gdgoc-solution-gallery
5+
destination: /home/ubuntu/gdgoc-solution-fe-app
66

77
hooks:
88
AfterInstall:

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ version: "3.8"
22

33
services:
44
frontend:
5-
image: "${DOCKER_HUB_USERNAME}/gdgoc-solution-gallery:latest"
6-
container_name: gdgoc-solution-gallery
5+
image: "${DOCKER_HUB_USERNAME}/gdgoc-solution-fe-app:latest"
6+
container_name: gdgoc-solution-fe-app
77
restart: always
88
ports:
9-
- "3001:3001"
9+
- "3001:3000"
1010
environment:
1111
NODE_ENV: production
1212
working_dir: /app

scripts/deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
cd /home/ubuntu/gdgoc-solution-gallery
2+
cd /home/ubuntu/gdgoc-solution-fe-app
33

44
# Docker & Docker Compose가 설치되어 있는지 확인
55
if ! [ -x "$(command -v docker)" ]; then
@@ -29,7 +29,7 @@ docker volume prune -f
2929

3030
# 최신 이미지 가져오기
3131
export $(grep -v '^#' .env | xargs)
32-
docker pull ${DOCKER_HUB_USERNAME}/gdgoc-solution-gallery:latest
32+
docker pull ${DOCKER_HUB_USERNAME}/gdgoc-solution-fe-app:latest
3333

3434
# 컨테이너 실행
3535
docker-compose --env-file .env up -d

0 commit comments

Comments
 (0)