-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
43 lines (30 loc) · 1.13 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
FROM condaforge/mambaforge AS build
COPY environment.yml /my-model/environment.yml
RUN conda install -c conda-forge conda-pack && \
conda env create -f /my-model/environment.yml
# Use conda-pack to create a enviornment in /venv:
RUN conda-pack -n my-model -o /tmp/env.tar && \
mkdir /venv && cd /venv && tar xf /tmp/env.tar && \
rm /tmp/env.tar
# No longer need conda, just the packed python
FROM debian:buster AS runtime
# provide version from Docker build args
ARG VERSION
ENV version=$VERSION
ENV PATH="${PATH}:/venv/bin"
# Copy /venv from the previous stage:
COPY --from=build /venv /venv
COPY . /my-model
SHELL ["/bin/bash", "-c"]
# Fix paths, will be same in final image so this is fine
RUN source /venv/bin/activate && \
/venv/bin/conda-unpack
COPY _entrypoint.sh /usr/local/bin/_entrypoint.sh
COPY my_model/flow.py /opt/prefect/flow.py
RUN chmod +x /usr/local/bin/_entrypoint.sh
RUN source /venv/bin/activate && \
python -m pip install /my-model
# When image is run, run the code with the environment
# activated:
SHELL ["/usr/local/bin/_entrypoint.sh", "/bin/bash", "-c"]
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"]