release
This commit is contained in:
parent
22981e4535
commit
455af41d0d
@ -1,9 +1,6 @@
|
|||||||
# Build stage
|
# Build stage
|
||||||
FROM node:20-slim AS builder
|
FROM node:20-slim AS builder
|
||||||
ARG PROJECT_FOLDER
|
ARG PROJECT_FOLDER
|
||||||
ARG REACT_APP_MEMBER_URL
|
|
||||||
ARG REACT_APP_MYSUB_URL
|
|
||||||
ARG REACT_APP_RECOMMEND_URL
|
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
@ -20,13 +17,11 @@ RUN npm run build
|
|||||||
# Run stage
|
# Run stage
|
||||||
FROM nginx:stable-alpine
|
FROM nginx:stable-alpine
|
||||||
|
|
||||||
# 시스템 환경변수 셋팅: api.js에서 사용하는 시스템 환경변수를 build시 셋팅해야 생성됨
|
|
||||||
ENV REACT_APP_MEMBER_URL=${REACT_APP_MEMBER_URL}
|
|
||||||
ENV REACT_APP_MYSUB_URL=${REACT_APP_MYSUB_URL}
|
|
||||||
ENV REACT_APP_RECOMMEND_URL=${REACT_APP_RECOMMEND_URL}
|
|
||||||
|
|
||||||
ARG BUILD_FOLDER
|
ARG BUILD_FOLDER
|
||||||
ARG EXPORT_PORT
|
ARG EXPORT_PORT
|
||||||
|
ARG REACT_APP_MEMBER_URL
|
||||||
|
ARG REACT_APP_MYSUB_URL
|
||||||
|
ARG REACT_APP_RECOMMEND_URL
|
||||||
|
|
||||||
# Create nginx user if it doesn't exist
|
# Create nginx user if it doesn't exist
|
||||||
RUN adduser -S nginx || true
|
RUN adduser -S nginx || true
|
||||||
@ -34,6 +29,17 @@ RUN adduser -S nginx || true
|
|||||||
# Copy build files
|
# Copy build files
|
||||||
COPY --from=builder /app/build /usr/share/nginx/html
|
COPY --from=builder /app/build /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Create runtime config
|
||||||
|
/*
|
||||||
|
index.html의 헤더에서 이 값을 읽어 환경변수를 생성함
|
||||||
|
api.js에서 이 환경변수를 이용함: 예) window.__runtime_config__.MEMBER_URL
|
||||||
|
*/
|
||||||
|
RUN echo "window.__runtime_config__ = { \
|
||||||
|
MEMBER_URL: '${REACT_APP_MEMBER_URL}', \
|
||||||
|
MYSUB_URL: '${REACT_APP_MYSUB_URL}', \
|
||||||
|
RECOMMEND_URL: '${REACT_APP_RECOMMEND_URL}' \
|
||||||
|
}" > /usr/share/nginx/html/runtime-env.js
|
||||||
|
|
||||||
# Copy and process nginx configuration
|
# Copy and process nginx configuration
|
||||||
COPY ${BUILD_FOLDER}/nginx.conf /etc/nginx/templates/default.conf.template
|
COPY ${BUILD_FOLDER}/nginx.conf /etc/nginx/templates/default.conf.template
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
<meta name="description" content="생활 구독 관리 서비스" />
|
<meta name="description" content="생활 구독 관리 서비스" />
|
||||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
|
<script src="%PUBLIC_URL%/runtime-env.js"></script>
|
||||||
<title>마이구독</title>
|
<title>마이구독</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
5
public/runtime-env.js
Normal file
5
public/runtime-env.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
window.__runtime_config__ = {
|
||||||
|
MEMBER_URL: 'http://localhost:8081',
|
||||||
|
MYSUB_URL: 'http://localhost:8082',
|
||||||
|
RECOMMEND_URL: 'http://localhost:8083'
|
||||||
|
};
|
||||||
@ -2,9 +2,14 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
// 서비스별 base URL
|
// 서비스별 base URL
|
||||||
|
/*
|
||||||
const MEMBER_URL = process.env.REACT_APP_MEMBER_URL || 'http://localhost:8081';
|
const MEMBER_URL = process.env.REACT_APP_MEMBER_URL || 'http://localhost:8081';
|
||||||
const MYSUB_URL = process.env.REACT_APP_MYSUB_URL || 'http://localhost:8082';
|
const MYSUB_URL = process.env.REACT_APP_MYSUB_URL || 'http://localhost:8082';
|
||||||
const RECOMMEND_URL = process.env.REACT_APP_RECOMMEND_URL || 'http://localhost:8083';
|
const RECOMMEND_URL = process.env.REACT_APP_RECOMMEND_URL || 'http://localhost:8083';
|
||||||
|
*/
|
||||||
|
const MEMBER_URL = window.__runtime_config__.MEMBER_URL || 'http://localhost:8081';
|
||||||
|
const MYSUB_URL = window.__runtime_config__.MYSUB_URL || 'http://localhost:8082';
|
||||||
|
const RECOMMEND_URL = window.__runtime_config__.RECOMMEND_URL || 'http://localhost:8083';
|
||||||
|
|
||||||
// 서비스별 axios 인스턴스 생성
|
// 서비스별 axios 인스턴스 생성
|
||||||
const createAxiosInstance = (baseURL) => {
|
const createAxiosInstance = (baseURL) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user