配置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
|
||||
COPY ./ /app
|
||||
WORKDIR /app
|
||||
|
||||
ENV NPM_CONFIG_REGISTRY=https://registry.npmmirror.com/
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
ARG DEPLOY_ENV=prod
|
||||
RUN if [ "$DEPLOY_ENV" = "test" ]; then \
|
||||
npm run build ; \
|
||||
else \
|
||||
npm run build ; \
|
||||
fi
|
||||
RUN npm run build
|
||||
|
||||
FROM node:22.14.0-alpine3.21 AS production-stage
|
||||
WORKDIR /app
|
||||
|
||||
# production stage
|
||||
FROM nginx:1.27.4-alpine3.21 AS production-stage
|
||||
RUN mkdir /app
|
||||
COPY --from=build-stage /app/dist /app
|
||||
RUN apk add --no-cache nginx ffmpeg
|
||||
|
||||
COPY --from=build-stage /app /app
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
RUN mkdir -p /run/nginx /var/lib/nginx/tmp /var/log/nginx /app/uploads
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
CMD ["sh", "-c", "node ./node_modules/tsx/dist/cli.mjs server.ts & nginx -g 'daemon off;'"]
|
||||
|
||||
27
nginx.conf
27
nginx.conf
@ -1,7 +1,7 @@
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
pid /run/nginx.pid;
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
@ -14,17 +14,30 @@ http {
|
||||
access_log /var/log/nginx/access.log main;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
client_max_body_size 1024m;
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
location / {
|
||||
root /app;
|
||||
|
||||
location /video_translate/api/ {
|
||||
proxy_pass http://127.0.0.1:3000/api/;
|
||||
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;
|
||||
}
|
||||
|
||||
location /video_translate/ {
|
||||
alias /app/dist/;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
try_files $uri $uri/ /video_translate/index.html;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
location = /video_translate {
|
||||
return 301 /video_translate/;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user