Skip to content

Commit

Permalink
build : dockerfile 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeyo03 authored Nov 5, 2024
1 parent 32be660 commit 76f86b4
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions Dockerfile
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;"]

0 comments on commit 76f86b4

Please sign in to comment.