cantremember commited on
Commit
b8b80ac
·
1 Parent(s): 10e44cc

i forgot about build secrets

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -3
  2. README.md +11 -0
Dockerfile CHANGED
@@ -19,15 +19,23 @@ COPY --chmod=0440 assets/linux/sudoers-sleepbotzz /etc/sudoers.d/sleepbotzz
19
  # User constraints
20
 
21
  # https://huggingface.co/docs/hub/spaces-sdks-docker#permissions
22
- RUN useradd -m -u 1000 -s /bin/bash -p "${BUILD_USER_PASSWORD}" sleepbotzz
23
-
 
 
 
 
 
 
24
  # password
25
  # https://askubuntu.com/questions/752500/how-do-i-encrypt-a-new-users-password-using-the-useradd-command
26
  # received as clear text from HF secrets
27
  # encrypted with $6 (SHA-512)
28
  # direct use of `python` is to avoid escaping the '$'s
29
  ARG BUILD_USER_PASSWORD
30
- RUN usermod --password \
 
 
31
  $(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)\$\"))") \
32
  sleepbotzz
33
 
 
19
  # User constraints
20
 
21
  # https://huggingface.co/docs/hub/spaces-sdks-docker#permissions
22
+ RUN useradd -m -u 1000 -s /bin/bash sleepbotzz
23
+
24
+ # secrets
25
+ # https://huggingface.co/docs/hub/spaces-sdks-docker
26
+ # https://docs.docker.com/build/building/secrets/
27
+ # https://docs.docker.com/reference/cli/docker/buildx/build/#secret
28
+ # must be provided in `docker buildx` -- "ERROR: secret BUILD_USER_PASSWORD: not found"
29
+ # precedent = ARG, secret
30
  # password
31
  # https://askubuntu.com/questions/752500/how-do-i-encrypt-a-new-users-password-using-the-useradd-command
32
  # received as clear text from HF secrets
33
  # encrypted with $6 (SHA-512)
34
  # direct use of `python` is to avoid escaping the '$'s
35
  ARG BUILD_USER_PASSWORD
36
+ RUN --mount=type=secret,id=BUILD_USER_PASSWORD,mode=0444,required=true \
37
+ export BUILD_USER_PASSWORD="${BUILD_USER_PASSWORD:-$(cat /run/secrets/BUILD_USER_PASSWORD)}" ; \
38
+ usermod --password \
39
  $(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)\$\"))") \
40
  sleepbotzz
41
 
README.md CHANGED
@@ -20,9 +20,20 @@ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-
20
  ## Notes To myself
21
 
22
  ```bash
 
 
 
23
  # vs. 'linux/arm64'
24
  docker buildx build . -t cantremember/hf-my-first-docker:latest \
25
  --platform linux/amd64 \
 
 
26
  --build-arg BUILD_USER_PASSWORD=___
 
27
  docker run -it --platform linux/amd64 cantremember/hf-my-first-docker:latest bash
28
  ```
 
 
 
 
 
 
20
  ## Notes To myself
21
 
22
  ```bash
23
+ # secret file
24
+ echo "xxx" > /tmp/BUILD_USER_PASSWORD
25
+
26
  # vs. 'linux/arm64'
27
  docker buildx build . -t cantremember/hf-my-first-docker:latest \
28
  --platform linux/amd64 \
29
+ --progress=plain --no-cache \
30
+ --secret id=BUILD_USER_PASSWORD,type=file,source=/tmp/BUILD_USER_PASSWORD \
31
  --build-arg BUILD_USER_PASSWORD=___
32
+
33
  docker run -it --platform linux/amd64 cantremember/hf-my-first-docker:latest bash
34
  ```
35
+
36
+ Secrets
37
+
38
+ - Spaces > Settings > Variables and secrets
39
+ - `BUILD_USER_PASSWORD` - Desired password for sleepbotzz user