-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.prod
67 lines (52 loc) · 1.63 KB
/
Dockerfile.prod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Stage 1: Build environment
FROM python:3.9-slim-buster AS builder
# Set work directory
WORKDIR /app
# Install system build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
wget \
&& rm -rf /var/lib/apt/lists/*
# Install Miniconda
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh \
&& bash miniconda.sh -b -p /opt/conda \
&& rm miniconda.sh
ENV PATH="/opt/conda/bin:${PATH}"
# Create a conda environment
RUN conda create -n pipeline python=3.9 -y
SHELL ["conda", "run", "-n", "pipeline", "/bin/bash", "-c"]
# Copy only requirements, to cache them in docker layer
COPY requirements.txt /app/
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Stage 2: Runtime environment
FROM python:3.9-slim-buster AS runtime
# Set work directory
WORKDIR /app
# Install runtime system dependencies
RUN apt-get update && apt-get install -y \
libsm6 \
libxext6 \
libxrender-dev \
libglib2.0-0 \
libgl1-mesa-glx \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy conda environment from builder
COPY --from=builder /opt/conda /opt/conda
ENV PATH="/opt/conda/bin:${PATH}"
SHELL ["conda", "run", "-n", "pipeline", "/bin/bash", "-c"]
# Copy application code
COPY . /app
# Install Ollama
RUN curl https://ollama.ai/install.sh | sh
# Make port 8080 available to the world outside this container
EXPOSE 8080
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Run the application
CMD ["conda", "run", "--no-capture-output", "-n", "pipeline", "python", "main.py"]