qbhf2 commited on
Commit
06721eb
·
verified ·
1 Parent(s): 56092f8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -15
Dockerfile CHANGED
@@ -3,13 +3,12 @@ FROM python:3.11-slim-bookworm
3
 
4
  ENV DEBIAN_FRONTEND=noninteractive
5
 
6
- # System deps for Blender GUI-less rendering
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
- ca-certificates wget bzip2 xz-utils \
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 \
12
- git curl \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
  # Grab a local copy of model-viewer so we can inline it (no external script loads)
@@ -38,13 +37,13 @@ RUN pip install --no-cache-dir -r requirements.txt
38
  COPY app.py render.py /app/
39
 
40
  # -------- Runtime bootstrap to pull private repo safely --------
41
- # Expects:
42
- # - Secret: GIT_TOKEN
43
- # - Variable: GIT_REPO (e.g. owner/private-repo)
44
- # - Variable: GIT_REF (optional, default "main")
45
- # - Variable: GIT_SUBDIR (optional, e.g. "apps/serviceA")
46
  RUN set -eux; \
47
- cat > /usr/local/bin/start.sh << 'EOF'; \
48
  #!/usr/bin/env bash
49
  set -euo pipefail
50
 
@@ -58,7 +57,7 @@ REF="${GIT_REF:-main}"
58
  SUBDIR="${GIT_SUBDIR:-}"
59
 
60
  use_bundled_fallback() {
61
- echo "[info] Using bundled /app fallback (no private repo configured)."
62
  rsync -a /app/ "${TARGET_ROOT}/"
63
  cd "${TARGET_ROOT}"
64
  exec python app.py
@@ -71,8 +70,7 @@ fi
71
  echo "[info] Downloading ${REPO}@${REF} tarball from GitHub..."
72
  ARCHIVE_URL="https://api.github.com/repos/${REPO}/tarball/${REF}"
73
 
74
- # Download without leaking token into image layers (runtime only)
75
- # Token is passed in header; -q to avoid verbose logs
76
  if ! wget -q --header="Authorization: Bearer ${GIT_TOKEN}" -O /tmp/repo.tar.gz "${ARCHIVE_URL}"; then
77
  echo "[warn] Download failed; falling back to bundled app."
78
  use_bundled_fallback
@@ -83,15 +81,16 @@ rm -rf "${TARGET_ROOT:?}/"*
83
  tar -xzf /tmp/repo.tar.gz -C "${TARGET_ROOT}" --strip-components=1
84
  rm -f /tmp/repo.tar.gz
85
 
 
86
  if [[ -n "${SUBDIR}" ]]; then
87
  if [[ -d "${TARGET_ROOT}/${SUBDIR}" ]]; then
88
  TARGET_ROOT="${TARGET_ROOT}/${SUBDIR}"
89
  else
90
- echo "[warn] GIT_SUBDIR=${SUBDIR} not found in repo; continuing from repo root."
91
  fi
92
  fi
93
 
94
- # If the repo ships its own requirements, install them now
95
  if [[ -f "${TARGET_ROOT}/requirements.txt" ]]; then
96
  echo "[info] Installing repo requirements..."
97
  pip install --no-cache-dir -r "${TARGET_ROOT}/requirements.txt"
@@ -99,7 +98,7 @@ fi
99
 
100
  cd "${TARGET_ROOT}"
101
 
102
- # Basic sanity check
103
  if [[ ! -f "app.py" ]]; then
104
  echo "[warn] app.py not found in repo path; falling back to bundled app."
105
  use_bundled_fallback
 
3
 
4
  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 rsync git \
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 \
 
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
  # Grab a local copy of model-viewer so we can inline it (no external script loads)
 
37
  COPY app.py render.py /app/
38
 
39
  # -------- Runtime bootstrap to pull private repo safely --------
40
+ # Expects Space settings:
41
+ # Secret: GIT_TOKEN
42
+ # Variable: GIT_REPO (e.g. owner/private-repo)
43
+ # Variable: GIT_REF (optional, default "main")
44
+ # Variable: GIT_SUBDIR (optional, if app.py not at repo root)
45
  RUN set -eux; \
46
+ cat > /usr/local/bin/start.sh << 'EOF'
47
  #!/usr/bin/env bash
48
  set -euo pipefail
49
 
 
57
  SUBDIR="${GIT_SUBDIR:-}"
58
 
59
  use_bundled_fallback() {
60
+ echo "[info] Using bundled /app fallback (no private repo configured or fetch failed)."
61
  rsync -a /app/ "${TARGET_ROOT}/"
62
  cd "${TARGET_ROOT}"
63
  exec python app.py
 
70
  echo "[info] Downloading ${REPO}@${REF} tarball from GitHub..."
71
  ARCHIVE_URL="https://api.github.com/repos/${REPO}/tarball/${REF}"
72
 
73
+ # Download using header auth; avoid printing token
 
74
  if ! wget -q --header="Authorization: Bearer ${GIT_TOKEN}" -O /tmp/repo.tar.gz "${ARCHIVE_URL}"; then
75
  echo "[warn] Download failed; falling back to bundled app."
76
  use_bundled_fallback
 
81
  tar -xzf /tmp/repo.tar.gz -C "${TARGET_ROOT}" --strip-components=1
82
  rm -f /tmp/repo.tar.gz
83
 
84
+ # Optional subdir
85
  if [[ -n "${SUBDIR}" ]]; then
86
  if [[ -d "${TARGET_ROOT}/${SUBDIR}" ]]; then
87
  TARGET_ROOT="${TARGET_ROOT}/${SUBDIR}"
88
  else
89
+ echo "[warn] GIT_SUBDIR='${SUBDIR}' not found; continuing from repo root."
90
  fi
91
  fi
92
 
93
+ # Install repo-specific deps if present
94
  if [[ -f "${TARGET_ROOT}/requirements.txt" ]]; then
95
  echo "[info] Installing repo requirements..."
96
  pip install --no-cache-dir -r "${TARGET_ROOT}/requirements.txt"
 
98
 
99
  cd "${TARGET_ROOT}"
100
 
101
+ # Sanity check
102
  if [[ ! -f "app.py" ]]; then
103
  echo "[warn] app.py not found in repo path; falling back to bundled app."
104
  use_bundled_fallback