配置nginx
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m48s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m48s
This commit is contained in:
parent
a0c1dc6ad5
commit
844ee38215
26
Dockerfile
26
Dockerfile
@ -1,22 +1,24 @@
|
|||||||
FROM node:22.14.0-alpine3.21 AS build-stage
|
FROM node:22.14.0-alpine3.21 AS build-stage
|
||||||
COPY ./ /app
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV NPM_CONFIG_REGISTRY=https://registry.npmmirror.com/
|
ENV NPM_CONFIG_REGISTRY=https://registry.npmmirror.com/
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
ARG DEPLOY_ENV=prod
|
RUN npm run build
|
||||||
RUN if [ "$DEPLOY_ENV" = "test" ]; then \
|
|
||||||
npm run build ; \
|
|
||||||
else \
|
|
||||||
npm run build ; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
FROM node:22.14.0-alpine3.21 AS production-stage
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
# production stage
|
RUN apk add --no-cache nginx ffmpeg
|
||||||
FROM nginx:1.27.4-alpine3.21 AS production-stage
|
|
||||||
RUN mkdir /app
|
COPY --from=build-stage /app /app
|
||||||
COPY --from=build-stage /app/dist /app
|
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
RUN mkdir -p /run/nginx /var/lib/nginx/tmp /var/log/nginx /app/uploads
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
|
CMD ["sh", "-c", "node ./node_modules/tsx/dist/cli.mjs server.ts & nginx -g 'daemon off;'"]
|
||||||
|
|||||||
29
nginx.conf
29
nginx.conf
@ -1,7 +1,7 @@
|
|||||||
user nginx;
|
user nginx;
|
||||||
worker_processes 1;
|
worker_processes 1;
|
||||||
error_log /var/log/nginx/error.log warn;
|
error_log /var/log/nginx/error.log warn;
|
||||||
pid /var/run/nginx.pid;
|
pid /run/nginx.pid;
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
}
|
}
|
||||||
@ -14,17 +14,30 @@ http {
|
|||||||
access_log /var/log/nginx/access.log main;
|
access_log /var/log/nginx/access.log main;
|
||||||
sendfile on;
|
sendfile on;
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
|
client_max_body_size 1024m;
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
location / {
|
|
||||||
root /app;
|
location /video_translate/api/ {
|
||||||
index index.html;
|
proxy_pass http://127.0.0.1:3000/api/;
|
||||||
try_files $uri $uri/ /index.html;
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_read_timeout 600s;
|
||||||
|
proxy_send_timeout 600s;
|
||||||
}
|
}
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
location /video_translate/ {
|
||||||
root /usr/share/nginx/html;
|
alias /app/dist/;
|
||||||
|
index index.html;
|
||||||
|
try_files $uri $uri/ /video_translate/index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /video_translate {
|
||||||
|
return 301 /video_translate/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user