-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #545 from OpenSRP/runtime-configuration
Dockerize web app
- Loading branch information
Showing
12 changed files
with
350 additions
and
91 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,17 @@ | ||
**/*.db | ||
**/.env | ||
**/.env.development.local | ||
**/.env.local | ||
**/.env.production.local | ||
**/.env.test.local | ||
**/.git* | ||
**/.waypoint | ||
**/build | ||
**/dist | ||
**/node_modules | ||
**/npm-debug.log | ||
.dckerignore | ||
Dockerfile | ||
README.md | ||
docs | ||
waypoint.hcl |
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ build | |
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
*.db | ||
|
||
debug.log* | ||
npm-debug.log* | ||
|
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,70 @@ | ||
FROM alpine/git AS sources | ||
|
||
RUN git clone --depth=1 --branch=config-sessions https://github.com/onaio/express-server.git /usr/src/express-server | ||
|
||
FROM node:14.9.0-alpine as build | ||
|
||
COPY ./ /project | ||
|
||
WORKDIR /project | ||
ENV PATH /project/node_modules/.bin:$PATH | ||
|
||
RUN chown -R node . | ||
USER node | ||
|
||
RUN cp /project/app/.env.sample /project/app/.env \ | ||
&& yarn | ||
|
||
USER root | ||
RUN chown -R node . | ||
USER node | ||
RUN yarn lerna:prepublish | ||
|
||
FROM node:14.9.0-alpine as nodejsbuild | ||
COPY --from=sources /usr/src/express-server /usr/src/express-server | ||
|
||
WORKDIR /usr/src/express-server | ||
RUN yarn && yarn tsc && npm prune -production | ||
RUN yarn add lodash && npm prune -production | ||
|
||
# Remove unused dependencies | ||
RUN rm -rf ./node_modules/typescript | ||
|
||
FROM node:14.9.0-alpine as final | ||
|
||
# Use tini for NodeJS application https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#handling-kernel-signals | ||
RUN apk add --no-cache tini curl | ||
|
||
# confd | ||
RUN curl -sSL -o /usr/local/bin/confd https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64 \ | ||
&& chmod +x /usr/local/bin/confd | ||
|
||
COPY ./docker/confd_env.toml /etc/confd/conf.d/appconfig.toml | ||
COPY ./docker/config.js.tmpl /etc/confd/templates/config.js.tmpl | ||
|
||
COPY ./docker/app.sh /usr/local/bin/app.sh | ||
RUN chmod +x /usr/local/bin/app.sh | ||
|
||
WORKDIR /usr/src/web | ||
|
||
COPY --from=build /project/node_modules /usr/src/web/node_modules | ||
COPY --from=build /project/app/build /usr/src/web | ||
|
||
RUN chown -R node /usr/src/web | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY --from=nodejsbuild /usr/src/express-server/dist /usr/src/app | ||
COPY --from=nodejsbuild /usr/src/express-server/node_modules /usr/src/app/node_modules | ||
|
||
RUN chown -R node /usr/src/app | ||
|
||
USER node | ||
|
||
ENV EXPRESS_REACT_BUILD_PATH /usr/src/web/ | ||
|
||
EXPOSE 3000 | ||
|
||
CMD [ "/bin/sh", "-c", "/usr/local/bin/app.sh && node ." ] | ||
|
||
ENTRYPOINT ["/sbin/tini", "--"] |
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 @@ | ||
window._env_ = {}; |
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
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
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,7 @@ | ||
services: | ||
web: | ||
build: . | ||
ports: | ||
- "3000:3000" | ||
environment: | ||
- "API_URL=production.example.com" |
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,8 @@ | ||
#!/bin/sh | ||
# vim:sw=4:ts=4:et | ||
|
||
set -e | ||
|
||
confd -onetime -backend env | ||
sed -i "s/CONFIG_VERSION/`date '+%s'`/" /usr/src/web/index.html | ||
sed -i "s/Redirected path should match configured path/Redirected path ' + Url.parse(options.redirectUri).pathname + 'should match configured path/" /usr/src/web/node_modules/client-oauth2/src/client-oauth2.js |
Oops, something went wrong.