Skip to content

Commit

Permalink
Adding a docker file to deploy this application
Browse files Browse the repository at this point in the history
need to update it or change it...
  • Loading branch information
MementoMori11723 committed Sep 12, 2024
1 parent 3600dcd commit eafe4e8
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Dockerfile
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"]


0 comments on commit eafe4e8

Please sign in to comment.