-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (57 loc) · 1.89 KB
/
Copy pathDockerfile
File metadata and controls
74 lines (57 loc) · 1.89 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
66
67
68
69
70
71
72
73
74
FROM python:3.12-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /build
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
g++ \
python3-dev \
libffi-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Poetry
RUN pip install --no-cache-dir poetry==1.8.2
# Copy dependency files
COPY pyproject.toml poetry.lock* ./
# Install dependencies
RUN poetry config virtualenvs.create false && \
poetry install --without dev --no-root --no-interaction --no-ansi --no-cache || \
(poetry lock && poetry install --without dev --no-root --no-interaction --no-ansi --no-cache)
# Copy application code
COPY README.md ./
COPY src/ ./src/
COPY config.example.yaml ./config.example.yaml
# Install the package itself
RUN poetry install --only-root --no-interaction --no-ansi
# Runtime stage
FROM python:3.12-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app:/app/src \
IN_DOCKER=1 \
FORCE_COLOR=1
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
cron \
curl \
procps \
&& rm -rf /var/lib/apt/lists/*
# Copy Python 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 /usr/local/bin
# Copy application code
COPY --from=builder /build/src /app/src
COPY --from=builder /build/config.example.yaml /app/config.example.yaml
# Copy Docker scripts
COPY docker/scripts/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
HEALTHCHECK --interval=60s --timeout=10s --start-period=30s --retries=3 \
CMD spotisync config path || exit 1
ENTRYPOINT ["/entrypoint.sh"]
CMD ["cron", "-f"]