-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.build
55 lines (38 loc) · 1.4 KB
/
Dockerfile.build
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
FROM python:3.12-slim as base
ARG TORCHLITE_VERSION
ENV TORCHLITE_PORT 8000
ENV TORCHLITE_VERSION "${TORCHLITE_VERSION:-0.0.0}"
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
ENV PYTHONFAULTHANDLER 1
ENV PYTHONHASHSEED random
ENV PIP_NO_CACHE_DIR 1
RUN apt update && apt -y install dumb-init && rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip
RUN useradd -ms /bin/bash torchlite
WORKDIR /home/torchlite
FROM base as builder
ENV PIP_DEFAULT_TIMEOUT 100
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PIPX_BIN_DIR /usr/local/bin
ENV POETRY_VERSION 1.8.3
ENV POETRY_VIRTUALENVS_IN_PROJECT true
ENV POETRY_DYNAMIC_VERSIONING_BYPASS true
RUN pip install --upgrade pipx && pipx install "poetry==$POETRY_VERSION"
COPY poetry.lock pyproject.toml README.* ./
COPY htrc ./htrc
RUN poetry install --no-interaction --no-ansi --no-root --only=main --sync \
&& poetry version "$TORCHLITE_VERSION" \
&& poetry build --format=wheel
FROM base as final
ENV PATH ".local/bin:$PATH"
COPY --chown=torchlite:torchlite --from=builder /home/torchlite/dist .
COPY --chown=torchlite:torchlite docker-entrypoint.sh .
COPY --chown=torchlite:torchlite log_conf.yaml .
USER torchlite
RUN pip install *.whl && rm -f *.whl
EXPOSE $TORCHLITE_PORT
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["./docker-entrypoint.sh"]