-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (31 loc) · 1.1 KB
/
Dockerfile
File metadata and controls
43 lines (31 loc) · 1.1 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
# Use a multi-stage build to reduce final image size
FROM python:3.9-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libasound2-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy only what's needed for installing dependencies
COPY requirements.txt .
# Install Python dependencies
RUN pip install --user -r requirements.txt
# Runtime stage
FROM python:3.9-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libasound2 \
alsa-utils \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy Python dependencies from builder
COPY --from=builder /root/.local /root/.local
# Copy application files from local directory
COPY home-assistant-mqtt-volume-control.py .
COPY configuration.yaml .
# Make sure scripts in .local are usable
ENV PATH=/root/.local/bin:$PATH
# Volume for configuration (if you want to mount it at runtime instead)
VOLUME /app/config
# Set the entrypoint to your specific script
ENTRYPOINT ["python", "home-assistant-mqtt-volume-control.py"]