Skip to content

Commit d531a7e

Browse files
authored
Merge pull request #38 from tushar5526/dockerize
Dockerize workflow
2 parents 7f168dc + bc1849d commit d531a7e

File tree

25 files changed

+29774
-96
lines changed

25 files changed

+29774
-96
lines changed

.env

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,42 @@ DATABASE_PASSWORD=hkaLBM3RVnyYeYeqE3WI1w2e4Avpy0Wd5O3s3
55
ES_JAVA_OPTS="-Xms512m -Xmx512m"
66
FUSIONAUTH_APP_MEMORY=512M
77

8+
#minio
89
MINIO_USERNAME=workflow-dev
910
MINIO_PASSWORD=workflow-dev
1011
MINIO_BUCKETNAME=affiliationbucket
1112

1213
# central envs
1314
CENTRAL_USER_EMAIL=chakshu@samagragovernance.in
14-
CENTRAL_USER_PASS=StrongPassword@1234
15+
CENTRAL_USER_PASS=StrongPassword@1234
16+
17+
#enketo-express
18+
ENCRYPTION_KEY=somestrongencrytionkey
19+
LESS_SECURE_ENCRYPTION_KEY=ssssomestrongencrytionkey
20+
FORM_MANAGER_BASE_URI=IP:PORT_OF_DEPLOYED_INSTANCE
21+
22+
# form manager
23+
FORM_MANAGER_URL=http://form-manager:3006
24+
MINIO_URL=IP:PORT_OF_DEPLOYED_MINIO
25+
MINIO_ENDPOINT=minio
26+
MINIO_PORT=9000
27+
REDIS_HOST=fm-cache
28+
MINIO_USE_SSL=false
29+
REDIS_PORT=6379
30+
31+
# TSDB
32+
TSDB_POSTGRES_USER=timescaledb
33+
TSDB_POSTGRES_PASSWORD=postgrespassword
34+
35+
# GQL
36+
HASURA_GRAPHQL_ADMIN_SECRET=myadminsecretkey
37+
HASURA_GRAPHQL_JWT_SECRET={"type":"RS256","jwk_url":"http://fusionauth:9011/.well-known/jwks.json"}
38+
HASURA_GRAPHQL_DATABASE_URL=postgres://$TSDB_POSTGRES_USER:$TSDB_POSTGRES_PASSWORD@tsdb:5432/postgres?sslmode=disable
39+
40+
#react wrapper
41+
# http://service-name is not going to work as we are building a static build
42+
# and serving it through nginx
43+
# use actual IP address instead
44+
REACT_APP_ENKETO_URL=https://8065-tushar5526-workflow-0qffaj3egws.ws-us93.gitpod.io
45+
REACT_APP_FORM_MANAGER_URL=https://3006-tushar5526-workflow-0qffaj3egws.ws-us93.gitpod.io
46+
REACT_APP_HASURA_URL=https://8080-tushar5526-workflow-0qffaj3egws.ws-us93.gitpod.io

