-
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.
Merge pull request #52 from jaeyo03/main
Dockerfile 수정
- Loading branch information
Showing
1 changed file
with
15 additions
and
14 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,35 +1,36 @@ | ||
# Base image for building | ||
FROM node:18-alpine AS base | ||
FROM node:18-alpine AS build | ||
|
||
# Define arguments for environment variables | ||
ARG VITE_KAKAO_MAP_KEY | ||
ARG VITE_KAKAO_REST_API_KEY | ||
|
||
# Install dependencies | ||
# Set working directory and copy package files | ||
WORKDIR /app | ||
COPY package.json package-lock.json* ./ | ||
|
||
RUN npm ci # package 설치 | ||
# Install dependencies | ||
RUN npm ci # Install packages | ||
|
||
# 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 # npm run build 명령어로 vite 실행 | ||
RUN npm run build # Run the Vite build command | ||
|
||
# Nginx server to serve static files | ||
FROM nginx:stable-alpine AS runner | ||
# Production stage | ||
FROM node:18-alpine AS serve | ||
|
||
# Copy nginx configuration (optional, if you have a custom config) | ||
COPY nginx/nginx.conf /etc/nginx/nginx.conf | ||
# Install serve to serve static files | ||
RUN npm install -g serve | ||
|
||
# Copy built files to Nginx for serving | ||
COPY --from=base /app/dist /usr/share/nginx/html | ||
# Copy built files | ||
COPY --from=build /app/dist /app | ||
|
||
# Expose port 80 for Nginx | ||
EXPOSE 80 | ||
# Expose port 3000 for serve | ||
EXPOSE 3000 | ||
|
||
# Start Nginx | ||
CMD ["nginx", "-g", "daemon off;"] | ||
# Serve static files on port 3000 | ||
CMD ["serve", "-s", "/app", "-l", "3000"] |