chrisjcc's picture
Made GITHUB_TOKEN variable reusable
6146778
Raw
History Blame Contribute Delete
2.12 kB
FROM python:3.10-slim
ARG GITHUB_USERNAME=chrisjcc
ARG GITHUB_REPO_NAME=confluence-ingestor
ARG WHEEL_NAME="confluence_ingestor-0.3.0-py3-none-any.whl"
WORKDIR /app
# Install system dependencies
RUN apt-get update --allow-releaseinfo-change \
&& apt-get install -y --no-install-recommends \
curl unzip git jq \
&& rm -rf /var/lib/apt/lists/*
# -----------------------------
# Copy ALL application code first
# -----------------------------
COPY . .
# -----------------------------
# Update pip
# -----------------------------
RUN pip install --upgrade pip
# Install other dependencies
RUN pip install --no-cache-dir -r requirements.txt
# -----------------------------
# Install private GitHub confluence-ingestor wheel using BuildKit secret
# -----------------------------
RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) \
&& echo "βœ… GITHUB_TOKEN set (length: ${#GITHUB_TOKEN})" \
&& echo "πŸ” Fetching latest release..." \
&& curl -s -L -H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${GITHUB_USERNAME}/${GITHUB_REPO_NAME}/releases/latest" \
| tee /tmp/release.json \
&& ASSET_URL=$(cat /tmp/release.json | jq -r '.assets[0].url // empty') \
&& echo "πŸ“₯ Downloading from GitHub API asset URL: ${ASSET_URL}" \
&& curl -s -L \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Accept: application/octet-stream" \
-o /tmp/${WHEEL_NAME} \
"${ASSET_URL}" \
&& echo "πŸ“ Downloaded file size: $(ls -lh /tmp/${WHEEL_NAME})" \
&& if [ ! -s /tmp/${WHEEL_NAME} ]; then echo "❌ Empty wheel file"; exit 1; fi \
&& echo "πŸ”§ Installing wheel..." \
&& pip install --no-cache-dir --verbose /tmp/${WHEEL_NAME} \
&& python -c "import confluence_ingestor; print('βœ“ confluence_ingestor import OK')" \
&& pip list | grep confluence || echo "βœ… Installation verified" \
&& rm /tmp/*.*
EXPOSE 7860
# -----------------------------
# Entrypoint
# -----------------------------
CMD ["python", "app.py"]