-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (38 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
54 lines (38 loc) · 1.13 KB
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
ARG PYTHON_VERSION=3.11
#
# Base image
#
FROM python:${PYTHON_VERSION}-slim-bookworm AS base
ARG DOCKER_USER=bob
ARG DOCKER_GROUP=bob
# Add normal user that will use the container
RUN set -ex; addgroup --gid 1000 ${DOCKER_GROUP} && \
adduser --ingroup ${DOCKER_GROUP} --uid 1000 --disabled-password ${DOCKER_USER}
# Create app directory
RUN mkdir /app && \
chown -R ${DOCKER_USER}:${DOCKER_GROUP} /app
# Set working directory
WORKDIR /app
# Add pip installed binary directory to PATH
ENV PATH="/home/${DOCKER_USER}/.local/bin:${PATH}"
# Run as normal user
USER ${DOCKER_USER}
#
# Dev image
#
FROM base AS dev
# Add fix-perm.sh script to image
USER 0
COPY ./fix-perm.sh /fix-perm.sh
RUN chmod +x /fix-perm.sh
USER ${DOCKER_USER}
# Set entrypoint so the container will run without doing anything
ENTRYPOINT ["/bin/sleep", "infinity"]
FROM base AS dist
#
# Image with torch-cpu library installed
#
FROM base AS torch-cpu
ARG TORCH_VERSION
# Install torch cpu
RUN pip install --prefix "/home/${DOCKER_USER}/.local" --no-cache-dir --disable-pip-version-check torch==${TORCH_VERSION} --index-url https://download.pytorch.org/whl/cpu