-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
52 lines (32 loc) · 1.19 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
# syntax = docker/dockerfile:latest
ARG PYTHON_VERSION=3.8
ARG WHEELDIR=/opt/python${PYTHON_VERSION}/wheels/
# --- Setup build environment
FROM python:${PYTHON_VERSION}-slim as base
ARG WHEELDIR
WORKDIR /laminar
RUN --mount=type=cache,mode=0755,target=/var/cache/apt \
--mount=type=cache,mode=0755,target=/var/lib/apt \
--mount=type=cache,mode=0755,target=/root/.cache/pip \
apt-get update \
&& apt-get upgrade -y \
&& apt-get clean \
&& python -m pip install --upgrade pip wheel
# --- Build laminar package wheels
FROM base as builder
COPY . ./
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
python -m pip wheel --wheel-dir ${WHEELDIR} .
# --- Install laminar packages from wheels
FROM python:3.8-slim as test
ARG WHEELDIR
WORKDIR /laminar
COPY --from=builder ${WHEELDIR} ${WHEELDIR}
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
python -m pip install --no-index --find-links=${WHEELDIR} laminar \
&& rm -rf ${WHEELDIR}
COPY main.py ./
# --- Create laminar release image
FROM base as release
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
python -m pip install laminar