diff --git a/.gitignore b/.gitignore index 36ea263..99567b1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ yarn-debug.log* yarn-error.log* pnpm-debug.log* lerna-debug.log* +netlify.toml node_modules dist diff --git a/Dockerfile b/Dockerfile index 58fa95f..f94cb50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ COPY *.json . # Install dependencies and build the app RUN yarn install -RUN yarn build-test +RUN yarn build-prod # Step 2. Production image, copy all the files and run nginx diff --git a/Dockerfile-prod b/Dockerfile-prod deleted file mode 100644 index f94cb50..0000000 --- a/Dockerfile-prod +++ /dev/null @@ -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/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;"] \ No newline at end of file diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..44bc1b9 --- /dev/null +++ b/compose.yaml @@ -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/index.html && envsubst '$APP_API_URL' < default.conf.template > default.conf && cat default.conf", + "nginx -g daemon off;" + ] + <<: *common \ No newline at end of file