-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
70 lines (60 loc) · 1.86 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
# syntax=docker/dockerfile:1
# Build Command
# export DOCKER_BUILDKIT=1; docker buildx build -t chimefrb/workflow:latest .
ARG PYTHON_VERSION=3.10
FROM python:${PYTHON_VERSION}-slim as base
# Setup Environment Variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=true \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/opt/workflow" \
VENV_PATH="/opt/workflow/.venv" \
DEBIAN_FRONTEND=noninteractive \
OPENMP_ENABLED=1
# prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
# Setup Shell for the Docker Image
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
FROM base as builder
# Install system dependencies
RUN set -ex \
&& apt-get update -yqq \
&& apt-get install --no-install-recommends -yqq \
curl \
ssh \
gnupg \
lsb-release \
# Cleanup
&& apt-get autoremove -yqq --purge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* \
&& rm -rf /var/tmp/* \
&& rm -rf /usr/share/man \
&& rm -rf /usr/share/doc \
&& rm -rf /usr/share/doc-base \
# Setup SSH for Github Access
&& mkdir -p ~/.ssh \
&& touch ~/.ssh/known_hosts \
&& chmod 0600 ~/.ssh/known_hosts ~/.ssh \
&& ssh-keyscan github.com >> ~/.ssh/known_hosts
# Install Poetry
RUN set -ex \
&& pip install --upgrade pip poetry --no-cache-dir
# Copy Project Files
COPY . $PYSETUP_PATH
WORKDIR $PYSETUP_PATH
# Install Project Dependencies
RUN set -ex \
&& poetry install --without dev --no-interaction --no-ansi --no-cache -v
# Final Image
FROM base as production
COPY --from=builder $VENV_PATH $VENV_PATH
COPY --from=builder $PYSETUP_PATH $PYSETUP_PATH
ENTRYPOINT [ "/opt/workflow/entrypoint.sh" ]
CMD ["workflow"]