Browse Source

chore(CI): added basic travis ci implementation

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 5 years ago
parent
commit
661f6aa7f4
6 changed files with 51 additions and 14 deletions
  1. 35 0
      .travis.yml
  2. 4 4
      README.md
  3. 1 0
      backend/Dockerfile
  4. 5 5
      backend/config/template.json
  5. 1 0
      frontend/Dockerfile
  6. 5 5
      frontend/dist/config/template.json

+ 35 - 0
.travis.yml

@@ -0,0 +1,35 @@
+# .travis.yml
+
+
+language: minimal
+sudo: required
+services:
+  - docker
+
+env:
+  - REDIS_PASSWORD=PASSWORD
+  - BACKEND_PORT=8080
+  - FRONTEND_PORT=80
+  - MONGO_PORT=27017
+  - MONGO_ROOT_PASSWORD=PASSWORD_HERE
+  - MONGO_USER_USERNAME=musare
+  - MONGO_USER_PASSWORD=OTHER_PASSWORD_HERE
+  - MONGOCLIENT_PORT=3000
+  - REDIS_PORT=6379
+  - COMPOSE_PROJECT_NAME=musare
+  - FRONTEND_MODE=prod
+
+before_install:
+  # create config files from template
+  - cp backend/config/template.json backend/config/default.json
+  - cp frontend/dist/config/template.json frontend/dist/config/default.json
+
+script:
+  - docker-compose build
+  - docker compose up -d mongo # start mongo (users automatically setup)
+  - docker-compose up -d mongoclient redis # start mongoclient and redis
+  - docker-compose up -d frontend # start frontend
+  - docker-compose -p tests run frontend yarn lint # using eslint to check for formatting/linting issues
+  - docker-compose -p tests run frontend snyk test --dev # scan for dependency/dev. dependency vunerabilities
+  - docker-compose up -d backend # start backend
+  - docker-compose -p tests run backend snyk test --dev # scan for dependency/dev. dependency vunerabilities

+ 4 - 4
README.md

@@ -115,14 +115,14 @@ The configurable ports will be how you access the services on your machine, or w
 
       In `.env` set the environment variable of `MONGO_USER_USERNAME` and `MONGO_USER_PASSWORD`.
 
-   2. Start the database, which will generate the correct MongoDB users.
+   2. Start the database (in detached mode), which will generate the correct MongoDB users.
 
-      `docker-compose up mongo`
+      `docker-compose up -d mongo`
 
 
-3) Start the databases and tools in the background, as we usually don't need to monitor these for errors
+3) Start redis and the mongo client in the background, as we usually don't need to monitor these for errors
 
-   `docker-compose up -d mongo mongoclient redis`
+   `docker-compose up -d mongoclient redis`
 
 4) Start the backend and frontend in the foreground, so we can watch for errors during development
 

+ 1 - 0
backend/Dockerfile

@@ -3,6 +3,7 @@ FROM node
 RUN apt-get update
 
 RUN npm install -g nodemon
+RUN npm install -g snyk
 
 RUN mkdir -p /opt
 WORKDIR /opt

+ 5 - 5
backend/config/template.json

@@ -1,9 +1,9 @@
 {
 	"mode": "development",
-	"secret": "",
-	"domain": "",
+	"secret": "default",
+	"domain": "http://localhost",
 	"frontendPort": 80,
-	"serverDomain": "",
+	"serverDomain": "http://localhost:8080",
   	"serverPort": 8080,
   	"isDocker": true,
 	"apis": {
@@ -46,10 +46,10 @@
 	    "password": "PASSWORD"
 	},
   	"mongo": {
-	  	"url": "mongodb://musare:PASSWORD@mongo:27017/musare"
+	  	"url": "mongodb://musare:OTHER_PASSWORD_HERE@mongo:27017/musare"
 	},
   	"cookie": {
-	  	"domain": "",
+	  	"domain": "localhost",
 	  	"secure": false
 	}
 }

+ 1 - 0
frontend/Dockerfile

@@ -5,6 +5,7 @@ RUN apt-get install nginx -y
 
 RUN npm install -g yarn
 
+RUN yarn global add snyk
 RUN yarn global add webpack@4.35.3
 RUN yarn global add webpack-cli@3.3.5
 RUN yarn global add webpack-dev-server@3.7.2

+ 5 - 5
frontend/dist/config/template.json

@@ -2,12 +2,12 @@
 	"recaptcha": {
 		"key": ""
 	},
-	"serverDomain": "",
-	"frontendDomain": "",
-	"frontendPort": "",
+	"serverDomain": "http://localhost:8080",
+	"frontendDomain": "http://localhost",
+	"frontendPort": "81",
   	"cookie": {
-		"domain": "",
-		"secure": true
+		"domain": "localhost",
+		"secure": false
 	},
 	"siteSettings": {
 		"logo": "/assets/wordmark.png",