20241113-a
This commit is contained in:
14
docker/Dockerfile
Normal file
14
docker/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM nginx:stable-alpine
|
||||
ARG version=0.0.0
|
||||
ENV VERSION=${version}
|
||||
# ENV INTERCEPT_POST=true
|
||||
|
||||
COPY pub /etc/nginx/html
|
||||
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
COPY docker/docker-entrypoint.sh /docker-entrypoint.d/40-dynamic-subpath.sh
|
||||
RUN chmod +x /docker-entrypoint.d/40-dynamic-subpath.sh \
|
||||
&& echo ${version} > /etc/nginx/html/VERSION
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
25
docker/Dockerfile.build
Normal file
25
docker/Dockerfile.build
Normal file
@@ -0,0 +1,25 @@
|
||||
# build environment
|
||||
FROM node:16 as builder
|
||||
WORKDIR /app
|
||||
ENV PATH /app/node_modules/.bin:$PATH
|
||||
COPY package.json ./
|
||||
COPY package-lock.json ./
|
||||
RUN npm install
|
||||
COPY . ./
|
||||
RUN npm run build
|
||||
|
||||
# production environment
|
||||
FROM nginx:stable-alpine
|
||||
ARG version=0.0.0
|
||||
ENV VERSION=${version}
|
||||
# ENV INTERCEPT_POST=true
|
||||
|
||||
COPY --from=builder /app/dist /etc/nginx/html
|
||||
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
COPY docker/docker-entrypoint.sh /docker-entrypoint.d/40-dynamic-subpath.sh
|
||||
RUN chmod +x /docker-entrypoint.d/40-dynamic-subpath.sh \
|
||||
&& echo ${version} > /etc/nginx/html/VERSION
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
19
docker/Dockerfile.subpath
Normal file
19
docker/Dockerfile.subpath
Normal file
@@ -0,0 +1,19 @@
|
||||
# build environment
|
||||
FROM node:14 as builder
|
||||
WORKDIR /app
|
||||
ENV PATH /app/node_modules/.bin:$PATH
|
||||
ENV REACT_APP_BASE $BASE_PATH
|
||||
ENV PUBLIC_URL $BASE_PATH/admin
|
||||
COPY package.json ./
|
||||
COPY package-lock.json ./
|
||||
RUN npm install
|
||||
COPY . ./
|
||||
RUN REACT_APP_BASE=/changzhou PUBLIC_URL=/changzhou/admin GENERATE_SOURCEMAP=false node scripts/build.js
|
||||
|
||||
# production environment
|
||||
FROM nginx:stable-alpine
|
||||
COPY --from=builder /app/dist /etc/nginx/html
|
||||
COPY nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
13
docker/docker-entrypoint.sh
Normal file
13
docker/docker-entrypoint.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
if [[ "$APP_SUB_PATH" ]]; then
|
||||
sed -i s@/admin/@$APP_SUB_PATH/admin/@g /etc/nginx/html/index.html
|
||||
sed -i s@basePath:\"@basePath:\"$APP_SUB_PATH@g /etc/nginx/html/static/js/main*
|
||||
sed -i s@\"/api/report-api/@\"${APP_SUB_PATH}/api/report-api/@g /etc/nginx/html/static/js/*
|
||||
sed -i s@'/download@'$APP_SUB_PATH/download@g /etc/nginx/html/static/js/*
|
||||
sed -i s@/admin/preview@$APP_SUB_PATH/admin/preview@g /etc/nginx/html/static/js/*
|
||||
sed -i s@baseURL=\"/api\"@baseURL=\"$APP_SUB_PATH/api\"@g /etc/nginx/html/static/js/main*
|
||||
sed -i s@"/admin/"@"$APP_SUB_PATH/admin/"@g /etc/nginx/html/static/css/*
|
||||
fi
|
||||
19
docker/nginx/default.conf
Normal file
19
docker/nginx/default.conf
Normal file
@@ -0,0 +1,19 @@
|
||||
server {
|
||||
|
||||
listen 80;
|
||||
|
||||
location ^~ /admin {
|
||||
alias /etc/nginx/html;
|
||||
try_files $uri $uri/index.html @admin;
|
||||
}
|
||||
|
||||
location @admin {
|
||||
rewrite ^.*$ /admin/index.html last;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
98
docker/nginx/nginx.conf
Normal file
98
docker/nginx/nginx.conf
Normal file
@@ -0,0 +1,98 @@
|
||||
# user www-data;
|
||||
worker_processes 2;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
client_max_body_size 10m;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
|
||||
gzip_vary on;
|
||||
gzip_min_length 1000;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_comp_level 6;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/x-ipynb+json;
|
||||
|
||||
##
|
||||
# nginx-naxsi config
|
||||
##
|
||||
# Uncomment it if you installed nginx-naxsi
|
||||
##
|
||||
|
||||
#include /etc/nginx/naxsi_core.rules;
|
||||
|
||||
##
|
||||
# nginx-passenger config
|
||||
##
|
||||
# Uncomment it if you installed nginx-passenger
|
||||
##
|
||||
|
||||
#passenger_root /usr;
|
||||
#passenger_ruby /usr/bin/ruby;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
client_header_buffer_size 16k;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
|
||||
|
||||
#mail {
|
||||
# # See sample authentication script at:
|
||||
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
|
||||
#
|
||||
# # auth_http localhost/auth.php;
|
||||
# # pop3_capabilities "TOP" "USER";
|
||||
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
|
||||
#
|
||||
# server {
|
||||
# listen localhost:110;
|
||||
# protocol pop3;
|
||||
# proxy on;
|
||||
# }
|
||||
#
|
||||
# server {
|
||||
# listen localhost:143;
|
||||
# protocol imap;
|
||||
# proxy on;
|
||||
# }
|
||||
#}
|
||||
Reference in New Issue
Block a user