-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (33 loc) · 1.04 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (33 loc) · 1.04 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
# Build stage
FROM python:3.12-slim AS builder
# Copy uv from its official image
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# Set the working directory
WORKDIR /app
# Enable bytecode compilation for better performance
ENV UV_COMPILE_BYTECODE=1
ENV UV_SYSTEM_PYTHON=1
# Copy only requirements file first to leverage caching
COPY requirements.txt .
COPY pyproject.toml .
COPY README.md .
COPY src ./src
# Install dependencies with uv
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install --system -r requirements.txt \
&& uv pip install --system .
# Final stage
FROM python:3.12-slim
# Set the working directory
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/
COPY --from=builder /usr/local/bin/sonos-lastfm /usr/local/bin/sonos-lastfm
# Create data directory
RUN mkdir -p /app/data
# Copy application files
COPY . .
# Define volume for the data directory
VOLUME ["/app/data"]
# Run the application
CMD ["sonos-lastfm"]