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 webpack-stats.json
pip-selfcheck.json pip-selfcheck.json
.idea/ .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 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 # 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 WORKDIR /webodm/nodeodm/external/node-OpenDroneMap
RUN npm install RUN npm install

Wyświetl plik

@ -19,9 +19,12 @@ services:
container_name: webapp container_name: webapp
entrypoint: /bin/bash -c "chmod +x /webodm/*.sh && /bin/bash -c \"/webodm/wait-for-it.sh db:5432 -- /webodm/start.sh\"" entrypoint: /bin/bash -c "chmod +x /webodm/*.sh && /bin/bash -c \"/webodm/wait-for-it.sh db:5432 -- /webodm/start.sh\""
volumes: volumes:
- appmedia:/webodm/app/media - ${MEDIA_DIR}:/webodm/app/media
ports: ports:
- "8000:8000" - "${PORT}:8000"
depends_on: depends_on:
- db - db
environment:
- PORT
- HOST
restart: on-failure:10 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; listen 8000 deferred;
client_max_body_size 0; client_max_body_size 0;
# set the correct host(s) for your site server_name $HOST;
server_name webodm.localhost;
keepalive_timeout 5; keepalive_timeout 5;

Wyświetl plik

@ -74,7 +74,19 @@ if [ "$1" = "--setup-devenv" ] || [ "$2" = "--setup-devenv" ] || [ "$1" = "--no-
else else
if [ -e /webodm ] && [ ! -e /webodm/build/static ]; then 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." 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 nginx -c $(pwd)/nginx/nginx.conf
gunicorn webodm.wsgi --bind unix:/tmp/gunicorn.sock --timeout 360 --preload gunicorn webodm.wsgi --bind unix:/tmp/gunicorn.sock --timeout 360 --preload
fi fi

Wyświetl plik

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