Environmental variables, nginx templates

pull/332/head
Piero Toffanin 2017-11-16 19:19:19 -05:00
rodzic 68fd2da296
commit a2b8267cd5
8 zmienionych plików z 37 dodań i 6 usunięć

3
.env 100644
Wyświetl plik

@ -0,0 +1,3 @@
HOST=webodm.localhost
PORT=8000
APP_MEDIA_DIR=appmedia

1
.gitignore vendored
Wyświetl plik

@ -93,3 +93,4 @@ node_modules/
webpack-stats.json
pip-selfcheck.json
.idea/
package-lock.json

Wyświetl plik

@ -27,7 +27,7 @@ RUN printf "deb http://mirror.steadfast.net/debian/ stable main contrib n
RUN printf "deb http://mirror.steadfast.net/debian/ testing main contrib non-free\ndeb-src http://mirror.steadfast.net/debian/ testing main contrib non-free" > /etc/apt/sources.list.d/testing.list
# Install GDAL, nginx
RUN apt-get update && apt-get install -t testing -y binutils libproj-dev gdal-bin nginx
RUN apt-get update && apt-get install -t testing -y binutils libproj-dev gdal-bin nginx gettext-base
WORKDIR /webodm/nodeodm/external/node-OpenDroneMap
RUN npm install

Wyświetl plik

@ -19,9 +19,12 @@ services:
container_name: webapp
entrypoint: /bin/bash -c "chmod +x /webodm/*.sh && /bin/bash -c \"/webodm/wait-for-it.sh db:5432 -- /webodm/start.sh\""
volumes:
- appmedia:/webodm/app/media
- ${MEDIA_DIR}:/webodm/app/media
ports:
- "8000:8000"
- "${PORT}:8000"
depends_on:
- db
environment:
- PORT
- HOST
restart: on-failure:10

2
nginx/.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1,2 @@
ssl/
*.conf

Wyświetl plik

@ -31,8 +31,7 @@ http {
listen 8000 deferred;
client_max_body_size 0;
# set the correct host(s) for your site
server_name webodm.localhost;
server_name $HOST;
keepalive_timeout 5;

Wyświetl plik

@ -74,7 +74,19 @@ if [ "$1" = "--setup-devenv" ] || [ "$2" = "--setup-devenv" ] || [ "$1" = "--no-
else
if [ -e /webodm ] && [ ! -e /webodm/build/static ]; then
echo -e "\033[91mWARN:\033[39m /webodm/build/static does not exist, CSS, JS and other files might not be available."
fi
fi
# If this is invoked outside docker, we need to make sure
# envsubst returns a valid config file...
export HOST="${HOST:=webodm.localhost}"
echo "Generating nginx configurations from templates..."
for templ in nginx/*.template
do
echo "- $templ"
envsubst '\$HOST \$OTHER_VAR' < $templ > ${templ%.*}
done
nginx -c $(pwd)/nginx/nginx.conf
gunicorn webodm.wsgi --bind unix:/tmp/gunicorn.sock --timeout 360 --preload
fi

Wyświetl plik

@ -16,6 +16,11 @@ if [[ $platform = "Windows" ]]; then
export COMPOSE_CONVERT_WINDOWS_PATHS=1
fi
# Set default ENV variables
export PORT="${WEBODM_PORT:=8000}"
export HOST="${WEBODM_HOST:=webodm.localhost}"
export MEDIA_DIR="${WEBODM_MEDIA_DIR:=appmedia}"
usage(){
echo "Usage: $0 <command> [options]"
echo
@ -121,6 +126,12 @@ resetpassword(){
if [[ $1 = "start" ]]; then
environment_check
echo "Starting WebODM..."
echo -e "Host: \033[92m\033[1m$PORT\033[0m\033[39m"
echo -e "Port: \033[92m\033[1m$HOST\033[0m\033[39m"
echo -e "Media dir: \033[92m\033[1m$HOST\033[0m\033[39m"
start
elif [[ $1 = "stop" ]]; then
environment_check