2022-03-04 12:13:31 +00:00
|
|
|
FROM python:3.9-slim
|
2019-09-12 11:43:27 +00:00
|
|
|
|
|
|
|
# Install packages needed to run your application (not build deps):
|
|
|
|
# We need to recreate the /usr/share/man/man{1..8} directories first because
|
|
|
|
# they were clobbered by a parent image.
|
|
|
|
RUN set -ex \
|
|
|
|
&& RUN_DEPS=" \
|
|
|
|
libexpat1 \
|
|
|
|
libjpeg62-turbo \
|
|
|
|
libpcre3 \
|
|
|
|
libpq5 \
|
|
|
|
mime-support \
|
|
|
|
postgresql-client \
|
2019-10-04 19:46:28 +00:00
|
|
|
procps \
|
2019-09-12 11:43:27 +00:00
|
|
|
zlib1g \
|
|
|
|
" \
|
|
|
|
&& seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} \
|
|
|
|
&& apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2017-02-18 01:43:58 +00:00
|
|
|
|
|
|
|
ADD requirements/ /requirements/
|
|
|
|
RUN set -ex \
|
2019-09-12 11:43:27 +00:00
|
|
|
&& BUILD_DEPS=" \
|
|
|
|
build-essential \
|
2019-07-20 22:29:11 +00:00
|
|
|
git \
|
2019-09-12 11:43:27 +00:00
|
|
|
libexpat1-dev \
|
|
|
|
libjpeg62-turbo-dev \
|
|
|
|
libpcre3-dev \
|
|
|
|
libpq-dev \
|
|
|
|
zlib1g-dev \
|
|
|
|
" \
|
|
|
|
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
|
2022-03-04 12:13:31 +00:00
|
|
|
&& python3.9 -m venv /venv \
|
2019-07-20 22:29:11 +00:00
|
|
|
&& /venv/bin/pip install -U pip \
|
2019-09-12 11:43:27 +00:00
|
|
|
&& /venv/bin/pip install --no-cache-dir -r /requirements/production.txt \
|
|
|
|
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2017-02-18 01:43:58 +00:00
|
|
|
RUN mkdir /code/
|
|
|
|
WORKDIR /code/
|
|
|
|
ADD . /code/
|
2023-02-03 11:06:01 +00:00
|
|
|
ENV PORT 8000
|
2017-02-18 01:43:58 +00:00
|
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
# Add custom environment variables needed by Django or your settings file here:
|
|
|
|
ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off
|
|
|
|
|
|
|
|
# Call collectstatic with dummy environment variables:
|
|
|
|
RUN DATABASE_URL=postgres://none REDIS_URL=none /venv/bin/python manage.py collectstatic --noinput
|
|
|
|
|
2017-04-15 14:26:46 +00:00
|
|
|
# make sure static files are writable by uWSGI process
|
2019-10-04 21:33:17 +00:00
|
|
|
RUN mkdir -p /code/bakerydemo/media/images && chown -R 1000:2000 /code/bakerydemo/media
|
2017-04-15 14:26:46 +00:00
|
|
|
|
2019-09-12 11:43:27 +00:00
|
|
|
# mark the destination for images as a volume
|
|
|
|
VOLUME ["/code/bakerydemo/media/images/"]
|
|
|
|
|
2017-02-18 01:43:58 +00:00
|
|
|
# start uWSGI, using a wrapper script to allow us to easily add more commands to container startup:
|
|
|
|
ENTRYPOINT ["/code/docker-entrypoint.sh"]
|
2019-09-12 11:43:27 +00:00
|
|
|
|
|
|
|
# Start uWSGI
|
2023-02-03 11:06:01 +00:00
|
|
|
CMD ["/venv/bin/uwsgi", "/code/etc/uwsgi.ini"]
|