diff --git a/.gitignore b/.gitignore index 7753c3c2..274b54c5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ # database *.sqlite3 +# docker +docker.env + # npm folder /node_modules diff --git a/Dockerfile b/Dockerfile index 8a0b7c3f..1dfcbfe9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,16 +5,15 @@ ADD package-lock.json /build/ RUN npm install RUN npm install -g gulp-cli ADD gulpfile.js /build/gulpfile.js -ADD api /app/api -ADD babybuddy /app/babybuddy -ADD core /app/core -ADD dashboard /app/dashboard -ADD reports /app/reports +ADD api /build/api +ADD babybuddy /build/babybuddy +ADD core /build/core +ADD dashboard /build/dashboard +ADD reports /build/reports RUN gulp build FROM python:3 as app -ENV PYTHONUNBUFFERED 1 RUN pip install --upgrade pipenv gunicorn WORKDIR /app COPY Pipfile /app/ @@ -26,9 +25,5 @@ ADD babybuddy /app/babybuddy ADD core /app/core ADD dashboard /app/dashboard ADD reports /app/reports -ENV DJANGO_SETTINGS_MODULE babybuddy.settings.development -ENV SECRET_KEY TODOCHANGEME COPY --from=build /build/babybuddy/static /app/babybuddy/static -RUN python manage.py collectstatic --no-input -RUN python manage.py migrate ADD etc/gunicorn.py /app/ diff --git a/babybuddy/settings/docker.py b/babybuddy/settings/docker.py index 7e98ccc8..655fcea9 100644 --- a/babybuddy/settings/docker.py +++ b/babybuddy/settings/docker.py @@ -3,13 +3,15 @@ import os from .base import * # noqa: F401,F403 -DEBUG = os.environ.get('DEBUG', False) - - -# SECURITY WARNING: keep the secret key used in production secret! +# Production settings +# See babybuddy.settings.base for additional settings information. SECRET_KEY = os.environ.get('SECRET_KEY') +ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') + +DEBUG = os.environ.get('DEBUG', False) + # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases diff --git a/docker-compose.yml b/docker-compose.yml index 07bf8171..f94a38a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,9 +4,10 @@ services: db: image: postgres web: + env_file: docker.env build: . command: gunicorn -c /app/gunicorn.py babybuddy.wsgi ports: - "8000:8000" depends_on: - - db + - db \ No newline at end of file diff --git a/docker.env.example b/docker.env.example new file mode 100644 index 00000000..79ba552f --- /dev/null +++ b/docker.env.example @@ -0,0 +1,4 @@ +ALLOWED_HOSTS= +DJANGO_SETTINGS_MODULE=babybuddy.settings.docker +PYTHONUNBUFFERED=1 +SECRET_KEY= \ No newline at end of file