chrisjcc commited on
Commit
78b8ab6
Β·
verified Β·
1 Parent(s): e954f40

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -10
Dockerfile CHANGED
@@ -4,11 +4,6 @@ ARG GITHUB_USERNAME=chrisjcc
4
  ARG GITHUB_REPO_NAME=confluence-ingestor
5
  ARG WHEEL_NAME="confluence_ingestor-0.3.0-py3-none-any.whl"
6
 
7
- RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
8
- echo "Username: ${GITHUB_USERNAME}" \
9
- && echo "Repo: ${GITHUB_REPO_NAME}" \
10
- && echo "Wheel: ${WHEEL_NAME}"
11
-
12
  WORKDIR /app
13
 
14
  # Install system dependencies
@@ -33,19 +28,23 @@ RUN pip install --no-cache-dir -r requirements.txt
33
  # -----------------------------
34
  # Install private GitHub confluence-ingestor wheel using BuildKit secret
35
  # -----------------------------
 
36
  RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
37
  echo "βœ… GITHUB_TOKEN is set" \
 
38
  && echo "πŸ” Fetching release tag..." \
39
- && RELEASE_TAG=$(curl -s \
40
- -H "Authorization: token $(cat /run/secrets/GITHUB_TOKEN)" \
41
  "https://api.github.com/repos/${GITHUB_USERNAME}/${GITHUB_REPO_NAME}/releases" \
42
- | jq -r '.[0].tag_name') \
 
43
  && echo "🏷️ Release tag: ${RELEASE_TAG}" \
 
44
  && ASSET_ID=$(curl -s \
45
  -H "Authorization: token $(cat /run/secrets/GITHUB_TOKEN)" \
46
  "https://api.github.com/repos/${GITHUB_USERNAME}/${GITHUB_REPO_NAME}/releases/tags/${RELEASE_TAG}" \
47
- | jq -r '.assets[] | select(.name=="'"${WHEEL_NAME}"'") | .id') \
48
  && echo "πŸ“¦ Asset ID: ${ASSET_ID}" \
 
49
  && echo "πŸ“₯ Downloading wheel..." \
50
  && curl -fL \
51
  -H "Authorization: token $(cat /run/secrets/GITHUB_TOKEN)" \
@@ -54,7 +53,7 @@ RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
54
  "https://api.github.com/repos/${GITHUB_USERNAME}/${GITHUB_REPO_NAME}/releases/assets/${ASSET_ID}" \
55
  && echo "πŸ“¦ Installing wheel..." \
56
  && pip install --no-cache-dir /tmp/${WHEEL_NAME} \
57
- && rm -f /tmp/${WHEEL_NAME} \
58
  && echo "βœ… Installed ${WHEEL_NAME}"
59
 
60
  EXPOSE 7860
 
4
  ARG GITHUB_REPO_NAME=confluence-ingestor
5
  ARG WHEEL_NAME="confluence_ingestor-0.3.0-py3-none-any.whl"
6
 
 
 
 
 
 
7
  WORKDIR /app
8
 
9
  # Install system dependencies
 
28
  # -----------------------------
29
  # Install private GitHub confluence-ingestor wheel using BuildKit secret
30
  # -----------------------------
31
+ # SINGLE RUN with all ARGs + secret mount
32
  RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
33
  echo "βœ… GITHUB_TOKEN is set" \
34
+ && echo "πŸ” Username: ${GITHUB_USERNAME}, Repo: ${GITHUB_REPO_NAME}" \
35
  && echo "πŸ” Fetching release tag..." \
36
+ && curl -s -H "Authorization: token $(cat /run/secrets/GITHUB_TOKEN)" \
 
37
  "https://api.github.com/repos/${GITHUB_USERNAME}/${GITHUB_REPO_NAME}/releases" \
38
+ | tee /tmp/releases.json \
39
+ && RELEASE_TAG=$(cat /tmp/releases.json | jq -r 'if type == "array" and length > 0 then .[0].tag_name else "ERROR_NO_RELEASES" end') \
40
  && echo "🏷️ Release tag: ${RELEASE_TAG}" \
41
+ && if [ "$RELEASE_TAG" = "ERROR_NO_RELEASES" ]; then exit 1; fi \
42
  && ASSET_ID=$(curl -s \
43
  -H "Authorization: token $(cat /run/secrets/GITHUB_TOKEN)" \
44
  "https://api.github.com/repos/${GITHUB_USERNAME}/${GITHUB_REPO_NAME}/releases/tags/${RELEASE_TAG}" \
45
+ | jq -r ".assets[] | select(.name==\"${WHEEL_NAME}\") | .id") \
46
  && echo "πŸ“¦ Asset ID: ${ASSET_ID}" \
47
+ && if [ -z "$ASSET_ID" ] || [ "$ASSET_ID" = "null" ]; then echo "❌ No asset found"; exit 1; fi \
48
  && echo "πŸ“₯ Downloading wheel..." \
49
  && curl -fL \
50
  -H "Authorization: token $(cat /run/secrets/GITHUB_TOKEN)" \
 
53
  "https://api.github.com/repos/${GITHUB_USERNAME}/${GITHUB_REPO_NAME}/releases/assets/${ASSET_ID}" \
54
  && echo "πŸ“¦ Installing wheel..." \
55
  && pip install --no-cache-dir /tmp/${WHEEL_NAME} \
56
+ && rm -f /tmp/${WHEEL_NAME} /tmp/releases.json \
57
  && echo "βœ… Installed ${WHEEL_NAME}"
58
 
59
  EXPOSE 7860