forked from DarrenOfficial/dpaste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
57 lines (37 loc) · 1.47 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
# ------------------------------------------------
FROM python:3.6 as build
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.
RUN pip install -U pip
# 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.
CMD ./manage.py migrate --noinput && ./manage.py pyuwsgi --http=:${PORT} --logger file:/var/log/uwsgi.log
EXPOSE ${PORT}