forked from awslabs/mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
88 lines (69 loc) · 3.04 KB
/
Dockerfile
File metadata and controls
88 lines (69 loc) · 3.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# dependabot should continue to update this to the latest hash.
FROM public.ecr.aws/docker/library/python:3.13-alpine@sha256:070342a0cc1011532c0e69972cce2bbc6cc633eba294bae1d12abea8bd05303b AS uv
# Install the project into `/app`
WORKDIR /app
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy
# Prefer the system python
ENV UV_PYTHON_PREFERENCE=only-system
# Run without updating the uv.lock file like running with `--frozen`
ENV UV_FROZEN=true
# Copy the required files first
COPY pyproject.toml uv.lock uv-requirements.txt ./
# Python optimization and uv configuration
ENV PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install system dependencies and Python package manager
RUN apk update && \
apk add --no-cache --virtual .build-deps \
build-base \
gcc \
musl-dev \
libffi-dev \
openssl-dev \
cargo
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
pip install --require-hashes --requirement uv-requirements.txt --no-cache-dir && \
uv sync --python 3.13 --frozen --no-install-project --no-dev --no-editable
# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
COPY . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --python 3.13 --frozen --no-dev --no-editable
# Make the directory just in case it doesn't exist
RUN mkdir -p /root/.local
FROM public.ecr.aws/docker/library/python:3.13-alpine@sha256:070342a0cc1011532c0e69972cce2bbc6cc633eba294bae1d12abea8bd05303b
# Place executables in the environment at the front of the path and include other binaries
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1
# Install runtime dependencies and create application user
RUN apk update && \
apk add --no-cache ca-certificates && \
update-ca-certificates && \
addgroup -S app && \
adduser -S app -G app -h /app
# Copy application artifacts from build stage
COPY --from=uv --chown=app:app /app/.venv /app/.venv
# Get healthcheck script
COPY ./docker-healthcheck.sh /usr/local/bin/docker-healthcheck.sh
# Run as non-root
USER app
# When running the container, add --db-path and a bind mount to the host's db file
HEALTHCHECK --interval=60s --timeout=10s --start-period=10s --retries=3 CMD ["docker-healthcheck.sh"]
ENTRYPOINT ["awslabs.cfn-mcp-server"]