-
Notifications
You must be signed in to change notification settings - Fork 1
/
python.dockerfile
61 lines (56 loc) · 2.08 KB
/
python.dockerfile
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
# Base image with CUDA support
FROM nvidia/cuda:12.4.1-base-ubuntu22.04
# Environment configuration
ENV PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND="noninteractive" \
# User configuration
DISCORD_BOT_TOKEN="" \
DISCORD_GUILD_IDS="" \
GITHUB_ACCESS_TOKEN="" \
MAX_MODEL_SCALE=4 \
MIN_COLORS_IN=3 \
MIN_COLORS_OUT=3 \
OWNER_ONLY=0 \
# Paths
LD_LIBRARY_PATH="/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}" \
PATH="/root/.local/bin:${PATH}"
# Set the working directory
WORKDIR /app
# Copy project requirements and files
COPY requirements.base.txt requirements.torch.txt /app/
ADD scalecord /app/scalecord
# Install and update system level dependencies
RUN apt-get update -y && \
apt-get install -y software-properties-common && \
# Add the deadsnakes PPA and install Python 3.11
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update -y && \
apt-get install -y --no-install-recommends \
git \
build-essential \
python3.11 \
python3-pip \
python3.11-venv \
python3.11-dev && \
# Set Python 3.11 as default, upgrade pip
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
update-alternatives --set python3 /usr/bin/python3.11 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 && \
update-alternatives --set python /usr/bin/python3.11 && \
python -m pip install --upgrade pip && \
# Install scalecord project
pip install -r requirements.torch.txt && \
pip install -r requirements.base.txt && \
# Housekeeping to reduce image size
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
pip cache purge && \
# Build the command entrypoint and install it
echo "#!/bin/bash" > scalecord.sh && \
echo 'export PYTHONPATH="/app:$PYTHONPATH"' >> scalecord.sh && \
echo 'python -m scalecord.cli "$@"' >> scalecord.sh && \
chmod +x scalecord.sh && \
mv scalecord.sh /usr/local/bin/scalecord
# Command entrypoint and default commands
ENTRYPOINT ["scalecord"]
CMD ["update", "all", "bot", "run"]