Parcourir la source

Add of docker images and deployment

Jérôme BUISINE il y a 5 ans
Parent
commit
7b9fca5904
6 fichiers modifiés avec 59 ajouts et 1 suppressions
  1. 2 0
      .dockerignore
  2. 7 0
      Dockerfile_back
  3. 16 0
      Dockerfile_front
  4. 7 0
      Makefile
  5. 1 1
      config.js
  6. 26 0
      docker-compose.yml

+ 2 - 0
.dockerignore

@@ -0,0 +1,2 @@
+node_modules
+npm-debug.log

+ 7 - 0
Dockerfile_back

@@ -0,0 +1,7 @@
+FROM node:11.7.0-alpine
+
+# Back docker image
+
+WORKDIR /usr/src/app
+
+EXPOSE 5000

+ 16 - 0
Dockerfile_front

@@ -0,0 +1,16 @@
+FROM nginx:1.15.10-alpine
+
+RUN apk add yarn
+RUN mkdir app
+
+COPY . /app
+
+WORKDIR /app
+
+RUN yarn install 
+RUN yarn run app:build
+
+CMD ["rm", "/usr/share/nginx/html/*/html"]
+CMD [ "cp", "-r", "/app/dist/*", "/usr/share/nginx/html" ]
+CMD ["chmod", "775", "-R", "/usr/share/nginx/html"]
+CMD ["nginx", "-g", "daemon off;"]

+ 7 - 0
Makefile

@@ -0,0 +1,7 @@
+compose:
+	yarn install
+	yarn run app:build
+	docker-compose up --scale web=3 &
+	sleep 5
+
+

+ 1 - 1
config.js

@@ -6,7 +6,7 @@ const PRODUCTION_MODE = process.env.NODE_ENV === 'production'
 
 const apiConfig = {
   routePrefix: '/api',
-  port: PRODUCTION_MODE ? 80 : 5000,
+  port: PRODUCTION_MODE ? 5000 : 5000,
   imagesPath: path.resolve(__dirname, 'images')
 }
 

+ 26 - 0
docker-compose.yml

@@ -0,0 +1,26 @@
+version: '3'
+
+services:
+
+  back_node:
+      build:
+          context: .
+          dockerfile: Dockerfile_back
+      command:    
+          sh -c "yarn install && yarn run api:start"
+      image: backapp
+      ports:
+          - "5000:5000"
+      volumes:
+          - ./:/usr/src/app
+      environment:
+          NODE_ENV: production
+          SERVE_CLIENT: $SERVE_CLIENT
+
+  front_vue:
+      build:
+          context: .
+          dockerfile: Dockerfile_front  
+      image: frontwebapp
+      ports:
+          - "80:80"