-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (50 loc) · 1.69 KB
/
Dockerfile
File metadata and controls
65 lines (50 loc) · 1.69 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# This file is part of DisMu.
# Licensed under the GNU GPL v3 or later – see LICENSE.md for details.
# Choosing last Ubuntu LTS since it's faster than python base image
FROM ubuntu:24.04 AS builder-image
# Avoid stuck build due to user prompt
ARG DEBIAN_FRONTEND=noninteractive
# Installing needed dependencies during build
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.12 \
python3.12-dev \
python3.12-venv \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python3.12 -m venv /home/dismu/venv
ENV PATH="/home/dismu/venv/bin:$PATH"
# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip wheel
RUN pip install --no-cache-dir -r requirements.txt
FROM ubuntu:24.04 AS runner-image
# Installing needed dependencies during run
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
python3.12 \
python3.12-venv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create user first
RUN useradd --create-home dismu
# Copy virtual environment from builder
COPY --from=builder-image /home/dismu/venv /home/dismu/venv
# Set up directories and copy application code
RUN mkdir -p /home/dismu/app
WORKDIR /home/dismu/app
# Copy the entire src directory to maintain proper structure
COPY src/ ./src/
COPY .env .
# Change ownership to dismu user
RUN chown -R dismu:dismu /home/dismu/app
# Switch to non-root user
USER dismu
# Virtual env settings
ENV PYTHONUNBUFFERED=1
ENV VIRTUAL_ENV=/home/dismu/venv
ENV PATH="/home/dismu/venv/bin:$PATH"
ENV PYTHONPATH="/home/dismu/app"
# Command to run bot
CMD ["python", "src/main.py"]