Skip to content

Commit 0b02a51

Browse files
Initial Containerization (#4)
* Add initial docker files * WIP add dev-related docker files * WIP try installing node_modules into parent directory of checkout * WIP * Run as non-root inside container; fix paths * Cleanup comment; add missing chown * fixup comment * reword * Add comment * Use long options * Rearrange dockerfile lines * Add docs, example config * Fixup markdown * Move USER further down * Run dc in foreground * Remove workaround; fixed in #3 * Refactor environment files * Fixup spelling Co-authored-by: Hannah <[email protected]> Co-authored-by: Hannah <[email protected]>
1 parent 5efc423 commit 0b02a51

6 files changed

+63
-0
lines changed

.env.default

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Default docker-compose environment file (.env)
2+
# https://docs.docker.com/compose/environment-variables/#the-env-file
3+
# environment variables for interpolation in docker-compose YAML files
4+
# Copy to .env and modify as necessary
5+
6+
COMPOSE_PROJECT_NAME=
7+
8+
# docker-compose development overrides; uncomment to enable
9+
# COMPOSE_FILE=docker-compose.yaml:docker-compose.dev.yaml

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# TODO update to newer version: Active LTS or Current
2+
FROM node:14
3+
4+
# cache hack (very fragile): initially only copy list of project dependencies
5+
COPY --chown=node:node package.json package-lock.json /opt/node/
6+
7+
# install node dependencies to parent directory of code
8+
WORKDIR /opt/node
9+
USER node
10+
RUN npm install
11+
12+
# add node modules binary folder to system PATH
13+
ENV PATH=/opt/node/node_modules/.bin/:$PATH
14+
15+
# copy source code, switch to code directory
16+
COPY --chown=node:node . /opt/node/app
17+
WORKDIR /opt/node/app
18+
19+
CMD ["npm", "start"]

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ A number of options are available for local usage to support testing with synthe
2727
### Setup
2828
This project manages dependencies using the [NPM package manager](https://www.npmjs.com/) in the [Node environment](https://nodejs.dev/) (Node version <= 16 is recommended for this application). Make sure to have both NPM and Node installed before proceeding. The dependencies for the application can be installed locally by typing `npm install` at the command line. A local version of the app can be launched by typing `npm start` at the command line and the page will reload when you make changes. A copy suitable for distribution can be built using the `npm run build` command (see the `build` folder).
2929

30+
### Docker
31+
To start services via docker, first copy the default configuration files and modify as necessary:
32+
33+
# docker-compose service/project configuration
34+
cp .env.default .env
35+
36+
# React App configuration
37+
cp frontend.env.default frontend.env
38+
39+
To start all services, run the below command:
40+
41+
docker-compose up
42+
3043
### Download Value Sets from VSAC
3144
The value set content used by the CQL is cached in a file named valueset-db.json, which has been checked into this project in an empty state. In order for the CDS to operate as intended, implementers must populate valueset-db.json with the value sets which have been published on the [Value Set Authority Center (VSAC)](https://vsac.nlm.nih.gov/). In order to access VSAC, you must sign up for a [UMLS Terminology Services account](https://uts.nlm.nih.gov//license.html).
3245

docker-compose.dev.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# docker-compose development overrides
2+
---
3+
version: "3.4"
4+
services:
5+
frontend:
6+
volumes:
7+
# mount code directory into container to allow hot-reloading
8+
- ./:/opt/node/app
9+
ports:
10+
# map container port 3000 to $FRONTEND_EXTERNAL_PORT (port 3000 by default) on localhost (127.0.0.1)
11+
- 127.0.0.1:${FRONTEND_EXTERNAL_PORT:-3000}:3000

docker-compose.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
version: "3.4"
3+
services:
4+
frontend:
5+
build:
6+
context: .
7+
env_file:
8+
- frontend.env

default.env frontend.env.default

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Example docker-compose environment file
2+
# Copy to frontend.env and modify as necessary
3+
# https://docs.docker.com/compose/env-file/
14

25
#FHIR resources to load
36
#REACT_APP_FHIR_RESOURCES=Condition,Procedure,Observation,Questionnaire,QuestionnaireResponse

0 commit comments

Comments
 (0)