Browse Source

Added nginx for static production serving

Tomi Cvetic 6 years ago
parent
commit
07c32803ed
3 changed files with 27 additions and 2 deletions
  1. 2 1
      .gitignore
  2. 11 1
      docker-compose.yml
  3. 14 0
      nginx/default.conf

+ 2 - 1
.gitignore

@@ -7,7 +7,8 @@ node_modules/
 /coverage
 
 # production
-/build
+/client/build
+/data
 
 # misc
 .DS_Store

+ 11 - 1
docker-compose.yml

@@ -16,11 +16,21 @@ services:
     build: ./client/
     volumes:
       - './client:/usr/src'
-      - '/usr/src/node_modules'
+      - './node_modules:/usr/src/node_modules'
     ports:
       - '3000:3000'
 
+  public:
+    container_name: public
+    image: nginx
+    ports:
+      - '8080:8080'
+    volumes:
+      - './nginx/default.conf:/etc/nginx/conf.d/default.conf'
+      - './client/build:/usr/share/nginx/html'
+
   mongodb:
+    container_name: database
     image: mongo
     volumes:
       - './data:/data/db'

+ 14 - 0
nginx/default.conf

@@ -0,0 +1,14 @@
+server {
+    listen       8080;
+    server_name  localhost;
+
+    location / {
+        root /usr/share/nginx/html;
+        try_files $uri /index.html;
+    }
+
+    error_page   500 502 503 504  /50x.html;
+    location = /50x.html {
+        root   /usr/share/nginx/html;
+    }
+}