-
Notifications
You must be signed in to change notification settings - Fork 0
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
33 additions
and
25 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,46 +1,54 @@ | ||
# 빌드 단계 | ||
FROM node:18.19-alpine AS builder | ||
|
||
# 작업 디렉토리 설정 | ||
WORKDIR /app | ||
|
||
# 필요한 시스템 패키지 설치 | ||
RUN apk add --no-cache libc6-compat | ||
|
||
# .env 파일 | ||
# 환경 변수 설정 (빌드 시간 ARG로 전달받음) | ||
ARG VITE_SERVER_BASE_URL | ||
ENV VITE_SERVER_BASE_URL=${VITE_SERVER_BASE_URL} | ||
|
||
ARG VITE_SERVER_SOCKET_URL | ||
ENV VITE_SERVER_SOCKET_URL=${VITE_SERVER_SOCKET_URL} | ||
|
||
ARG CHANNEL_TALK_PLUGIN_KEY | ||
ENV CHANNEL_TALK_PLUGIN_KEY=${CHANNEL_TALK_PLUGIN_KEY} | ||
|
||
ARG VITE_SERVER_GRAFANA_URL | ||
ENV VITE_SERVER_GRAFANA_URL=${VITE_SERVER_GRAFANA_URL} | ||
|
||
COPY . ./ | ||
ENV VITE_SERVER_BASE_URL=${VITE_SERVER_BASE_URL} \ | ||
VITE_SERVER_SOCKET_URL=${VITE_SERVER_SOCKET_URL} \ | ||
CHANNEL_TALK_PLUGIN_KEY=${CHANNEL_TALK_PLUGIN_KEY} \ | ||
VITE_SERVER_GRAFANA_URL=${VITE_SERVER_GRAFANA_URL} | ||
|
||
RUN yarn install --immutable | ||
RUN yarn build | ||
# 소스 코드 복사 | ||
COPY . . | ||
|
||
# 의존성 설치 및 애플리케이션 빌드 | ||
RUN yarn install --immutable && yarn build | ||
|
||
# 실행 단계 | ||
FROM nginx:alpine AS runner | ||
|
||
# Nginx 설정 | ||
RUN echo "\ | ||
server {\ | ||
listen 3000;\ | ||
location / {\ | ||
root /usr/share/nginx/html;\ | ||
index index.html index.htm;\ | ||
try_files \$uri \$uri/ /index.html =404;\ | ||
}\ | ||
}" > /etc/nginx/conf.d/default.conf | ||
# 작업 디렉토리 설정 | ||
WORKDIR /usr/share/nginx/html | ||
|
||
# Nginx 설정 복사 및 설정 최적화 | ||
COPY --from=builder /app/dist ./ | ||
COPY <<EOF /etc/nginx/conf.d/default.conf | ||
server { | ||
listen 3000; | ||
server_name localhost; | ||
|
||
COPY --from=builder /app/dist /usr/share/nginx/html | ||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html; | ||
try_files \$uri /index.html; | ||
} | ||
|
||
# 3000포트 열기 | ||
error_page 404 /index.html; | ||
} | ||
EOF | ||
|
||
# 3000포트 노출 | ||
EXPOSE 3000 | ||
|
||
# Nginx 시작 | ||
CMD ["nginx", "-g", "daemon off;"] | ||
|
||
|