Update Dockerfile
Browse files- Dockerfile +16 -15
Dockerfile
CHANGED
|
@@ -11,7 +11,7 @@ RUN apt-get update && \
|
|
| 11 |
rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
# Clone the repository using secret mounts.
|
| 14 |
-
# Secrets: GIT_USER, GIT_TOKEN, GIT_REPO (the
|
| 15 |
RUN --mount=type=secret,id=GIT_USER,mode=0444,required=true \
|
| 16 |
--mount=type=secret,id=GIT_TOKEN,mode=0444,required=true \
|
| 17 |
--mount=type=secret,id=GIT_REPO,mode=0444,required=true \
|
|
@@ -26,7 +26,7 @@ RUN --mount=type=secret,id=GIT_USER,mode=0444,required=true \
|
|
| 26 |
# Debug: List directories under /build.
|
| 27 |
RUN echo "Directory structure in /build:" && ls -la /build
|
| 28 |
|
| 29 |
-
#
|
| 30 |
RUN --mount=type=secret,id=GIT_REPO,mode=0444,required=true \
|
| 31 |
sh -c " \
|
| 32 |
REPO=\$(cat /run/secrets/GIT_REPO); \
|
|
@@ -79,23 +79,24 @@ RUN apt-get update && \
|
|
| 79 |
# Copy the entire fixed private_repo folder from the builder stage.
|
| 80 |
COPY --from=builder /build/private_repo/ /usr/src/app/
|
| 81 |
|
| 82 |
-
#
|
| 83 |
COPY --from=builder /build/PACKAGE_SEQUENCE.txt /usr/src/app/PACKAGE_SEQUENCE.txt
|
| 84 |
|
| 85 |
-
# Reinstall Python dependencies in the final stage
|
| 86 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 87 |
|
| 88 |
# Reinstall custom packages in the specified sequence.
|
| 89 |
-
RUN /bin/sh -c "
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
done
|
| 98 |
-
|
|
|
|
| 99 |
|
| 100 |
# Switch to a non-root user and adjust the PATH.
|
| 101 |
RUN useradd -m -u 1000 user
|
|
@@ -116,4 +117,4 @@ WORKDIR /usr/src/app
|
|
| 116 |
RUN echo "Final working directory contents:" && ls -la
|
| 117 |
|
| 118 |
# Start the Streamlit app.
|
| 119 |
-
CMD ["streamlit", "run", "st_app.py", "--server.headless", "true", "--server.port", "8501"]
|
|
|
|
| 11 |
rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
# Clone the repository using secret mounts.
|
| 14 |
+
# Secrets: GIT_USER, GIT_TOKEN, GIT_REPO (the secret GIT_REPO contains the repository name, e.g. internal_demo_signal_portfolio)
|
| 15 |
RUN --mount=type=secret,id=GIT_USER,mode=0444,required=true \
|
| 16 |
--mount=type=secret,id=GIT_TOKEN,mode=0444,required=true \
|
| 17 |
--mount=type=secret,id=GIT_REPO,mode=0444,required=true \
|
|
|
|
| 26 |
# Debug: List directories under /build.
|
| 27 |
RUN echo "Directory structure in /build:" && ls -la /build
|
| 28 |
|
| 29 |
+
# Copy the private_repo folder to a fixed location.
|
| 30 |
RUN --mount=type=secret,id=GIT_REPO,mode=0444,required=true \
|
| 31 |
sh -c " \
|
| 32 |
REPO=\$(cat /run/secrets/GIT_REPO); \
|
|
|
|
| 79 |
# Copy the entire fixed private_repo folder from the builder stage.
|
| 80 |
COPY --from=builder /build/private_repo/ /usr/src/app/
|
| 81 |
|
| 82 |
+
# Also copy the PACKAGE_SEQUENCE file.
|
| 83 |
COPY --from=builder /build/PACKAGE_SEQUENCE.txt /usr/src/app/PACKAGE_SEQUENCE.txt
|
| 84 |
|
| 85 |
+
# Reinstall Python dependencies in the final stage.
|
| 86 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 87 |
|
| 88 |
# Reinstall custom packages in the specified sequence.
|
| 89 |
+
RUN /bin/sh -c " \
|
| 90 |
+
if [ -f /usr/src/app/PACKAGE_SEQUENCE.txt ]; then \
|
| 91 |
+
echo 'Re-installing custom packages in sequence:'; \
|
| 92 |
+
while IFS= read -r pkg; do \
|
| 93 |
+
echo 'Installing custom package pattern:' \$pkg; \
|
| 94 |
+
for file in /usr/src/app/packages/\$pkg; do \
|
| 95 |
+
echo 'Installing package file:' \$file; \
|
| 96 |
+
pip install --no-cache-dir \"\$file\"; \
|
| 97 |
+
done; \
|
| 98 |
+
done < /usr/src/app/PACKAGE_SEQUENCE.txt; \
|
| 99 |
+
fi"
|
| 100 |
|
| 101 |
# Switch to a non-root user and adjust the PATH.
|
| 102 |
RUN useradd -m -u 1000 user
|
|
|
|
| 117 |
RUN echo "Final working directory contents:" && ls -la
|
| 118 |
|
| 119 |
# Start the Streamlit app.
|
| 120 |
+
CMD ["streamlit", "run", "st_app.py", "--server.headless", "true", "--server.port", "8501"]
|