FROM ubuntu:18.04 # Copy the code ADD . /code WORKDIR /code # install deps RUN apt-get update && apt-get install -y gcc libmariadbclient-dev python3-dev python3-pip && \ pip3 install --no-cache-dir -r requirements.txt && \ apt-get remove -y gcc && apt-get autoremove -y # configure django ENV DJANGO_SETTINGS_MODULE=settings # configure uwsgi ENV UWSGI_WSGI_FILE=wsgi.py UWSGI_HTTP=:8000 UWSGI_MASTER=1 UWSGI_WORKERS=2 UWSGI_THREADS=8 UWSGI_UID=1000 UWSGI_GID=2000 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy # collect static files RUN python3 manage.py collectstatic #### POSTGRES RUN \ apt -y install \ curl \ rsync \ cron \ postgresql postgresql-contrib \ sudo \ && mkdir -p /mnt/save \ && service postgresql start USER postgres RUN service postgresql start \ && psql --command "CREATE USER ss WITH SUPERUSER PASSWORD 'ss';" \ && psql --command "CREATE DATABASE silverstrikedb;" \ && psql --command "GRANT ALL PRIVILEGES ON DATABASE silverstrikedb TO ss;" USER root ENV ALLOWED_HOSTS=* ENV DATABASE_URL=postgres://ss:ss@localhost/silverstrikedb ENV SECRET_KEY=AimmBfzjdWcVN3rQs8YawbUowv5R8Eex CMD service postgresql start && (until psql $DATABASE_URL < /dev/null; do sleep 5; done) && python3 manage.py migrate && uwsgi