Skip to content

Commit

Permalink
feat(docker): added docker integration
Browse files Browse the repository at this point in the history
  • Loading branch information
serge1peshcoff committed Feb 1, 2020
1 parent d78a631 commit afa033b
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config = {
default: {
port: 8084,
postgres: {
host: process.env.DB_HOST || 'postgres',
host: process.env.DB_HOST || 'postgres-oms-core-js',
port: parseInt(process.env.DB_PORT, 10) || 5432,
username: process.env.USERNAME || 'postgres',
password: process.env.PG_PASSWORD || '5ecr3t',
Expand Down
11 changes: 11 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.4"
### OMS STATUTORY #######################################
services:
oms-core-js:
build:
context: ./${PATH_OMS_CORE_JS}/..
dockerfile: ./docker/oms-statutory/Dockerfile
image: aegee/oms-statutory:dev
volumes:
- /usr/app/src/node_modules
- ./${PATH_OMS_CORE_JS}/../:/usr/app/src
56 changes: 56 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: "3.4"

services:
postgres-oms-core-js:
restart: always
image: postgres:10
volumes:
- postgres-oms-core-js:/var/lib/postgresql/data
expose:
- "5432"
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "${PW_POSTGRES}"

oms-core-js:
restart: always
image: aegee/oms-core-js:latest
volumes:
- oms-core-js-media:/usr/app/media
- shared:/usr/app/shared:ro
depends_on:
- postgres-oms-core-js
expose:
- "8084"
environment:
BUGSNAG_KEY: "${BUGSNAG_KEY_CORE_JS}"
PG_PASSWORD: "${PW_POSTGRES}"
NODE_ENV: "${MYAEGEE_ENV}"
HOST: "${SUBDOMAIN_FRONTEND}${BASE_URL}"
CORE_LOGIN: "${CORE_LOGIN}"
CORE_PASSWORD: "${CORE_PASSWORD}"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8084/healthcheck"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
labels:
- "traefik.backend=oms-core-js"
- "traefik.port=8084"
- "traefik.frontend.rule=PathPrefix:/api/core;PathPrefixStrip:/api/core"
- "traefik.frontend.priority=110"
- "traefik.enable=true"

volumes:
postgres-oms-core-js:
driver: local
oms-core-js-media:
driver: local
shared:
driver: local

networks:
default:
external:
name: OMS
28 changes: 28 additions & 0 deletions docker/oms-core-js/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:12

RUN mkdir -p /usr/app/src \
&& mkdir -p /usr/app/media \
&& mkdir -p /usr/app/scripts

RUN apt-get update
RUN apt-get install netcat -y

COPY ./docker/oms-statutory/bootstrap.sh /usr/app/scripts/bootstrap.sh
COPY ./docker/oms-statutory/wait.sh /usr/app/scripts/wait.sh
COPY . /usr/app/src

RUN chown -R node:node /usr/app

WORKDIR /usr/app/src

USER node

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH="/home/node/.npm-global/bin:${PATH}"

RUN npm install -g --loglevel warn nodemon && npm cache clean --force
RUN npm install --loglevel warn

CMD sh /usr/app/scripts/bootstrap.sh && nodemon -e "js,json" lib/run.js

EXPOSE 8084
5 changes: 5 additions & 0 deletions docker/oms-core-js/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
echo "Creating database..."
npm run db:create
echo "Migrating database..."
npm run db:migrate
10 changes: 10 additions & 0 deletions docker/oms-core-js/wait.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "Waiting for bootstrap"

while ! nc -z localhost 8084; do
sleep 0.1
done

echo "Bootstrap finished"

0 comments on commit afa033b

Please sign in to comment.