This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
forked from kobotoolbox/enketo-express
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
294 additions
and
93 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,6 @@ | ||
Dockerfile | ||
node_modules | ||
docker-compose.yml | ||
setup/docker/envfile.txt | ||
setup/docker/secrets | ||
|
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 |
---|---|---|
@@ -1,35 +1,44 @@ | ||
FROM ubuntu:trusty | ||
FROM phusion/baseimage:latest | ||
|
||
EXPOSE 8005 | ||
CMD ["bash", "/srv/enketo-express/setup/docker/entrypoint.bash"] | ||
ENV ENKETO_SRC_DIR=/srv/src/enketo_express | ||
|
||
################ | ||
# apt installs # | ||
################ | ||
|
||
WORKDIR /srv | ||
# Install Node. | ||
ADD https://deb.nodesource.com/setup_4.x /tmp/ | ||
RUN bash /tmp/setup_4.x | ||
|
||
COPY ./setup/docker/apt_requirements.txt ${ENKETO_SRC_DIR}/setup/docker/ | ||
WORKDIR ${ENKETO_SRC_DIR}/ | ||
RUN apt-get update && \ | ||
apt-get upgrade -y | ||
RUN apt-get install -y curl && \ | ||
curl -sL https://deb.nodesource.com/setup_4.x | bash - | ||
COPY ./setup/docker/apt_packages.txt /srv/ | ||
RUN apt-get install -y $(cat apt_packages.txt) | ||
apt-get upgrade -y && \ | ||
apt-get install -y $(cat setup/docker/apt_requirements.txt) && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# Non-interactive equivalent of `dpkg-reconfigure -plow unattended-upgrades` (see https://blog.sleeplessbeastie.eu/2015/01/02/how-to-perform-unattended-upgrades/). | ||
RUN cp /usr/share/unattended-upgrades/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades | ||
|
||
|
||
############################### | ||
# Enketo Express Installation # | ||
############################### | ||
|
||
RUN npm install -g grunt-cli pm2 | ||
# Checks out a fresh copy of the repo. | ||
RUN git clone https://github.com/enketo/enketo-express.git | ||
WORKDIR /srv/enketo-express | ||
RUN npm cache clean &&\ | ||
npm install | ||
COPY ./package.json ${ENKETO_SRC_DIR}/ | ||
RUN npm install --production | ||
|
||
COPY . ${ENKETO_SRC_DIR} | ||
ENV PATH $PATH:${KPI_SRC_DIR}/node_modules/.bin | ||
|
||
# Persist the `secrets` directory so the encryption key remains consistent. | ||
RUN mkdir -p /srv/enketo-express/setup/docker/secrets | ||
VOLUME /srv/enketo-express/setup/docker/secrets | ||
RUN mkdir -p ${ENKETO_SRC_DIR}/setup/docker/secrets | ||
VOLUME ${ENKETO_SRC_DIR}/setup/docker/secrets | ||
|
||
# Prepare for execution. | ||
RUN ln -s "${ENKETO_SRC_DIR}/setup/docker/01_setup_enketo.bash" /etc/my_init.d/ && \ | ||
mkdir -p /etc/service/enketo_express && \ | ||
ln -s "${ENKETO_SRC_DIR}/setup/docker/run_enketo.bash" /etc/service/enketo_express/run | ||
|
||
|
||
EXPOSE 8005 |
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 was deleted.
Oops, something went wrong.
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,14 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
source /etc/profile | ||
|
||
cd ${ENKETO_SRC_DIR}/ | ||
|
||
# Create a config. file if necessary. | ||
python setup/docker/create_config.py | ||
|
||
# Build. | ||
grunt | ||
# FIXME: Now that the client config. has been built, build again as a workaround to a `grunt` task sequencing issue. | ||
grunt |
File renamed without changes.
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,43 @@ | ||
nginx: | ||
image: nginx | ||
links: | ||
- enketo_express | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
env_file: | ||
- ./envfile.txt | ||
volumes: | ||
- ./nginx/:/tmp/enketo_express_nginx/:ro | ||
- ./secrets/:/tmp/enketo_express_secrets/:ro | ||
- ../../config/:/srv/src/enketo_express/config/ | ||
command: bash /tmp/enketo_express_nginx/nginx_command.bash | ||
restart: always | ||
|
||
enketo_express: | ||
# image: kobotoolbox/enketo_express | ||
build: ../.. | ||
links: | ||
- redis_main | ||
- redis_cache | ||
env_file: | ||
- ./envfile.txt | ||
volumes: | ||
- ../../config/:/srv/src/enketo_express/config | ||
- ./secrets/:/srv/src/enketo_express/setup/docker/secrets/ | ||
restart: always | ||
|
||
redis_main: | ||
image: redis:2.6 | ||
# Map our "main" Redis config into the container. | ||
volumes: | ||
- ../redis/conf/redis-enketo-main.conf:/etc/redis/redis.conf:ro | ||
- ./redis_main_data/:/data/ | ||
restart: always | ||
|
||
redis_cache: | ||
image: redis:2.6 | ||
# Map our "cache" Redis config into the container. | ||
volumes: | ||
- ../redis/conf/redis-enketo-cache.conf:/etc/redis/redis.conf:ro | ||
restart: always |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,15 +1,6 @@ | ||
# Necessary variable. | ||
ENKETO_API_KEY= | ||
|
||
# Optional variables (and their default values). | ||
#ENKETO_OFFLINE_SURVEYS=True | ||
#ENKETO_FORM_DATA_SERVER_URL=kobocat | ||
#ENKETO_REDIS_MAIN_HOST=redis_main | ||
#ENKETO_REDIS_MAIN_PORT=6379 | ||
#ENKETO_REDIS_MAIN_PASSWORD= | ||
#ENKETO_REDIS_CACHE_HOST=redis_cache | ||
#ENKETO_REDIS_CACHE_PORT=6379 | ||
#ENKETO_REDIS_CACHE_PASSWORD= | ||
# Required, if not specified in `config/config.json`. | ||
#ENKETO_API_KEY= | ||
|
||
# Autogenerated if missing. | ||
#ENKETO_ENCRYPTION_KEY= | ||
|
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,13 @@ | ||
# `envsubst` template. | ||
# Context: server | ||
|
||
# When using a root URI prefix, redirect requests to the new root that aren't terminated with a '/'. | ||
${INCLUDE_ROOT_URI_REDIRECT} | ||
|
||
location ${ROOT_URI} { | ||
include /tmp/enketo_express_nginx/enketo_express_proxy_pass.conf; | ||
|
||
# FIXME: Remove once Enketo Express is relocatable. | ||
# Optionally include rules for rewriting root-relative references in the response. | ||
${INCLUDE_REWRITE_RULES} | ||
} |
7 changes: 7 additions & 0 deletions
7
setup/docker/nginx/enketo_express_location_uri_prefix.conf.tmpl
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 @@ | ||
# `envsubst` template. | ||
# Context: server | ||
|
||
# Redirect requests not terminated with a '\'. | ||
location /${ENKETO_EXPRESS_URI_PREFIX} { | ||
return 301 $scheme://$http_host/${ENKETO_EXPRESS_URI_PREFIX}/; | ||
} |
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 @@ | ||
# Context: location | ||
|
||
proxy_pass http://enketo_express:8005/; | ||
proxy_redirect off; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr ; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ; | ||
proxy_set_header X-Forwarded-Proto https ; |
14 changes: 14 additions & 0 deletions
14
setup/docker/nginx/enketo_express_rewrite_response_reference_rules.conf.tmpl
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,14 @@ | ||
# `envsubst` template. | ||
# Context: location | ||
|
||
# Rewrite root-relative references in the response. | ||
proxy_set_header Accept-Encoding ""; # No GZip. | ||
sub_filter_once off; | ||
sub_filter_types text/html text/css application/javascript application/json; | ||
sub_filter 'href="/' 'href="/${ENKETO_EXPRESS_URI_PREFIX}/'; | ||
sub_filter 'src="/' 'src="/${ENKETO_EXPRESS_URI_PREFIX}/'; | ||
sub_filter 'src: url("/' 'src: url("/${ENKETO_EXPRESS_URI_PREFIX}/'; | ||
sub_filter 'url:"/' 'url:"/${ENKETO_EXPRESS_URI_PREFIX}/'; | ||
sub_filter '="/transform/xform' '="/${ENKETO_EXPRESS_URI_PREFIX}/transform/xform'; | ||
sub_filter '="/connection' '="/${ENKETO_EXPRESS_URI_PREFIX}/connection'; | ||
sub_filter '/_/#' '/${ENKETO_EXPRESS_URI_PREFIX}/_/#'; |
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 @@ | ||
# Context: http | ||
|
||
server { | ||
listen 80; | ||
|
||
include /tmp/nginx_templates_enabled/enketo_express_location.conf; | ||
} |
Oops, something went wrong.