image-caption-ai / Dockerfile
Ishu8904's picture
FINAL FIX: Create static/uploads directory with permissions
7ce37e3
# Stage 1: Downloader
FROM debian:bullseye-slim AS downloader
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
WORKDIR /models
# Paste your new v2.0.3 links here
RUN wget -O decoder-model.pth "https://github.com/Ishu-Kaur/Image-Caption-AI/releases/download/v2.0.3/decoder-model.pth"
RUN wget -O encoder-model.pth "https://github.com/Ishu-Kaur/Image-Caption-AI/releases/download/v2.0.3/encoder-model.pth"
RUN wget -O vocab.pkl "https://github.com/Ishu-Kaur/Image-Caption-AI/releases/download/v2.0.3/vocab.pkl"
# Stage 2: Final Application
FROM python:3.11-slim
WORKDIR /app
# Set the home directory for PyTorch cache to prevent permission errors
ENV TORCH_HOME=/app/cache
# Copy the downloaded model files from the 'downloader' stage
COPY --from=downloader /models/ .
# Copy and install requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . .
# CRITICAL FIX: Create the cache and static upload directories and set permissions
RUN mkdir -p /app/cache && chmod -R 777 /app/cache
RUN mkdir -p /app/static/uploads && chmod -R 777 /app/static
# Expose the correct port
EXPOSE 5000
# Run the application
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]