File size: 2,609 Bytes
c178b11
 
 
c82474f
c178b11
 
 
 
 
 
 
 
 
 
 
10e44cc
c178b11
 
 
2cd84cf
0479bd7
b8b80ac
 
 
 
 
 
 
 
c178b11
 
 
 
 
 
b8b80ac
 
 
c178b11
 
 
0479bd7
 
 
 
 
 
c178b11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0479bd7
 
 
c178b11
33b734c
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
71
72
73
74
75
76
77
78
79
80
# # this was going down a rabbit-hole
# #   particularly with Apple M1 & aarch64 & QEMU
# FROM alpine:latest

# https://github.com/pytorch/serve
#FROM pytorch/pytorch
# pinned to 2.3.1,
#   also see 'assets/bootstrap'
FROM pytorch/pytorch:2.3.1-cuda11.8-cudnn8-runtime

RUN apt update && apt-get clean
RUN set -ex && \
  apt install -y  sudo && \
  apt-get clean

COPY --chmod=0440  assets/linux/sudoers-sleepbotzz /etc/sudoers.d/sleepbotzz


# User constraints

# https://huggingface.co/docs/hub/spaces-sdks-docker#permissions
RUN useradd -m -u 1000 -s /bin/bash sleepbotzz

# secrets
#   https://huggingface.co/docs/hub/spaces-sdks-docker
#   https://docs.docker.com/build/building/secrets/
#   https://docs.docker.com/reference/cli/docker/buildx/build/#secret
#   must be provided in `docker buildx` -- "ERROR: secret BUILD_USER_PASSWORD: not found"
# precedent = ARG, secret
# password
#   https://askubuntu.com/questions/752500/how-do-i-encrypt-a-new-users-password-using-the-useradd-command
#   received as clear text from HF secrets
#   encrypted with $6 (SHA-512)
#   direct use of `python` is to avoid escaping the '$'s
ARG BUILD_USER_PASSWORD
RUN --mount=type=secret,id=BUILD_USER_PASSWORD,mode=0444,required=true \
    export BUILD_USER_PASSWORD="${BUILD_USER_PASSWORD:-$(cat /run/secrets/BUILD_USER_PASSWORD)}" ; \
    usermod --password \
    $(python -c "import crypt; import os; print(crypt.crypt(os.getenv('BUILD_USER_PASSWORD'), \"\$6\$$(</dev/urandom tr -dc 'a-zA-Z0-9' | head -c 32)\$\"))") \
    sleepbotzz

USER sleepbotzz
ENV \
    HOME=/home/sleepbotzz \
    PATH=/home/sleepbotzz/.local/bin:$PATH

WORKDIR $HOME/app
COPY --chown=sleepbotzz  assets/bootstrap assets/bootstrap


# already has:  bash python3
RUN set -ex && \
  sudo apt install -y \
    vim git curl && \
  sudo apt-get clean

# already has:  conda
#RUN curl -o '/tmp/Anaconda3-2024.02-1-Linux-x86_64.sh' 'https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh'
#RUN test "$(sha256sum /tmp/Anaconda3-2024.02-1-Linux-x86_64.sh | cut -d ' ' -f 1)" = \
#  "c536ddb7b4ba738bddbd4e581b29308cb332fa12ae3fa2cd66814bd735dff231"
#
#RUN bash /tmp/Anaconda3-2024.02-1-Linux-x86_64.sh -f -b -p /usr/local/anaconda3

RUN conda init
RUN conda config --set verbosity 2 --env
RUN test "$(conda list pytorch | grep '^pytorch ' | awk -F ' ' '{ printf "%s", $2 }')" = \
  "2.3.1"
RUN conda env create -f ./assets/bootstrap/anaconda.environment.yml

#
# !!! DO NOT ADD NEW LINES ABOVE THIS POINT !!!
#


COPY --chown=sleepbotzz  assets assets


CMD [ "bash" ]
ENTRYPOINT [ "/home/sleepbotzz/app/assets/script/entrypoint.sh" ]