Skip to content

Commit

Permalink
[#109] 도커 파일 수정 및 app.yaml 파일 수정 (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
henny1105 authored Feb 11, 2025
1 parent fb0ec26 commit e2ee709
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 100 deletions.
18 changes: 2 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,5 @@ jobs:
# 4. App Engine에 애플리케이션 배포
- name: Deploy to App Engine
run: |
gcloud app deploy apps/express-server/app.yaml --image-url=us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/express-server:latest
gcloud app deploy apps/next-client/app.yaml --image-url=us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/next-client:latest
# 5. PR에 댓글 남기기
- name: Comment on PR
uses: actions/github-script@v6
if: ${{ github.event.workflow_run.event == 'pull_request' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.workflow_run.pull_requests[0].number,
body: "PR 확인 완료! 배포가 잘 마무리 되었습니다.😎"
})
gcloud app deploy apps/express-server/app.yaml --image-url=asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/express-server:latest
gcloud app deploy apps/next-client/app.yaml --image-url=asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/next-client:latest
10 changes: 5 additions & 5 deletions .github/workflows/docker-img.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Configure Google Cloud SDK
run: |
gcloud --quiet config set project ${{ secrets.GCP_PROJECT_ID }}
gcloud --quiet auth configure-docker us-central1-docker.pkg.dev
gcloud --quiet auth configure-docker asia-northeast3-docker.pkg.dev
# 5. express-server 이미지 빌드 및 푸시
- name: Build and Push express-server Image
Expand All @@ -38,8 +38,8 @@ jobs:
file: ./apps/express-server/Dockerfile
push: true
tags: |
us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/express-server:${{ github.sha }}
us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/express-server:latest
asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/express-server:${{ github.sha }}
asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/express-server:latest
cache-from: type=gha,scope=express-server
cache-to: type=gha,mode=max,scope=express-server
build-args: |
Expand All @@ -60,8 +60,8 @@ jobs:
file: ./apps/next-client/Dockerfile
push: true
tags: |
us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/next-client:${{ github.sha }}
us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/next-client:latest
asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/next-client:${{ github.sha }}
asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/project/next-client:latest
cache-from: type=gha,scope=next-client
cache-to: type=gha,mode=max,scope=next-client
build-args: |
Expand Down
35 changes: 9 additions & 26 deletions apps/express-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
# Base Image
# 베이스 이미지 설정
FROM node:20-alpine3.18 AS phase1

# 작업 디렉터리 설정
WORKDIR /app

# Copy necessary files
# package.json이 변경될 경우에만 yarn 실행
COPY --chown=node:node turbo.json .
COPY --chown=node:node tsconfig.json .
COPY --chown=node:node package.json .

# Create the express-server directory and copy relevant files
# 필요한 디렉터리 생성
RUN mkdir -p apps/express-server

# 필요한 패키지 파일만 복사
COPY --chown=node:node ./apps/express-server/package.json apps/express-server
COPY --chown=node:node ./apps/express-server apps/express-server

# Environment variables for build arguments
ARG JWT_SECRET
ARG DB_USER
ARG DB_HOST
ARG DB_NAME
ARG DB_PASSWORD
ARG DB_PORT
ARG FRONTEND_URL
ARG DATA_API_KEY

# Set environment variables for runtime
ENV JWT_SECRET=$JWT_SECRET
ENV DB_USER=$DB_USER
ENV DB_HOST=$DB_HOST
ENV DB_NAME=$DB_NAME
ENV DB_PASSWORD=$DB_PASSWORD
ENV DB_PORT=$DB_PORT
ENV FRONTEND_URL=$FRONTEND_URL
ENV DATA_API_KEY=$DATA_API_KEY

# Install dependencies
# 종속성 설치
RUN yarn

# Build express-server
# express-server 빌드
RUN yarn build

# Start the server
# 개발 환경에서 서버 실행
CMD ["yarn", "workspace", "express-server", "start"]
11 changes: 6 additions & 5 deletions apps/express-server/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@ env: flex

manual_scaling:
instances: 1

resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10

env_variables:
JWT_SECRET: 'b1fbf862fe5538e821c12ac9c45c9809f87e685e04ebe183ec061efd5a46820ea779b0d159732465ca36c97a62c4c7305e89df29b859cdabd5161b67548875fb'
JWT_SECRET: 'projects/109725974101/secrets/JWT_SECRET/versions/latest'
DB_USER: 'postgres'
DB_HOST: '/cloudsql/f-lab-project-440413:us-central1:postgres'
DB_HOST: '/cloudsql/medi-map-449217:us-central1:postgress'
DB_NAME: 'postgres'
DB_PASSWORD: 'postgres'
DB_PORT: 5432
FRONTEND_URL: 'https://f-lab-project-440413.uc.r.appspot.com'
DATA_API_KEY: 'YJ8so8uNR%2FiHv%2FB3FhjsGfy%2BxFhgfB9tv9grEqDfzPkkoWEx8tIiME6UarZefKqWPeHo%2BE3XxrtqA8BH0WOlnQ%3D%3D'
FRONTEND_URL: 'https://medi-map-449217.uc.r.appspot.com'
DATA_API_KEY: 'projects/109725974101/secrets/DATA_API_KEY/versions/latest'

beta_settings:
cloud_sql_instances: "f-lab-project-440413:us-central1:postgres"
cloud_sql_instances: 'medi-map-449217:us-central1:postgress'

readiness_check:
app_start_timeout_sec: 600
Expand Down
54 changes: 13 additions & 41 deletions apps/next-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,27 @@
# Base Image
# 베이스 이미지 설정
FROM node:20-alpine3.18 AS base

# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine
# to understand why libc6-compat might be needed.
# 필요한 종속성 추가
RUN apk add --no-cache libc6-compat

# Set working directory
# 작업 디렉터리 설정
WORKDIR /app

# Define build-time variables
ARG GOOGLE_CLIENT_ID
ARG GOOGLE_CLIENT_SECRET
ARG NEXTAUTH_SECRET
ARG NEXT_PUBLIC_LOCAL_BACKEND_URL
ARG NEXTAUTH_URL
ARG NEXT_PUBLIC_KAKAO_MAP_KEY
ARG DATA_API_KEY

# Set environment variables to be used in the container
ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID
ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET
ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET
ENV NEXT_PUBLIC_LOCAL_BACKEND_URL=$NEXT_PUBLIC_LOCAL_BACKEND_URL
ENV NEXTAUTH_URL=$NEXTAUTH_URL
ENV NEXT_PUBLIC_KAKAO_MAP_KEY=$NEXT_PUBLIC_KAKAO_MAP_KEY
ENV DATA_API_KEY=$DATA_API_KEY

# Create the next-client directory and copy necessary files
RUN mkdir -p apps/next-client

# Copy root package.json and yarn.lock
COPY package.json yarn.lock /app/

# Copy next-client package.json
COPY ./apps/next-client/package.json /app/apps/next-client/

# Copy the rest of the next-client files
COPY ./apps/next-client /app/apps/next-client/

# Install dependencies for next-client
WORKDIR /app/apps/next-client
# 패키지 파일 복사
COPY package.json yarn.lock ./
COPY apps/next-client/package.json apps/next-client/

# 종속성 설치
RUN yarn --frozen-lockfile

# Copy the rest of the next-client application code into the container
COPY --chown=node:node ./apps/next-client ./apps/next-client/
# 애플리케이션 코드 복사
COPY apps/next-client apps/next-client

# Build the Next.js app
# Next.js 애플리케이션 빌드
RUN yarn workspace next-client build

# Expose the port Next.js app runs on (default is 3000)
# 애플리케이션 실행 포트 공개 (기본값: 3000)
EXPOSE 3000

# Start the app
# 애플리케이션 시작
CMD ["yarn", "workspace", "next-client", "start"]
15 changes: 8 additions & 7 deletions apps/next-client/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ automatic_scaling:
max_num_instances: 5

env_variables:
NEXT_PUBLIC_LOCAL_BACKEND_URL: "https://backend-dot-f-lab-project-440413.uc.r.appspot.com"
GOOGLE_CLIENT_ID: "560997285561-laq7qtne5qfo3uqvm7opijbvdpf05fdb.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET: "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"
NEXTAUTH_SECRET: "8b885ddb0a5da1f04784be72e27589c9fbfee22d20f4ef27f063d8ed7d8211bd"
NEXTAUTH_URL: "https://f-lab-project-440413.uc.r.appspot.com"
NEXT_PUBLIC_KAKAO_MAP_KEY: "23090c63da235aab83cf17abbb29bcab"
DATA_API_KEY: "YJ8so8uNR%2FiHv%2FB3FhjsGfy%2BxFhgfB9tv9grEqDfzPkkoWEx8tIiME6UarZefKqWPeHo%2BE3XxrtqA8BH0WOlnQ%3D%3D"
NEXT_PUBLIC_LOCAL_BACKEND_URL: "https://backend-dot-medi-map-449217.uc.r.appspot.com"
NEXT_PUBLIC_GOOGLE_CLIENT_ID: "projects/109725974101/secrets/NEXT_PUBLIC_LOCAL_BACKEND_URL/versions/latest"
GOOGLE_CLIENT_ID: "projects/109725974101/secrets/GOOGLE_CLIENT_ID/versions/latest"
GOOGLE_CLIENT_SECRET: "projects/109725974101/secrets/GOOGLE_CLIENT_SECRET/versions/latest"
NEXTAUTH_SECRET: "projects/109725974101/secrets/NEXTAUTH_SECRET/versions/latest"
NEXTAUTH_URL: "projects/109725974101/secrets/NEXTAUTH_URL/versions/latest"
NEXT_PUBLIC_KAKAO_MAP_KEY: "projects/109725974101/secrets/NEXT_PUBLIC_KAKAO_MAP_KEY/versions/latest"
DATA_API_KEY: "projects/109725974101/secrets/DATA_API_KEY/versions/latest"

readiness_check:
app_start_timeout_sec: 600

0 comments on commit e2ee709

Please sign in to comment.