Browse Source

Cleanup build process. Disable debug build by default

master
Joshua Rubingh 2 months ago
parent
commit
0727fad678
  1. 1
      VRE/requirements.txt
  2. 12
      docker-compose.yaml
  3. 25
      docker/Dockerfile.api
  4. 20
      docker/Dockerfile.scheduler
  5. 2
      docker/project.example.env

1
VRE/requirements.txt

@ -7,6 +7,7 @@ psycopg2-binary==2.9.2
# Tasks
redis==4.0.0
hiredis==2.0.0
huey==2.4.1
# Django Rest Framework

12
docker-compose.yaml

@ -40,7 +40,7 @@ services:
# DOCKER_CACHE: registry.webhosting.rug.nl/cache/library/
dockerfile: ./docker/Dockerfile.api
args:
DEBUG: true
DEBUG: "False"
command: gunicorn VRE.wsgi:application --bind 0.0.0.0:8000 --workers=4
ports:
- 8000:8000
@ -87,6 +87,8 @@ services:
# args:
# DOCKER_CACHE: registry.webhosting.rug.nl/cache/library/
dockerfile: ./docker/Dockerfile.scheduler
args:
DEBUG: "False"
command: python manage.py run_huey
depends_on:
- broker-api
@ -94,7 +96,7 @@ services:
- redis
volumes:
postgres-data:
redis-data:
staticfiles:
mediafiles:
postgres-data: null
redis-data: null
staticfiles: null
mediafiles: null

25
docker/Dockerfile.api

@ -7,15 +7,19 @@ FROM ${DOCKER_CACHE}python:3.8
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV DEBIAN_FRONTEND=noninteractive
ENV APP_HOME=/opt/VRE
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Update packages and install nc for database up detection
RUN apt-get update && apt-get -y full-upgrade && apt-get install -y netcat
ARG DEBUG=false
RUN if [ "$DEBUG" = "true" ] ; then apt-get install -y graphviz libgraphviz-dev; fi
# Create an app user in the app group.
RUN useradd --user-group --create-home --no-log-init --shell /bin/bash app
ENV APP_HOME=/home/app/web
ARG DEBUG="False"
ENV DEBUG="${DEBUG}"
RUN if [ "$DEBUG" = "True" ] ; then apt-get install -y graphviz libgraphviz-dev; fi
# Create a logfile dir... not sure if this is the right way
RUN mkdir -p ${APP_HOME}/../log
@ -37,18 +41,13 @@ RUN pip install --upgrade pip wheel
# Install the requirements.
RUN pip install --no-cache-dir -r requirements.txt
RUN if [ "$DEBUG" = "True" ] ; then pip install --no-cache-dir -r requirements-dev.txt; fi
# Startup script when the image is starting up with
COPY ./docker/entrypoint.api.sh ${APP_HOME}/entrypoint.api.sh
RUN chmod +x ${APP_HOME}/entrypoint.api.sh
# fix file rights
RUN chown -R app:app $APP_HOME/../
# Run as user (this will not work with Drones testing)
#USER app:app
# ENTRYPOINT does not work with variables..?? (${APP_HOME})
ENTRYPOINT ["/home/app/web/entrypoint.api.sh"]
ENTRYPOINT ["/opt/VRE/entrypoint.api.sh"]
# Strange exit errors....
#ENTRYPOINT ["sh","-c","${APP_HOME}/entrypoint.api.sh"]

20
docker/Dockerfile.scheduler

@ -7,12 +7,19 @@ FROM ${DOCKER_CACHE}python:3.8
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV DEBIAN_FRONTEND=noninteractive
ENV APP_HOME=/opt/VRE
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Update packages and install nc for database up detection
RUN apt-get update && apt-get -y full-upgrade
# Create an app user in the app group.
RUN useradd --user-group --create-home --no-log-init --shell /bin/bash app
ENV APP_HOME=/home/app/web
ARG DEBUG="False"
ENV DEBUG="${DEBUG}"
RUN if [ "$DEBUG" = "True" ] ; then apt-get install -y graphviz libgraphviz-dev; fi
# Create a logfile dir... not sure if this is the right way
RUN mkdir -p ${APP_HOME}/../log
@ -28,9 +35,4 @@ RUN pip install --upgrade pip wheel
# Install the requirements.
RUN pip install --no-cache-dir -r requirements.txt
# fix file rights
RUN chown -R app:app $APP_HOME/../
# Run as user (this will not work with Drones testing)
#USER app:app
RUN if [ "$DEBUG" = "True" ] ; then pip install --no-cache-dir -r requirements-dev.txt; fi

2
docker/project.example.env

@ -27,7 +27,7 @@ SECRET_KEY=@wb=#(f4uc0l%e!5*eo+aoflnxb(@!l9!=c5w=4b+x$=!8&vy%'
# Disable debug in production
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG=True
DEBUG=False
# Allowed hosts that Django does server. Use comma separated list Take care when NGINX is proxying in front of Django
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts

Loading…
Cancel
Save