Skip to content

Commit 5be50fd

Browse files
committed
Dockerize wrapper and fix env vars in wrapper
1 parent ea4f0da commit 5be50fd

File tree

10 files changed

+10311
-23
lines changed

10 files changed

+10311
-23
lines changed

.env

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ ENCRYPTION_KEY=somestrongencrytionkey
1919
LESS_SECURE_ENCRYPTION_KEY=ssssomestrongencrytionkey
2020

2121
# form manager
22-
FORM_MANAGER_URL=https://3006-tushar5526-workflow-fnu74wzypyq.ws-us93.gitpod.io
23-
MINIO_URL=https://9000-tushar5526-workflow-fnu74wzypyq.ws-us93.gitpod.io
22+
FORM_MANAGER_URL=http://form-manager:3006
23+
MINIO_URL=http://minio:9000
2424
MINIO_ENDPOINT=minio
2525
MINIO_PORT=9000
2626
REDIS_HOST=fm-cache
@@ -36,3 +36,7 @@ HASURA_GRAPHQL_ADMIN_SECRET=myadminsecretkey
3636
HASURA_GRAPHQL_JWT_SECRET={"type":"RS256","jwk_url":"http://fusionauth:9011/.well-known/jwks.json"}
3737
HASURA_GRAPHQL_DATABASE_URL=postgres://$TSDB_POSTGRES_USER:$TSDB_POSTGRES_PASSWORD@tsdb:5432/postgres?sslmode=disable
3838

39+
#react wrapper
40+
REACT_APP_ENKETO_URL=http://enketo-express:8065
41+
REACT_APP_FORM_MANAGER_URL=http://form-manager:3006
42+
REACT_APP_HASURA_URL=http://gql:8080

.gitpod.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,18 @@ tasks:
1818
openMode: tab-after
1919
init: |
2020
gp sync-done dev-setup
21-
sed -i~ "/^FORM_MANAGER_URL=/s/=.*/=https\:\/\/3006-${GITPOD_WORKSPACE_URL:8}/" .env
22-
sed -i~ "/^MINIO_URL=/s/=.*/=https\:\/\/9000-${GITPOD_WORKSPACE_URL:8}/" .env
23-
sed -i~ "/^MINIO_ENDPOINT=/s/=.*/=9000-${GITPOD_WORKSPACE_URL:8}/" .env
24-
sed -i~ "/^MINIO_PORT=/s/=.*/=80/" .env
25-
sed -i~ "/^MINIO_USE_SSL=/s/=.*/=true/" .env
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+
# sed -i~ "/^REACT_APP_ENKETO_URL=/s/=.*/=https\:\/\/8065-${GITPOD_WORKSPACE_URL:8}/" .env
28+
# sed -i~ "/^REACT_APP_FORM_MANAGER_URL=/s/=.*/=https\:\/\/3006-${GITPOD_WORKSPACE_URL:8}/" .env
29+
# sed -i~ "/^REACT_APP_HASURA_URL=/s/=.*/=https\:\/\/8080-${GITPOD_WORKSPACE_URL:8}/" .env
30+
2631
docker-compose up -d
2732
gp sync-done setup
28-
- name: Setup React Wrapper
29-
openMode: tab-after
30-
init: |
31-
gp sync-await setup
32-
cd apps/wrapper
33-
nvm use 16
34-
pnpm install
35-
bash make-envs-for-react.sh
36-
command: |
37-
npm run start
3833
3934
ports:
4035
- 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)