Update Dockerfile
Browse files- Dockerfile +17 -16
Dockerfile
CHANGED
|
@@ -3,6 +3,9 @@
|
|
| 3 |
# ----------------------------
|
| 4 |
FROM python:3.10-slim as builder
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
WORKDIR /build
|
| 7 |
|
| 8 |
# Install git and other necessary packages
|
|
@@ -10,10 +13,6 @@ RUN apt-get update && \
|
|
| 10 |
apt-get install -y git && \
|
| 11 |
rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
-
# Use a build argument for the repository name.
|
| 14 |
-
# This value must match the secret stored in GIT_REPO.
|
| 15 |
-
ARG GIT_REPO
|
| 16 |
-
|
| 17 |
# Clone the single private repository using secret mounts for credentials and repo name.
|
| 18 |
RUN --mount=type=secret,id=GIT_USER,mode=0444,required=true \
|
| 19 |
--mount=type=secret,id=GIT_TOKEN,mode=0444,required=true \
|
|
@@ -26,14 +25,14 @@ RUN --mount=type=secret,id=GIT_USER,mode=0444,required=true \
|
|
| 26 |
git clone https://\$GIT_USER:\$GIT_TOKEN@github.com/\$GIT_USER/\$GIT_REPO_SECRET.git \
|
| 27 |
"
|
| 28 |
|
| 29 |
-
# Debug: List the directory structure
|
| 30 |
RUN echo "Directory structure in /build:" && ls -la /build
|
| 31 |
|
| 32 |
# Set WORKDIR to the private_repo folder inside the cloned repository.
|
| 33 |
-
#
|
| 34 |
WORKDIR /build/${GIT_REPO}/private_repo
|
| 35 |
|
| 36 |
-
# Debug: List contents of private_repo to verify
|
| 37 |
RUN echo "Contents of /build/${GIT_REPO}/private_repo:" && ls -la
|
| 38 |
|
| 39 |
# Install Python dependencies from requirements.txt
|
|
@@ -43,10 +42,10 @@ RUN echo "Installing Python dependencies from requirements.txt:" && \
|
|
| 43 |
# ----------------------------
|
| 44 |
# Install Custom Packages
|
| 45 |
# ----------------------------
|
| 46 |
-
# PACKAGE_SEQUENCE is a newline-separated list of tar.gz file patterns
|
| 47 |
ARG PACKAGE_SEQUENCE
|
| 48 |
WORKDIR /build/${GIT_REPO}/private_repo/packages
|
| 49 |
-
RUN echo "Contents of packages
|
| 50 |
echo "Installing custom packages in the following sequence:" && \
|
| 51 |
echo "$PACKAGE_SEQUENCE" | while IFS= read -r pkg; do \
|
| 52 |
echo "Installing package: $pkg" && \
|
|
@@ -58,26 +57,28 @@ RUN echo "Contents of packages folder:" && ls -la && \
|
|
| 58 |
# ----------------------------
|
| 59 |
FROM python:3.10-slim
|
| 60 |
|
| 61 |
-
WORKDIR /app
|
| 62 |
|
| 63 |
# (Optional) Install git in the final image if needed
|
| 64 |
RUN apt-get update && \
|
| 65 |
apt-get install -y git && \
|
| 66 |
rm -rf /var/lib/apt/lists/*
|
| 67 |
|
| 68 |
-
# Pass the GIT_REPO build argument to the final stage
|
| 69 |
ARG GIT_REPO
|
| 70 |
|
| 71 |
-
# Copy the entire private_repo folder from the builder stage into /app.
|
| 72 |
-
|
| 73 |
-
COPY --from=builder /build/${GIT_REPO}/private_repo/ /app/
|
| 74 |
|
| 75 |
-
# Debug: List contents of the final working directory
|
| 76 |
-
RUN echo "Contents of /app:" && ls -la /app
|
| 77 |
|
| 78 |
# Expose Streamlit's default port
|
| 79 |
EXPOSE 8501
|
| 80 |
|
|
|
|
|
|
|
|
|
|
| 81 |
# Start the Streamlit app
|
| 82 |
CMD streamlit run st_app.py \
|
| 83 |
--server.headless true \
|
|
|
|
| 3 |
# ----------------------------
|
| 4 |
FROM python:3.10-slim as builder
|
| 5 |
|
| 6 |
+
# Declare GIT_REPO so it can be used throughout this stage.
|
| 7 |
+
ARG GIT_REPO
|
| 8 |
+
|
| 9 |
WORKDIR /build
|
| 10 |
|
| 11 |
# Install git and other necessary packages
|
|
|
|
| 13 |
apt-get install -y git && \
|
| 14 |
rm -rf /var/lib/apt/lists/*
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Clone the single private repository using secret mounts for credentials and repo name.
|
| 17 |
RUN --mount=type=secret,id=GIT_USER,mode=0444,required=true \
|
| 18 |
--mount=type=secret,id=GIT_TOKEN,mode=0444,required=true \
|
|
|
|
| 25 |
git clone https://\$GIT_USER:\$GIT_TOKEN@github.com/\$GIT_USER/\$GIT_REPO_SECRET.git \
|
| 26 |
"
|
| 27 |
|
| 28 |
+
# Debug: List the directory structure at /build
|
| 29 |
RUN echo "Directory structure in /build:" && ls -la /build
|
| 30 |
|
| 31 |
# Set WORKDIR to the private_repo folder inside the cloned repository.
|
| 32 |
+
# Use the build argument GIT_REPO (e.g., internal_demo_signal_portfolio).
|
| 33 |
WORKDIR /build/${GIT_REPO}/private_repo
|
| 34 |
|
| 35 |
+
# Debug: List contents of private_repo to verify that requirements.txt and st_app.py are present.
|
| 36 |
RUN echo "Contents of /build/${GIT_REPO}/private_repo:" && ls -la
|
| 37 |
|
| 38 |
# Install Python dependencies from requirements.txt
|
|
|
|
| 42 |
# ----------------------------
|
| 43 |
# Install Custom Packages
|
| 44 |
# ----------------------------
|
| 45 |
+
# PACKAGE_SEQUENCE is a newline-separated list of tar.gz file patterns.
|
| 46 |
ARG PACKAGE_SEQUENCE
|
| 47 |
WORKDIR /build/${GIT_REPO}/private_repo/packages
|
| 48 |
+
RUN echo "Contents of /build/${GIT_REPO}/private_repo/packages:" && ls -la && \
|
| 49 |
echo "Installing custom packages in the following sequence:" && \
|
| 50 |
echo "$PACKAGE_SEQUENCE" | while IFS= read -r pkg; do \
|
| 51 |
echo "Installing package: $pkg" && \
|
|
|
|
| 57 |
# ----------------------------
|
| 58 |
FROM python:3.10-slim
|
| 59 |
|
| 60 |
+
WORKDIR /usr/src/app
|
| 61 |
|
| 62 |
# (Optional) Install git in the final image if needed
|
| 63 |
RUN apt-get update && \
|
| 64 |
apt-get install -y git && \
|
| 65 |
rm -rf /var/lib/apt/lists/*
|
| 66 |
|
| 67 |
+
# Pass the GIT_REPO build argument to the final stage.
|
| 68 |
ARG GIT_REPO
|
| 69 |
|
| 70 |
+
# Copy the entire private_repo folder from the builder stage into /usr/src/app.
|
| 71 |
+
COPY --from=builder /build/${GIT_REPO}/private_repo/ /usr/src/app/
|
|
|
|
| 72 |
|
| 73 |
+
# Debug: List contents of the final working directory to verify files (e.g., st_app.py)
|
| 74 |
+
RUN echo "Contents of /usr/src/app:" && ls -la /usr/src/app
|
| 75 |
|
| 76 |
# Expose Streamlit's default port
|
| 77 |
EXPOSE 8501
|
| 78 |
|
| 79 |
+
# Set the working directory to where st_app.py is located.
|
| 80 |
+
WORKDIR /usr/src/app
|
| 81 |
+
|
| 82 |
# Start the Streamlit app
|
| 83 |
CMD streamlit run st_app.py \
|
| 84 |
--server.headless true \
|