.gitpod.yml

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,25 @@ tasks:
1414
init: |
1515
gp sync-done dev-setup
1616
bash install-central.sh
17-
- name: Setup Enketo Express
17+
- name: Start Services
1818
openMode: tab-after
1919
init: |
2020
gp sync-done dev-setup
21-
bash install-node.sh
22-
nvm use 14
23-
cd packages/enketo-express && pnpm i && pnpm i -g grunt
24-
bash update-config.sh
21+
# Not needed now, we can use docker-compose networking.. but one can use this in a script to repalce env vars at runtime in .env
22+
# sed -i~ "/^FORM_MANAGER_URL=/s/=.*/=https\:\/\/3006-${GITPOD_WORKSPACE_URL:8}/" .env
23+
sed -i~ "/^MINIO_URL=/s/=.*/=https\:\/\/9000-${GITPOD_WORKSPACE_URL:8}/" .env
24+
# sed -i~ "/^MINIO_ENDPOINT=/s/=.*/=9000-${GITPOD_WORKSPACE_URL:8}/" .env
25+
# sed -i~ "/^MINIO_PORT=/s/=.*/=80/" .env
26+
# sed -i~ "/^MINIO_USE_SSL=/s/=.*/=true/" .env
27+
# Replace env vars for react wrapper
28+
sed -i~ "/^REACT_APP_ENKETO_URL=/s/=.*/=https\:\/\/8065-${GITPOD_WORKSPACE_URL:8}/" .env
29+
sed -i~ "/^REACT_APP_FORM_MANAGER_URL=/s/=.*/=https\:\/\/3006-${GITPOD_WORKSPACE_URL:8}/" .env
30+
sed -i~ "/^REACT_APP_HASURA_URL=/s/=.*/=https\:\/\/8080-${GITPOD_WORKSPACE_URL:8}/" .env
31+
# for enketo-express
32+
sed -i~ "/^FORM_MANAGER_BASE_URI=/s/=.*/=https\:\/\/3006-${GITPOD_WORKSPACE_URL:8}/" .env
33+
34+
docker-compose up -d
2535
gp sync-done setup
26-
command: |
27-
grunt develop
28-
- name: Setup Form Manager
29-
openMode: tab-after
30-
init: |
31-
gp sync-await setup
32-
source .env
33-
docker run --name enketo-redis-main -p 6369:6379 -d redis
34-
cd packages/form-manager
35-
echo "MINIO_USERNAME=$MINIO_USERNAME" >> .env
36-
echo "MINIO_PASSWORD=$MINIO_PASSWORD" >> .env
37-
echo "MINIO_BUCKETNAME=$MINIO_BUCKETNAME" >> .env
38-
nvm use 16
39-
pnpm install
40-
command: |
41-
npm run start:dev
42-
- name: Setup React Wrapper
43-
openMode: tab-after
44-
init: |
45-
gp sync-await setup
46-
cd apps/wrapper
47-
nvm use 16
48-
pnpm install
49-
bash make-envs-for-react.sh
50-
command: |
51-
npm run start
5236
5337
ports:
5438
- port: 8065

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,10 @@ TODO: Add details on the specifications
221221
## Possible Attack Vectors
222222
1. XSS (High Priority) - Simple form
223223
2. SQL Injection (High Priority) - needs to be fixed.
224+
225+
NOTE:
226+
-----
227+
```
228+
For local development enketo-express needs node 14 and pnpm@7
229+
Run nvm use 14 && npm i -g pnpm@7 if developing in enketo-express
230+
```

apps/wrapper/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

apps/wrapper/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#get the latest alpine image from node registry
2+
FROM node:16-alpine AS build-stage
3+
RUN npm i -g pnpm
4+
#set the working directory
5+
WORKDIR /app
6+
7+
#copy the package and package lock files
8+
#from local to container work directory /app
9+
COPY package.json /app/
10+
COPY pnpm-lock.yaml /app/
11+
12+
#Run command npm install to install packages
13+
RUN pnpm install
14+
15+
#copy all the folder contents from local to container
16+
COPY . .
17+
18+
#specify env variables at runtime
19+
ARG REACT_APP_ENKETO_URL
20+
ARG REACT_APP_FORM_MANAGER_URL
21+
ARG REACT_APP_HASURA_URL
22+
23+
ENV REACT_APP_ENKETO_URL $REACT_APP_ENKETO_URL
24+
ENV REACT_APP_FORM_MANAGER_URL $REACT_APP_FORM_MANAGER_URL
25+
ENV REACT_APP_HASURA_URL $REACT_APP_HASURA_URL
26+
27+
28+
#create a react production build
29+
RUN npm run build
30+
31+
#get the latest alpine image from nginx registry
32+
FROM nginx:alpine
33+
34+
#we copy the output from first stage that is our react build
35+
#into nginx html directory where it will serve our index file
36+
COPY --from=build-stage /app/build/ /usr/share/nginx/html

apps/wrapper/make-envs-for-react.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)