Browse Source

chore: updated scripts for Docker-development

Added configurable ports for Redis/Mongo/Mongoclient
Updated frontend Dockerfile packages
Added dev-docker script for different webpack config
Updated nginx.conf
Kristian Vos 5 years ago
parent
commit
28b2c42c8b
6 changed files with 26 additions and 10 deletions
  1. 4 0
      .env.template
  2. 3 3
      docker-compose.yml
  3. 5 5
      frontend/Dockerfile
  4. 2 2
      frontend/nginx.conf
  5. 1 0
      frontend/package.json
  6. 11 0
      frontend/webpack.dev-docker.js

+ 4 - 0
.env.template

@@ -1,3 +1,7 @@
 REDIS_PASSWORD=PASSWORD
+
 BACKEND_PORT=8080
 FRONTEND_PORT=80
+MONGO_PORT=27017
+MONGOCLIENT_PORT=3000
+REDIS_PORT=6379

+ 3 - 3
docker-compose.yml

@@ -19,16 +19,16 @@ services:
   mongo:
     image: mongo:4.0
     ports:
-    - "27017:27017"
+    - "${MONGO_PORT}:27017"
     command: "--auth"
   mongoclient:
     image: mongoclient/mongoclient
     ports:
-    - "3000:3000"
+    - "${MONGOCLIENT_PORT}:3000"
   redis:
     image: redis
     command: "--notify-keyspace-events Ex --requirepass ${REDIS_PASSWORD}"
     volumes:
     - .redis:/data
     ports:
-    - "6379:6379"
+    - "${REDIS_PORT}:6379"

+ 5 - 5
frontend/Dockerfile

@@ -1,10 +1,12 @@
-FROM node
+FROM node:11
 
 RUN apt-get update
 RUN apt-get install nginx -y
 
 RUN npm install -g yarn
-RUN yarn global add webpack@1.14.0
+
+RUN yarn global add webpack@4.35.3
+RUN yarn global add webpack-cli@3.3.5
 
 RUN mkdir -p /opt
 WORKDIR /opt
@@ -14,6 +16,4 @@ RUN yarn install
 
 RUN mkdir -p /run/nginx
 
-EXPOSE 80
-
-CMD nginx -c /opt/app/nginx.conf; cd /opt/app; yarn run dev
+CMD nginx -c /opt/app/nginx.conf; cd /opt/app; yarn run dev-docker

+ 2 - 2
frontend/nginx.conf

@@ -18,8 +18,8 @@ http {
 
         location / {
             try_files $uri $uri/ /index.html;
-            root   /opt/app/build;
-            index  index.html;
+            root   /opt/app/dist;
+            index  build/index.html;
         }
     }
 }

+ 1 - 0
frontend/package.json

@@ -8,6 +8,7 @@
 	"scripts": {
 		"lint": "npx eslint . --ext .js,.vue",
 		"dev": "webpack-dev-server --config webpack.dev.js",
+		"dev-docker": "webpack --config webpack.dev-docker.js",
 		"build": "webpack --config webpack.prod.js"
 	},
 	"devDependencies": {

+ 11 - 0
frontend/webpack.dev-docker.js

@@ -0,0 +1,11 @@
+const merge = require("webpack-merge");
+const common = require("./webpack.common.js");
+
+module.exports = merge(common, {
+	mode: "development",
+	devtool: "inline-source-map",
+	watch: true,
+	output: {
+		publicPath: "/build/"
+	}
+});