feat: add docker compose file
This commit is contained in:
parent
770f320372
commit
3f7d5dad92
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ yarn-debug.log*
|
|||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
pnpm-debug.log*
|
pnpm-debug.log*
|
||||||
lerna-debug.log*
|
lerna-debug.log*
|
||||||
|
netlify.toml
|
||||||
|
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
@ -20,7 +20,7 @@ COPY *.json .
|
|||||||
|
|
||||||
# Install dependencies and build the app
|
# Install dependencies and build the app
|
||||||
RUN yarn install
|
RUN yarn install
|
||||||
RUN yarn build-test
|
RUN yarn build-prod
|
||||||
|
|
||||||
|
|
||||||
# Step 2. Production image, copy all the files and run nginx
|
# Step 2. Production image, copy all the files and run nginx
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
# Dockerfile for a React app build and run
|
|
||||||
|
|
||||||
FROM node:18.19.1-alpine AS builder
|
|
||||||
MAINTAINER yaclty2@gmail.com
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# envs 配置
|
|
||||||
# 应用部署后的URL
|
|
||||||
ENV APP_SITE_URL ""
|
|
||||||
# 应用接口前缀
|
|
||||||
ENV APP_API_URL ""
|
|
||||||
|
|
||||||
# Copy source code to the builder
|
|
||||||
COPY package.json yarn.lock* ./
|
|
||||||
COPY public ./public
|
|
||||||
COPY src ./src
|
|
||||||
COPY index.html ./
|
|
||||||
COPY *.ts .
|
|
||||||
COPY *.json .
|
|
||||||
|
|
||||||
# Install dependencies and build the app
|
|
||||||
RUN yarn install
|
|
||||||
RUN yarn build-prod
|
|
||||||
|
|
||||||
|
|
||||||
# Step 2. Production image, copy all the files and run nginx
|
|
||||||
FROM nginx:1.26-alpine3.19 AS runner
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# envs 配置
|
|
||||||
ENV APP_API_URL localhost:50000
|
|
||||||
|
|
||||||
# nginx配置文件
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf.template
|
|
||||||
# 编译文件
|
|
||||||
COPY --from=builder /app/dist ./
|
|
||||||
# RUN /bin/sh envsubst /etc/nginx/templates/*.template /etc/nginx/conf.d
|
|
||||||
WORKDIR /etc/nginx/conf.d/
|
|
||||||
ENTRYPOINT sed -i "s~<!--app_url-->~<script>const APP_SITE_URL='${APP_SITE_URL}';</script>~" /app/index.html && envsubst '$APP_API_URL' < default.conf.template > default.conf && cat default.conf && nginx -g 'daemon off;'
|
|
||||||
# 暴露80端口
|
|
||||||
EXPOSE 80
|
|
||||||
# 启动Nginx服务
|
|
||||||
# CMD ["nginx", "-g", "daemon off;"]
|
|
27
compose.yaml
Normal file
27
compose.yaml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
x-common: &common
|
||||||
|
pull_policy: always # always, never, missing, build
|
||||||
|
restart: unless-stopped
|
||||||
|
stop_signal: SIGINT
|
||||||
|
stop_grace_period: 1m
|
||||||
|
logging:
|
||||||
|
driver: "json-file"
|
||||||
|
options:
|
||||||
|
max-file: "10"
|
||||||
|
max-size: "100m"
|
||||||
|
|
||||||
|
services:
|
||||||
|
hkchc-payment-frontend-server:
|
||||||
|
image: registry.hkchc.team/hkchc-payment-frontend:latest
|
||||||
|
container_name: hkchc-payment-frontend
|
||||||
|
environment:
|
||||||
|
APP_API_URL: "10.10.0.152:50000" # payment backend service
|
||||||
|
working_dir: /etc/nginx/conf.d/
|
||||||
|
ports:
|
||||||
|
- "50001:80"
|
||||||
|
command: [
|
||||||
|
"sed -i \"s~<!--app_url-->~<script>const APP_SITE_URL='${APP_SITE_URL}';</script>~\" /app/index.html && envsubst '$APP_API_URL' < default.conf.template > default.conf && cat default.conf",
|
||||||
|
"nginx -g daemon off;"
|
||||||
|
]
|
||||||
|
<<: *common
|
Loading…
x
Reference in New Issue
Block a user