-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NRPTI-1115] DEV FEATURE** Create Dockerfiles and docker-compose (#1118)
* Added Dockerfiles for API and Database * changed 'as' to 'AS'
- Loading branch information
1 parent
9bd2658
commit dc38bbf
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ${MONGO_USERNAME:-nrpti-admin} -p ${MONGO_PASSWORD:-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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); |