Skip to content

Commit

Permalink
Ability to configure docker compose file
Browse files Browse the repository at this point in the history
  • Loading branch information
danmgs committed Aug 18, 2019
1 parent 4e787e9 commit e60f55e
Show file tree
Hide file tree
Showing 23 changed files with 719 additions and 14,460 deletions.
14 changes: 14 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
COMPOSE_PROJECT_NAME=my-weather-app

ENV_MONGO_PORT=27017

ENV_SERVER_API_PORT=30001
ENV_SERVER_API_MONGODB_URI=mongodb://mongo-service:27017
ENV_SERVER_API_ALLOW_HOSTS=*

ENV_CLIENT_WEBAPP_PORT=4200

NODE_ENV=production

ENV_SERVER_API_DOCKER_IMAGE_TAG=danmgs/myweatherapp-server-api:1.0
ENV_CLIENT_WEBAPP_DOCKER_IMAGE_TAG=danmgs/myweatherapp-client-webapp:1.0
65 changes: 44 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
version: '3'

services:
my-mongo-service:

mongo-service:

container_name: mongo
image: mongo
restart: always
ports:
- "27017:27017"
# environment:
# ME_CONFIG_MONGODB_ADMINUSERNAME: root
# ME_CONFIG_MONGODB_ADMINPASSWORD: example
my-server-api-service:
container_name: server
build:
dockerfile : Dockerfile.dev
- '$ENV_MONGO_PORT:$ENV_MONGO_PORT'
volumes:
- ./mongo/data/db:/data/db:ro

server-api-service:

build:
dockerfile: Dockerfile
context: ./server
image: $ENV_SERVER_API_DOCKER_IMAGE_TAG
working_dir: /usr/src/app
# volumes:
#- ./server:/usr/src/app
#- /usr/src/app/node_modules
# command: './node_modules/nodemon/bin/nodemon'
command: 'node ./src/app.js'
container_name: server-api-service
ports:
- "30001:30001"
- '$ENV_SERVER_API_PORT:$ENV_SERVER_API_PORT'
environment:
- SERVER_API_PORT=30001
- MONGODB_URI=mongodb://my-mongo-service:27017
restart: always
- ENV_SERVER_API_MONGODB_URI=$ENV_SERVER_API_MONGODB_URI
- ENV_SERVER_API_ALLOW_HOSTS=$ENV_SERVER_API_ALLOW_HOSTS
- NODE_ENV=$NODE_ENV
restart: always
depends_on:
- my-mongo-service
client-service:
container_name: client
build:
dockerfile : Dockerfile.dev
- mongo-service

client-webapp-service:

build:
context: ./public
dockerfile: Dockerfile
# args:
# - NODE_ENV=development # development / staging / production
image: $ENV_CLIENT_WEBAPP_DOCKER_IMAGE_TAG
working_dir: /usr/src/app
# volumes:
# - ./public:/usr/src/app
# - /usr/src/app/node_modules
container_name: client-webapp-service
ports:
- "4200:4200"
- '$ENV_CLIENT_WEBAPP_PORT:$ENV_CLIENT_WEBAPP_PORT'
environment:
- NODE_ENV=$NODE_ENV # development / staging / production
command: "npm start"
restart: always
depends_on:
- my-server-api-service

- server-api-service
13 changes: 13 additions & 0 deletions public/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:alpine

ARG NODE_ENV=development
ENV NODE_ENV $NODE_ENV

RUN echo $NODE_ENV

WORKDIR /usr/src/app
COPY ./package*.json ./
RUN npm install
COPY . .

CMD ["npm", "run", "start"]
10 changes: 0 additions & 10 deletions public/Dockerfile.dev

This file was deleted.

Loading

0 comments on commit e60f55e

Please sign in to comment.