forked from saleor/saleor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
72 lines (57 loc) · 1.87 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
### Build and install packages
FROM python:3.6 as build-python
RUN apt-get -y update \
&& apt-get install -y gettext \
# Cleanup apt cache
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
RUN pip install pipenv
COPY Pipfile Pipfile.lock /app/
WORKDIR /app
RUN pipenv install --system --deploy --dev
### Build static assets
FROM node:10 as build-nodejs
ARG STATIC_URL
ENV STATIC_URL ${STATIC_URL:-/static/}
# Install node_modules
COPY webpack.config.js app.json package.json package-lock.json tsconfig.json tslint.json webpack.d.ts /app/
WORKDIR /app
RUN npm install
# Build static
COPY ./remote_works/static /app/remote_works/static/
COPY ./templates /app/templates/
RUN STATIC_URL=${STATIC_URL} npm run build-assets --production \
&& npm run build-emails --production
### Final image
FROM python:3.6-slim
ARG STATIC_URL
ENV STATIC_URL ${STATIC_URL:-/static/}
RUN groupadd -r remote_works && useradd -r -g remote_works remote_works
RUN apt-get update \
&& apt-get install -y \
libxml2 \
libssl1.1 \
libcairo2 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libgdk-pixbuf2.0-0 \
shared-mime-info \
mime-support \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY . /app
COPY --from=build-python /usr/local/lib/python3.6/site-packages/ /usr/local/lib/python3.6/site-packages/
COPY --from=build-python /usr/local/bin/ /usr/local/bin/
COPY --from=build-nodejs /app/remote_works/static /app/remote_works/static
COPY --from=build-nodejs /app/webpack-bundle.json /app/
COPY --from=build-nodejs /app/templates /app/templates
WORKDIR /app
RUN SECRET_KEY=dummy STATIC_URL=${STATIC_URL} python3 manage.py collectstatic --no-input
RUN mkdir -p /app/media /app/static \
&& chown -R remote_works:remote_works /app/
EXPOSE 8000
ENV PORT 8000
ENV PYTHONUNBUFFERED 1
ENV PROCESSES 4
CMD ["uwsgi", "--ini", "/app/remote_works/wsgi/uwsgi.ini"]