Production env for the front
This commit is contained in:
@@ -1,22 +1,11 @@
|
||||
FROM node:lts-alpine
|
||||
|
||||
# install simple http server for serving static content
|
||||
RUN npm install -g http-server
|
||||
|
||||
# make the 'app' folder the current working directory
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install -g @angular/cli
|
||||
# copy both 'package.json' and 'package-lock.json' (if available)
|
||||
RUN npm install -g @angular/cli http-server
|
||||
COPY app/package*.json ./
|
||||
|
||||
# install project dependencies
|
||||
RUN npm install
|
||||
|
||||
# copy project files and folders to the current working directory (i.e. 'app' folder)
|
||||
COPY app/ .
|
||||
|
||||
# build app for production with minification
|
||||
RUN npm run build
|
||||
|
||||
EXPOSE 4200
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
"sourceLocale": "en-US",
|
||||
"locales": {
|
||||
"fr": {
|
||||
"translation": "src/locale/messages.fr.xlf"
|
||||
"translation": "src/locale/messages.fr.xlf",
|
||||
"baseHref": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -63,9 +64,6 @@
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true,
|
||||
"namedChunks": true
|
||||
},
|
||||
"fr": {
|
||||
"localize": ["fr"]
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
@@ -80,7 +78,7 @@
|
||||
"browserTarget": "app:build:development"
|
||||
},
|
||||
"fr": {
|
||||
"browserTarget": "App:build:fr"
|
||||
"browserTarget": "app:build:fr"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
|
||||
53
front/nginx.prod.conf
Normal file
53
front/nginx.prod.conf
Normal file
@@ -0,0 +1,53 @@
|
||||
worker_processes 1;
|
||||
|
||||
events { worker_connections 1024; }
|
||||
|
||||
http {
|
||||
|
||||
sendfile on;
|
||||
|
||||
upstream docker-back {
|
||||
server back:8000;
|
||||
}
|
||||
|
||||
types {
|
||||
module js;
|
||||
}
|
||||
include /etc/nginx/mime.types;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
gzip on;
|
||||
gzip_http_version 1.1;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
gzip_min_length 256;
|
||||
gzip_vary on;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
gzip_comp_level 9;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /usr/share/nginx/html/index.html =404;
|
||||
}
|
||||
|
||||
location ~* ^.+\.css$ {
|
||||
default_type text/css;
|
||||
}
|
||||
|
||||
location ~* ^.+\.js$ {
|
||||
default_type text/javascript;
|
||||
}
|
||||
|
||||
location /api/v1/ {
|
||||
proxy_pass http://docker-back/;
|
||||
proxy_redirect off;
|
||||
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-Host $server_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
front/prod.Dockerfile
Normal file
17
front/prod.Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
FROM node:lts-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install -g @angular/cli
|
||||
|
||||
COPY app/package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY app/ .
|
||||
|
||||
RUN npm run build --prod
|
||||
|
||||
FROM nginx:alpine
|
||||
COPY nginx.prod.conf /etc/nginx/nginx.conf
|
||||
|
||||
COPY --from=builder /app/dist/app/fr/ /usr/share/nginx/html/
|
||||
Reference in New Issue
Block a user