-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.prod
52 lines (41 loc) · 1.76 KB
/
Dockerfile.prod
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
######## YARN BUILD CONTAINER
FROM node:alpine AS yarn_build
RUN apk update && apk upgrade && apk --update add yarn
WORKDIR /code
COPY . /code
RUN yarn build_prod
####### LIBS ONLY CONTAINER
FROM python:3.6.4-alpine3.7 as libs_only
COPY --from=lifeloopweb /usr/lib /temp_lib
RUN mkdir /libs_only
# If anything is "omitted" by the copy command (which is ok) the exit code isn't 0
RUN cp -d /temp_lib/lib* /libs_only; true
######## FINAL CONTAINER
FROM python:3.6.4-alpine3.7
# Copy the code in
WORKDIR /code
COPY --from=lifeloopweb /code/lifeloopweb/ /code/lifeloopweb
ADD docker/web_entrypoint.sh /code
COPY --from=lifeloopweb /code/lifeloopweb.egg-info/ /code/lifeloopweb.egg-info
COPY --from=yarn_build /code/lifeloopweb/build/ /code/lifeloopweb/build/
# Get Dockerize
COPY --from=lifeloopweb /usr/local/bin/dockerize /usr/local/bin/dockerize
# Copy bins we need
COPY --from=lifeloopweb /usr/local/bin/flask /usr/local/bin/flask
COPY --from=lifeloopweb /usr/local/bin/lifeloop_db_manage /usr/local/bin/lifeloop_db_manage
# Copy over installed python packages
COPY --from=lifeloopweb /usr/local/lib/python3.6/site-packages/ /usr/local/lib/python3.6/site-packages/
# Copy shared libs
#
# How this Works:
#
# * Copies the entire /usr/lib dir out of the dev images to a temp container
# * Runs a command inside the container to copy all the shared libs
# into another path but not recurse
# * Builds the prod container by referring to the temporary copy container
# This little song and dance ends up saving 150MB in the prod container
# We also can't do it solely in the prod container as space can't be saved
# by running an rm. The layer containing the lib files we don't need remains
# attached to the container
COPY --from=lifeloopweb /lib /lib
COPY --from=libs_only /libs_only /usr/lib