diff --git a/.github/workflows/main.yml b/.github/workflows/ci-cd.yml similarity index 96% rename from .github/workflows/main.yml rename to .github/workflows/ci-cd.yml index 24948b3..3feb6a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/ci-cd.yml @@ -23,6 +23,8 @@ jobs: run: yarn install - name: Build the project + env: + VITE_API_URI: ${{ secrets.VITE_API_URI }} run: yarn build - name: Build Docker image diff --git a/.gitignore b/.gitignore index a547bf3..438657a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ node_modules dist dist-ssr *.local +.env # Editor directories and files .vscode/* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5e1088b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# 1단계: 빌드 단계 +FROM node:18 AS build + +WORKDIR /app + +# package.json과 yarn.lock을 복사 +COPY package.json yarn.lock ./ + +# 종속성 설치 +RUN yarn install + +# 소스 코드를 복사 +COPY . . + +# 애플리케이션 빌드 +RUN yarn build + +# 2단계: 런타임 단계 +FROM nginx:alpine + +# Nginx 설정 파일을 복사 (선택 사항) +COPY nginx.conf /etc/nginx/nginx.conf + +# 빌드 결과물을 Nginx의 기본 경로로 복사 +COPY --from=build /app/dist /usr/share/nginx/html + +# 포트 80 노출 +EXPOSE 80 + +# Nginx 실행 +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..2b8db07 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,27 @@ +worker_processes 1; + +events { worker_connections 1024; } + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 65; + + server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } +}