-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
10 additions
and
16 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 |
---|---|---|
@@ -1,36 +1,30 @@ | ||
# Base image for building | ||
FROM node:18-alpine AS build | ||
FROM node:18-alpine AS base | ||
|
||
# Define arguments for environment variables | ||
ARG VITE_KAKAO_MAP_KEY | ||
ARG VITE_KAKAO_REST_API_KEY | ||
|
||
# Set working directory and copy package files | ||
# Install dependencies | ||
WORKDIR /app | ||
COPY package.json package-lock.json* ./ | ||
|
||
# Install dependencies | ||
RUN npm ci # Install packages | ||
RUN npm ci # package 설치 | ||
|
||
# Copy source code and set environment variables | ||
COPY . . | ||
ENV VITE_KAKAO_MAP_KEY=${VITE_KAKAO_MAP_KEY} | ||
ENV VITE_KAKAO_REST_API_KEY=${VITE_KAKAO_REST_API_KEY} | ||
|
||
# Build the Vite application | ||
RUN npm run build # Run the Vite build command | ||
RUN npm run build # npm run build 명령어로 vite 실행 | ||
|
||
# Production stage | ||
FROM node:18-alpine AS serve | ||
# Production stage with Nginx | ||
FROM nginx:stable-alpine AS production | ||
COPY --from=build /app/dist /usr/share/nginx/html | ||
|
||
# Install serve to serve static files | ||
RUN npm install -g serve | ||
# Nginx configuration to handle all routes with index.html | ||
COPY nginx/nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Copy built files | ||
COPY --from=build /app/dist /app | ||
|
||
# Expose port 3000 for serve | ||
EXPOSE 3000 | ||
|
||
# Serve static files on port 3000 | ||
CMD ["serve", "-s", "/app", "-l", "3000"] | ||
CMD ["nginx", "-g", "daemon off;"] |