mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 03:39:29 +00:00
Build frontend in docker for production using nginx
This commit is contained in:
4
frontend/.docker/nginx/conf.d/default.conf
Executable file
4
frontend/.docker/nginx/conf.d/default.conf
Executable file
@@ -0,0 +1,4 @@
|
||||
server {
|
||||
server_name _;
|
||||
include include.d/spa.conf;
|
||||
}
|
||||
3
frontend/.docker/nginx/include.d/allcache.conf
Executable file
3
frontend/.docker/nginx/include.d/allcache.conf
Executable file
@@ -0,0 +1,3 @@
|
||||
expires 1y;
|
||||
add_header Cache-Control "public";
|
||||
access_log off;
|
||||
5
frontend/.docker/nginx/include.d/nocache.conf
Executable file
5
frontend/.docker/nginx/include.d/nocache.conf
Executable file
@@ -0,0 +1,5 @@
|
||||
add_header Last-Modified $date_gmt;
|
||||
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
||||
if_modified_since off;
|
||||
expires off;
|
||||
etag off;
|
||||
16
frontend/.docker/nginx/include.d/root.conf
Executable file
16
frontend/.docker/nginx/include.d/root.conf
Executable file
@@ -0,0 +1,16 @@
|
||||
# X-Frame-Options is to prevent from clickJacking attack
|
||||
add_header X-Frame-Options SAMEORIGIN;
|
||||
|
||||
# disable content-type sniffing on some browsers.
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
|
||||
# This header enables the Cross-site scripting (XSS) filter
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
|
||||
# This will enforce HTTP browsing into HTTPS and avoid ssl stripping attack
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
|
||||
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade";
|
||||
|
||||
# Enables response header of "Vary: Accept-Encoding"
|
||||
gzip_vary on;
|
||||
19
frontend/.docker/nginx/include.d/spa.conf
Executable file
19
frontend/.docker/nginx/include.d/spa.conf
Executable file
@@ -0,0 +1,19 @@
|
||||
listen 80;
|
||||
index index.html;
|
||||
root /var/www/public/;
|
||||
|
||||
location /{{ default .Env.FOLDER_BACKEND "api" }}/ {
|
||||
proxy_pass {{ .Env.URL_BACKEND }};
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
include include.d/nocache.conf;
|
||||
}
|
||||
|
||||
location /static {
|
||||
alias /var/www/public/static/;
|
||||
include include.d/allcache.conf;
|
||||
}
|
||||
|
||||
include include.d/root.conf;
|
||||
24
frontend/Dockerfile
Normal file
24
frontend/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
FROM node:14-alpine as build-deps
|
||||
WORKDIR /usr/src/app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm install
|
||||
COPY .env* ./
|
||||
COPY src/ ./src/
|
||||
COPY public/ ./public/
|
||||
RUN echo "REACT_APP_BACKEND_URL=/api/" > .env.production
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
RUN apk add --no-cache openssl
|
||||
ENV DOCKERIZE_VERSION v0.6.1
|
||||
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
||||
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
||||
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
|
||||
|
||||
COPY .docker/nginx /etc/nginx/
|
||||
COPY --from=build-deps /usr/src/app/build /var/www/public/
|
||||
EXPOSE 80
|
||||
|
||||
RUN echo "dockerize -template /etc/nginx/include.d/spa.conf:/etc/nginx/include.d/spa.conf" > /docker-entrypoint.d/01-change-url-backend.sh \
|
||||
&& chmod +x /docker-entrypoint.d/01-change-url-backend.sh
|
||||
Reference in New Issue
Block a user