Files
Pygentic-AI/Dockerfile
T
fsecada01andClaude Sonnet 5.5 ebe47f0be4 ci: read private shared-packages with a GitHub App token
The image build resolves a git dependency on the private
fsecada01/shared-packages repo. Mint a short-lived, read-only GitHub App
installation token in the workflow (create-github-app-token v2.2.2, pinned
to a commit SHA) and pass it to the build as a BuildKit secret. The
Dockerfile mounts it for the python_build.sh RUN step only and points git
at it with GIT_CONFIG_* variables, so it never lands in an ARG, ENV or
image layer. The secret is optional, so builds without it still work.

Also install git in the final stage and stop persisting checkout
credentials. Fork PRs get no secrets, so the image build is only expected
to run for same-repo branches.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017F3tydTA6i18mpWhvLQv9d
2026-11-15 22:50:47 -05:00

38 lines
1.7 KiB
Docker

FROM s3docker.francissecada.com/fjs_ubuntu:latest AS intermediate
ENV PYTHONUNBUFFERED=1
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV TZ="America/New_York"
ENV LANGUAGE=en_US:en
ENV DEBIAN_FRONTEND=noninteractive
ENV WORKDIR="/opt/pygentic_ai"
COPY . ${WORKDIR}
WORKDIR ${WORKDIR}
FROM s3docker.francissecada.com/fjs_ubuntu:latest
RUN apt-get update && \
apt-get install -y curl git
ENV WORKDIR="/opt/pygentic_ai"
COPY --from=intermediate ${WORKDIR} ${WORKDIR}
WORKDIR ${WORKDIR}
RUN useradd -ms /bin/bash celery
RUN mkdir -p /tmp/log/celery && \
mkdir -p ${WORKDIR}/src/backend/logs && \
chmod 777 ${WORKDIR}/src/backend/logs && \
ln -s /run/shm /dev/shm && \
mkdir celerybeat-schedule && \
chown celery:celery celerybeat-schedule
RUN find . -name "*.sh" -exec chmod +x {} \;
RUN echo $WORKDIR
# python_build.sh resolves a private git dependency (fsecada01/shared-packages).
# The GitHub App token comes in as a BuildKit secret mounted only for this
# RUN step: it must never go in ARG/ENV, which would persist in image layers
# and history. git reads the exported GIT_CONFIG_* variables for this one RUN
# only; they are inherited by the child bash. The secret is optional so
# builds without it (e.g. local builds) still work for public dependencies.
RUN --mount=type=secret,id=gh_token,required=false if [ -s /run/secrets/gh_token ]; then export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="url.https://x-access-token:$(cat /run/secrets/gh_token)@github.com/fsecada01/shared-packages.insteadOf" GIT_CONFIG_VALUE_0="https://github.com/fsecada01/shared-packages"; fi && /bin/bash -c 'source $WORKDIR/docker/pygentic_ai/python_build.sh'
CMD /bin/bash -c 'source $WORKDIR/docker/pygentic_ai/python_start.sh'