-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a docker file to deploy this application
need to update it or change it...
- Loading branch information
1 parent
3600dcd
commit eafe4e8
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Stage 1: Build Stage with python:3.10-alpine for a smaller footprint | ||
FROM python:3.10-alpine AS builder | ||
|
||
# Set environment variables to avoid Python output buffering | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Install build dependencies and required libraries | ||
RUN apk add --no-cache \ | ||
build-base \ | ||
gcc \ | ||
libc-dev \ | ||
libjpeg-turbo-dev \ | ||
zlib-dev \ | ||
python3-dev \ | ||
musl-dev \ | ||
bash \ | ||
jpeg-dev \ | ||
freetype-dev \ | ||
pkgconfig \ | ||
py3-pip \ | ||
py3-setuptools \ | ||
py3-wheel \ | ||
openblas-dev | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy requirements file and install dependencies | ||
COPY requirements.txt . | ||
|
||
# Install Python dependencies without caching to reduce the final image size | ||
RUN pip install --no-cache-dir --user -r requirements.txt | ||
|
||
# Stage 2: Final Stage - Use a minimal Alpine image for runtime | ||
FROM python:3.10-alpine | ||
|
||
# Install runtime dependencies only | ||
RUN apk add --no-cache \ | ||
libjpeg-turbo \ | ||
zlib \ | ||
libstdc++ \ | ||
jpeg-dev \ | ||
bash \ | ||
openblas | ||
|
||
# Set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy installed dependencies from the builder stage | ||
COPY --from=builder /root/.local /root/.local | ||
|
||
# Ensure the Python scripts in the user folder are in the PATH | ||
ENV PATH=/root/.local/bin:$PATH | ||
|
||
# Copy the application code | ||
COPY . . | ||
|
||
# Expose port for streamlit | ||
EXPOSE 8501 | ||
|
||
# Run the app | ||
CMD ["streamlit", "run", "app.py"] | ||
|
||
|