Created
April 14, 2018 21:36
-
-
Save dfcarpenter/15246c80ec6d76516b3a3922028c0a5f to your computer and use it in GitHub Desktop.
django dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.6-stretch as python-base | |
COPY webpack requirements.txt package.json yarn.lock ./ | |
RUN set -ex \ | |
&& apt-get update \ | |
&& apt-get install apt-transport-https \ | |
&& apt-get update \ | |
&& apt-get install --no-install-recommends -y \ | |
libpq-dev curl libjpeg-dev rsync libsass-dev libicu57 zlib1g-dev libpng-dev libmagickwand-dev \ | |
python3-dev libjpeg-progs optipng postgresql-client | |
RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - \ | |
&& apt-get update && apt-get install --no-install-recommends -y nodejs \ | |
&& npm install npm@latest -g | |
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ | |
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ | |
&& apt-get update && apt-get install -y yarn | |
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg \ | |
&& mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg \ | |
&& echo "deb [arch=amd64] https://packages.microsoft.com/debian/stretch/prod stretch main" > /etc/apt/sources.list.d/dotnetdev.list \ | |
&& apt-get update \ | |
&& apt-get install -y dotnet-runtime-2.0.5 dotnet-sdk-2.1.4 | |
RUN wget -O azcopy.tar.gz https://aka.ms/downloadazcopyprlinux \ | |
&& tar -xf azcopy.tar.gz \ | |
&& chmod +x ./install.sh \ | |
&& ./install.sh | |
RUN pip install -U pip \ | |
&& pip install -r ./requirements.txt | |
WORKDIR /app/ | |
ADD . /app/ | |
RUN yarn install && yarn build-prod | |
RUN azcopy --source /app/assets/dist/ \ | |
--destination [REMOVED] \ | |
--dest-key [REMOVED] \ | |
--recursive --set-content-type --quiet | |
FROM python:3.6-slim-stretch | |
RUN set -ex \ | |
&& apt-get update \ | |
&& apt-get install --no-install-recommends -y build-essential python-dev | |
COPY --from=python-base /root/.cache /root/.cache | |
COPY --from=python-base requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt && rm -rf /root/.cache \ | |
&& apt autoremove -y | |
WORKDIR /app/ | |
ADD . /app/ | |
COPY --from=python-base /app/webpack-stats-prod.json /app/webpack-stats-prod.json | |
ENV DJANGO_SETTINGS_MODULE=config.settings.dev | |
ENV DJANGO_MANAGEPY_MIGRATE="off" | |
ENV DJANGO_MANAGEPY_COLLECTSTATIC="off" | |
RUN chmod +x /app/docker-entrypoint.sh | |
EXPOSE 8000 | |
ENTRYPOINT ["/app/docker-entrypoint.sh"] | |
CMD ["uwsgi", "global_portal.ini", "--http-auto-chunked", "--http-keepalive"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment