2019-12-07 21:37:30 +11:00
|
|
|
|
FROM node:lts as staticfiles
|
|
|
|
|
|
|
|
|
|
ARG BUILD_EXTRAS=production
|
|
|
|
|
|
|
|
|
|
RUN echo "\nℹ️ Building staticfiles with "${BUILD_EXTRAS}" dependencies.\n"
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Install the JS dependencies
|
|
|
|
|
COPY package.json package-lock.json Makefile ./
|
|
|
|
|
|
|
|
|
|
RUN if [ "$BUILD_EXTRAS" = "dev" ] ; then npm install --ignore-scripts ; else npm ci --ignore-scripts ; fi
|
|
|
|
|
|
|
|
|
|
# Copy the client/ directory and compile them. The Python application
|
|
|
|
|
# doesn't need to exist yet.
|
|
|
|
|
COPY client ./client
|
|
|
|
|
|
|
|
|
|
RUN mkdir -p dpaste/static
|
|
|
|
|
RUN make css
|
|
|
|
|
RUN make js
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------
|
|
|
|
|
|
2022-08-18 02:18:48 +10:00
|
|
|
|
FROM python:3.10 as build
|
2019-12-07 21:37:30 +11:00
|
|
|
|
|
|
|
|
|
ARG BUILD_EXTRAS=production
|
|
|
|
|
|
|
|
|
|
ENV PORT=8000
|
|
|
|
|
|
|
|
|
|
RUN echo "\nℹ️ Building Django project with "${BUILD_EXTRAS}" dependencies.\n"
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Upgrade pip, the Image one is quite old.
|
2020-01-08 23:12:28 +11:00
|
|
|
|
RUN pip install -U pip
|
2019-12-07 21:37:30 +11:00
|
|
|
|
|
|
|
|
|
# Copy the dpaste staticfiles to this image
|
|
|
|
|
COPY --from=staticfiles /app /app/
|
|
|
|
|
|
|
|
|
|
# Copy only the files necessary to install the dpaste project as an editable
|
|
|
|
|
# package. This improves caching.
|
|
|
|
|
COPY setup.py setup.cfg ./
|
|
|
|
|
COPY dpaste/__init__.py dpaste/
|
|
|
|
|
RUN pip install -e .[${BUILD_EXTRAS}]
|
|
|
|
|
|
|
|
|
|
# Copy the rest of the application code
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# Collect all static files once.
|
|
|
|
|
RUN ./manage.py collectstatic --noinput
|
|
|
|
|
|
|
|
|
|
# By default run it with pyuwsgi, which is a great production ready
|
|
|
|
|
# server. For development, docker-compose will override it to use the
|
|
|
|
|
# regular Django runserver.
|
2019-12-07 22:21:04 +11:00
|
|
|
|
CMD ./manage.py migrate --noinput && ./manage.py pyuwsgi --http=:${PORT} --logger file:/var/log/uwsgi.log
|
2019-12-07 21:37:30 +11:00
|
|
|
|
|
|
|
|
|
EXPOSE ${PORT}
|