Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (52 loc) · 1.82 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (52 loc) · 1.82 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
# Production stage
FROM python:3.12-slim AS production
# Set build arguments
ARG APP_VERSION=0.2.0
ARG BUILD_DATE
ARG VCS_REF
# Labels for image metadata
LABEL org.opencontainers.image.title="Spotify MCP Server"
LABEL org.opencontainers.image.description="Production-ready Spotify MCP Server with FastMCP"
LABEL org.opencontainers.image.version=${APP_VERSION}
LABEL org.opencontainers.image.created=${BUILD_DATE}
LABEL org.opencontainers.image.revision=${VCS_REF}
LABEL org.opencontainers.image.vendor="Spotify MCP Team"
LABEL org.opencontainers.image.source="https://github.com/your-org/spotify-mcp-server"
# Create non-root user for security
RUN groupadd --gid 1001 spotify && \
useradd --uid 1001 --gid spotify --shell /bin/bash --create-home spotify
# Install runtime and build dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install latest Poetry
RUN pip install poetry
# Set up application directory
WORKDIR /app
# Copy application code
COPY --chown=spotify:spotify spotify_mcp /app/
COPY --chown=spotify:spotify pyproject.toml ./
# Install dependencies directly (no virtual environment needed in container)
RUN poetry config virtualenvs.create false \
&& poetry install --only=main --no-root
# Create directories for logs and cache
RUN mkdir -p /app/logs /app/cache && \
chown -R spotify:spotify /app/logs /app/cache
# Set environment variables
ENV PYTHONPATH=/app/src
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Runtime environment variables with sensible defaults
ENV ENVIRONMENT=production
ENV LOG_LEVEL=INFO
ENV SERVER_HOST=0.0.0.0
ENV SERVER_PORT=8081
ENV TOKEN_CACHE_PATH=/app/cache/.cache
# Switch to non-root user
USER spotify
# Expose port
EXPOSE 8081 8080
# Set the default command
CMD ["python", "server.py"]