From 761e952d537fa7f497efcff06b97805c5d83cd38 Mon Sep 17 00:00:00 2001 From: Ott Tooming Date: Tue, 5 Mar 2019 23:23:17 +0200 Subject: [PATCH] Add Docker build --- .dockerignore | 4 +++ Dockerfile.node | 16 +++++++++ common.env | 0 docker-compose.yml | 45 ++++++++++++++++++++++++++ packages/healthvet-front/package.json | 1 + packages/healthvet-server/package.json | 1 + 6 files changed, 67 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile.node create mode 100644 common.env create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5faf076 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +*Dockerfile* +*docker-compose* +*/node_modules \ No newline at end of file diff --git a/Dockerfile.node b/Dockerfile.node new file mode 100644 index 0000000..f41a604 --- /dev/null +++ b/Dockerfile.node @@ -0,0 +1,16 @@ +FROM node:10.15.0 + +ARG PACKAGE_PATH= +ARG WORKING_DIR= + +WORKDIR ${WORKING_DIR} + +COPY ${PACKAGE_PATH}/package*.json ${WORKING_DIR} + +RUN yarn install + +COPY ${PACKAGE_PATH} ${WORKING_DIR} + +VOLUME $WORKING_DIR/node_modules + +CMD [ "yarn", "start" ] diff --git a/common.env b/common.env new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2a526a4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +version: '3.5' + +services: + api: + build: + context: . + dockerfile: Dockerfile.node + args: + PACKAGE_PATH: packages/healthvet-server + WORKING_DIR: /usr/src/ + expose: + - 4000 + ports: + - 4000:4000 + environment: + - NODE_ENV=development + env_file: + - ./common.env + volumes: + - ./packages/healthvet-server:/usr/src + command: ['yarn', 'start:docker'] + + frontend: + build: + context: . + dockerfile: Dockerfile.node + args: + PACKAGE_PATH: packages/healthvet-front + WORKING_DIR: /usr/src/ + expose: + - 3000 + ports: + - 3000:3000 + environment: + - REACT_APP_ENV=development + - BACKEND=api:4000 + - HTTPS=true + - NODE_PATH=/usr/src/ + env_file: + - ./common.env + volumes: + - ./packages/healthvet-front:/usr/src + depends_on: + - api + command: ['yarn', 'start:docker'] diff --git a/packages/healthvet-front/package.json b/packages/healthvet-front/package.json index d7dfa24..8dfc2e4 100644 --- a/packages/healthvet-front/package.json +++ b/packages/healthvet-front/package.json @@ -23,6 +23,7 @@ }, "scripts": { "start": "react-scripts start", + "start:docker": "yarn install && yarn run start", "build": "react-scripts build", "generate": "gql-gen", "test": "react-scripts test", diff --git a/packages/healthvet-server/package.json b/packages/healthvet-server/package.json index f05fa8d..3c75155 100644 --- a/packages/healthvet-server/package.json +++ b/packages/healthvet-server/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "start": "ts-node src/index.ts", + "start:docker": "yarn install && yarn run start", "generate": "graphqlgen" }, "dependencies": {