mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 07:07:21 +00:00
working dockerized environment
This commit is contained in:
24
Dockerfile
24
Dockerfile
@ -1,6 +1,6 @@
|
|||||||
FROM node:20 as builder
|
FROM node:20 as builder
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /src/app
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
@ -8,18 +8,22 @@ RUN npm install
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm run build auth
|
RUN npm run build
|
||||||
RUN npm run build backend
|
|
||||||
|
|
||||||
FROM nginx:alpine
|
# Runtime stage
|
||||||
|
FROM node:20-alpine
|
||||||
|
|
||||||
RUN rm /etc/nginx/conf.d/default.conf
|
RUN apk add --no-cache nginx
|
||||||
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=builder /usr/src/app/dist/apps/auth /usr/share/nginx/html/auth
|
COPY --from=builder /src/app/dist/apps/auth ./auth
|
||||||
COPY --from=builder /usr/src/app/dist/apps/backend /usr/share/nginx/html/backend
|
COPY --from=builder /src/app/dist/apps/backend ./backend
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
EXPOSE 443
|
RUN npm install
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["sh", "-c", "nginx -g 'daemon off;' & node auth/main.js & node backend/main.js"]
|
||||||
|
25
nginx.conf
25
nginx.conf
@ -1,4 +1,8 @@
|
|||||||
events {}
|
worker_processes 1;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
include mime.types;
|
include mime.types;
|
||||||
@ -7,17 +11,22 @@ http {
|
|||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 443;
|
listen 80;
|
||||||
server_name localhost;
|
|
||||||
|
|
||||||
location /auth {
|
location /auth {
|
||||||
alias /usr/share/nginx/html/auth;
|
proxy_pass http://localhost:7001;
|
||||||
try_files $uri $uri/ /auth/index.html;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /backend {
|
location / {
|
||||||
alias /usr/share/nginx/html/backend;
|
proxy_pass http://localhost:7000;
|
||||||
try_files $uri $uri/ /backend/index.html;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
# error pages
|
# error pages
|
||||||
|
Reference in New Issue
Block a user