Skip to content

Commit

Permalink
Aggiunto supporto Docker.
Browse files Browse the repository at this point in the history
* Aggiunto Dockerfile e docker-compose.yml per testing

* App remote env set

* Url del server socket.io tramite ENV

* Stampa tutte le ENV (docker debug)

* Build immagine; Configurazione reverse proxy nginx

* Aggiunto client al network privato docker

* Reverse proxy al server api

* Serving del archivio e api

* Rimosso "backend" da docker file e docker compose

* Rimosso script di debug

* Riportato VueSocket a configurazione di default

* aggiunto proxypass per socket.io

* Rimosso "/" che causava problemi

* Update main.js

* Nuova configurazione per proxy socket.io

* Socket.io rp; pics; images

FIXME: cartella /client servita staticamente nella root del api

* Socket io reverse proxy

* Unlimited body size!
  • Loading branch information
Ernesto Montada Romero authored and Richard1984 committed Feb 28, 2019
1 parent 90f9515 commit 6fd1c02
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

FROM node:10.15.1-jessie-slim as builder

WORKDIR /tmp
COPY package.json package.json
RUN yarn

COPY . .
RUN yarn build

FROM nginx:latest
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
WORKDIR /usr/nginx/html
COPY --from=builder /tmp/dist .
CMD ["nginx", "-g", "daemon off;"]
50 changes: 50 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: "2"

services:
frontend:
build: .
image: archivio-fermi-client
restart: always
container_name: archivio-client
ports:
- 80:80
depends_on:
- backend
networks:
- api-network

backend: # Usa sempre backend come nome del server api PS: se lo cambi cambia anche nginx.conf
image: prons/archivio-fermi-server:latest
container_name: archivio-server
restart: always
environment:
MONGODB_URI: "mongodb://database:27017/archivio"
JWT_SECRET: 3xWXqcDzt86YGKr2zP
NODE_ENV: development
volumes:
- server-data:/usr/app/server/public
depends_on:
- database
networks:
- api-network

database:
image: mongo:3.4.19-jessie
container_name: archivio-db
restart: always
volumes:
- database-data:/data/db
- database-config:/data/configdb
environment:
MONGO_INITDB_DATABASE: archivio
networks:
- api-network

networks:
api-network:
driver: bridge

volumes:
database-data:
database-config:
server-data:
61 changes: 61 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
worker_processes 1; ## Default: 1

events { worker_connections 1024; }

http {
sendfile on;
client_max_body_size 0;

upstream backendapi {
server backend:3000;
}

server {
listen 80;
allow all;

root /usr/nginx/html;

location /signup {
proxy_pass http://backendapi$uri$is_args$args;
}
location /login {
proxy_pass http://backendapi$uri$is_args$args;
}
location /logout {
proxy_pass http://backendapi$uri$is_args$args;
}
location /api {
proxy_pass http://backendapi$uri$is_args$args;
}
location /public {
proxy_pass http://backendapi$uri$is_args$args;
}
location /pics {
proxy_pass http://backendapi$uri$is_args$args;
}
location /images {
proxy_pass http://backendapi$uri$is_args$args;
}

location /socket.io {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;

proxy_pass http://backendapi$uri$is_args$args;
proxy_redirect off;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

location / {
include /etc/nginx/mime.types;
try_files $uri $uri/ /index.html;
index index.html index.html;
}
}
}

0 comments on commit 6fd1c02

Please sign in to comment.