qbhf2 commited on
Commit
9fc5909
·
verified ·
1 Parent(s): 39c45d5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -13
Dockerfile CHANGED
@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive
5
 
6
  # System deps for Blender GUI-less rendering + runtime fetch tools
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
- ca-certificates wget curl bzip2 xz-utils git rsync \
9
  libglib2.0-0 libx11-6 libxi6 libxxf86vm1 libxrender1 libxfixes3 \
10
  libxkbcommon0 libxrandr2 libasound2 libxinerama1 libsm6 libice6 \
11
  libgl1 libegl1 libglu1-mesa libdbus-1-3 libxcb1 \
@@ -31,15 +31,16 @@ RUN /opt/blender-${BLENDER_VERSION}-linux-x64/${BLENDER_MAJOR}/python/bin/python
31
  # -------- Working dir where repo will be extracted --------
32
  WORKDIR /srv/app
33
 
34
- # -------- Startup script that downloads your PRIVATE GitHub repo and runs app.py --------
35
- # Expects Space settings:
36
- # Secret: GIT_TOKEN (GitHub PAT with repo read access)
37
- # Variable: GIT_REPO (e.g. chaous/render)
38
- # Variable: GIT_REF (optional, default "main"; branch/tag/commit)
39
- # Variable: GIT_SUBDIR(optional, if app.py is not at repo root)
40
  RUN printf '%s\n' \
41
  '#!/usr/bin/env bash' \
42
  'set -euo pipefail' \
 
43
  '' \
44
  'export BLENDER_BIN="${BLENDER_BIN:-blender}"' \
45
  'TARGET_ROOT="/srv/app"' \
@@ -52,13 +53,33 @@ RUN printf '%s\n' \
52
  ' exit 1' \
53
  'fi' \
54
  '' \
55
- 'echo "[info] Fetching ${REPO}@${REF}..."' \
56
- 'ARCHIVE_URL="https://api.github.com/repos/${REPO}/tarball/${REF}"' \
57
- 'wget -q --header="Authorization: Bearer ${GIT_TOKEN}" -O /tmp/repo.tar.gz "${ARCHIVE_URL}"' \
 
 
 
 
 
 
58
  '' \
59
- 'rm -rf "${TARGET_ROOT:?}/"*' \
60
- 'tar -xzf /tmp/repo.tar.gz -C "${TARGET_ROOT}" --strip-components=1' \
61
- 'rm -f /tmp/repo.tar.gz' \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  '' \
63
  'if [[ -n "${SUBDIR}" ]]; then' \
64
  ' if [[ -d "${TARGET_ROOT}/${SUBDIR}" ]]; then' \
 
5
 
6
  # System deps for Blender GUI-less rendering + runtime fetch tools
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
+ ca-certificates wget curl bzip2 xz-utils git rsync bash \
9
  libglib2.0-0 libx11-6 libxi6 libxxf86vm1 libxrender1 libxfixes3 \
10
  libxkbcommon0 libxrandr2 libasound2 libxinerama1 libsm6 libice6 \
11
  libgl1 libegl1 libglu1-mesa libdbus-1-3 libxcb1 \
 
31
  # -------- Working dir where repo will be extracted --------
32
  WORKDIR /srv/app
33
 
34
+ # -------- Startup script: download private repo then run app.py --------
35
+ # Required Space settings:
36
+ # Secret: GIT_TOKEN (PAT with repo read access)
37
+ # Variable: GIT_REPO (e.g. chaous/render OR https://github.com/chaous/render.git)
38
+ # Variable: GIT_REF (optional, default "main"; branch/tag/commit)
39
+ # Variable: GIT_SUBDIR (optional, if app.py is not at repo root)
40
  RUN printf '%s\n' \
41
  '#!/usr/bin/env bash' \
42
  'set -euo pipefail' \
43
+ 'export GIT_TERMINAL_PROMPT=0' \
44
  '' \
45
  'export BLENDER_BIN="${BLENDER_BIN:-blender}"' \
46
  'TARGET_ROOT="/srv/app"' \
 
53
  ' exit 1' \
54
  'fi' \
55
  '' \
56
+ 'fetch_github_tarball() {' \
57
+ ' local owner="$1"; local name="$2"; local ref="$3"' \
58
+ ' echo "[info] Downloading github.com/${owner}/${name}@${ref} tarball..."' \
59
+ ' local ARCHIVE_URL="https://api.github.com/repos/${owner}/${name}/tarball/${ref}"' \
60
+ ' wget -q --header="Authorization: token ${GIT_TOKEN}" -O /tmp/repo.tar.gz "${ARCHIVE_URL}"' \
61
+ ' rm -rf "${TARGET_ROOT:?}/"*' \
62
+ ' tar -xzf /tmp/repo.tar.gz -C "${TARGET_ROOT}" --strip-components=1' \
63
+ ' rm -f /tmp/repo.tar.gz' \
64
+ '}' \
65
  '' \
66
+ 'echo "[info] Fetching ${REPO}@${REF}..."' \
67
+ 'if [[ "${REPO}" == *"://"* ]]; then' \
68
+ ' # URL form' \
69
+ ' if [[ "${REPO}" == *"github.com"* ]]; then' \
70
+ ' path="${REPO#*github.com/}"; path="${path%.git}"' \
71
+ ' owner="${path%%/*}"; name="${path#*/}"; name="${name%%/*}"' \
72
+ ' fetch_github_tarball "${owner}" "${name}" "${REF}"' \
73
+ ' else' \
74
+ ' echo "[info] Non-GitHub host detected; using git clone."' \
75
+ ' rm -rf "${TARGET_ROOT:?}/"*' \
76
+ ' git -c http.extraHeader="Authorization: Bearer ${GIT_TOKEN}" clone --depth 1 --branch "${REF}" "${REPO}" "${TARGET_ROOT}"' \
77
+ ' fi' \
78
+ 'else' \
79
+ ' # owner/repo form' \
80
+ ' owner="${REPO%%/*}"; name="${REPO#*/}"' \
81
+ ' fetch_github_tarball "${owner}" "${name}" "${REF}"' \
82
+ 'fi' \
83
  '' \
84
  'if [[ -n "${SUBDIR}" ]]; then' \
85
  ' if [[ -d "${TARGET_ROOT}/${SUBDIR}" ]]; then' \