-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbitbot.dockerfile
More file actions
46 lines (35 loc) · 1.12 KB
/
bitbot.dockerfile
File metadata and controls
46 lines (35 loc) · 1.12 KB
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
# Stage 1: Build stage
FROM python:3.11-slim-bookworm AS builder
# Avoid bytecode baggage
ENV PYTHONDONTWRITEBYTECODE=1
# Create a virtual environment
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Update pip
RUN python3 -m pip install --upgrade pip --no-cache-dir
# Copy and install Python dependencies
COPY requirements.txt .
RUN python3 -m pip install -v \
--only-binary :all: \
-r requirements.txt \
--index-url https://pypi.org/simple \
--extra-index-url https://www.piwheels.org/simple \
--no-cache-dir
# Stage 2: Final stage
FROM python:3.11-slim-bookworm
# Avoid bytecode baggage
ENV PYTHONDONTWRITEBYTECODE=1
# Install only the necessary runtime dependencies
RUN apt-get update -y && \
apt-get install -y \
--no-install-recommends \
libopenblas-dev libopenjp2-7 libtiff6 libxcb1 libfreetype6-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy the virtual environment from the builder stage
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy only the necessary application code
WORKDIR /code
COPY . .
# Set the default command
CMD ["python", "run.py"]