Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NRPTI-1115] DEV FEATURE** Create Dockerfiles and docker-compose #1116

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:18.15.0-alpine AS base

# Directory used in container
WORKDIR /usr/api/

# Copy everything
COPY . .

##################
### PROD IMAGE ###
##################
FROM node:18.15.0-alpine as prod
ENV NODE_ENV=production

# Add curl for health check
RUN apk --update --no-cache add curl

# Directory used in container
WORKDIR /usr/api/

# Install packages. Needed even for compiled build.
COPY package.json .
RUN yarn

# Copy compiled build from base
COPY --from=base /usr/api .

CMD [ "node", "app.js" ]
52 changes: 52 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: "3.7"
services:
#############################################################################################
### Mongo ###
#############################################################################################
mongo:
image: mongo:3.6
container_name: nrpti-mongo
tty: true
restart: always
volumes:
- ./mongoSeed/init:/docker-entrypoint-initdb.d
ports:
- 27017:27017
networks:
- nrpti
healthcheck:
test: echo 'db.runCommand({serverStatus:1}).ok' | mongo admin -u nrpti-admin -p nrpti-admin --quiet | grep 1
interval: 20s
timeout: 30s
retries: 5
start_period: 120s
#############################################################################################
### API ###
#############################################################################################
api:
container_name: nrpti-api
build:
context: ./api
dockerfile: Dockerfile
networks:
- nrpti
environment:
- MONGODB_SERVICE_HOST=mongo
ports:
- 3000:3000
# healthcheck:
# test: curl localhost:${PORT:-3000}/api/health | grep 'API is healthy and ready'
# interval: 20s
# timeout: 30s
# retries: 5
# start_period: 20s
depends_on:
mongo:
condition: service_healthy

#############################################################################################
### Network ###
#############################################################################################
networks:
nrpti:
driver: "bridge"
23 changes: 23 additions & 0 deletions mongoSeed/init/create-db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @desc Seed data for initialization of NRPTI Development Database
* @author LocalNewsTV
*/

const db = new Mongo().getDB('nrpti-dev');

db.createUser({
user: "nrpti-admin",
pwd: "nrpti-admin",
roles: [{
role: 'readWrite',
db: 'nrpti-dev',
}],
});

db.createCollection("audit", {capped: false});
db.createCollection("description_summary_subset", {capped: false});
db.createCollection("location_subset", {capped: false});
db.createCollection("migrations", {capped: false});
db.createCollection("nrpti", {capped: false});
db.createCollection("record_name_subset", {capped: false});
db.createCollection("redacted_record_subset", {capped: false});
Loading