Skip to content

Commit c486aaf

Browse files
fix: convert sam/build-python to python:alpine (#868)
* fix: convert sam/build-python to python:alpine Signed-off-by: Scott Schreckengaust <scottschreckengaust@users.noreply.github.com> * fix: terraform-mcp-server Signed-off-by: Scott Schreckengaust <scottschreckengaust@users.noreply.github.com> * fix: optimizing Signed-off-by: Scott Schreckengaust <scottschreckengaust@users.noreply.github.com> --------- Signed-off-by: Scott Schreckengaust <scottschreckengaust@users.noreply.github.com> Co-authored-by: Alain Krok <alkrok@amazon.com>
1 parent 3485628 commit c486aaf

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

src/aws-diagram-mcp-server/Dockerfile

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
# dependabot should continue to update this to the latest hash.
16-
FROM public.ecr.aws/sam/build-python3.12@sha256:e76d50b20fa10ee101886cb62962aaf87a5cd1d737af48e1b8395a05f3a7c52f AS uv
16+
FROM public.ecr.aws/docker/library/python:3.12-slim-bookworm@sha256:4600f71648e110b005bf7bca92dbb335e549e6b27f2e83fceee5e11b3e1a4d01 AS uv
1717

1818
# Install the project into `/app`
1919
WORKDIR /app
@@ -48,24 +48,26 @@ COPY . /app
4848
RUN --mount=type=cache,target=/root/.cache/uv \
4949
uv sync --python 3.12 --frozen --no-dev --no-editable
5050

51-
# Make the directory just in case it doesn't exist
52-
RUN mkdir -p /root/.local
51+
# # Make the directory just in case it doesn't exist
52+
# RUN mkdir -p /root/.local
5353

54-
FROM public.ecr.aws/sam/build-python3.12@sha256:e76d50b20fa10ee101886cb62962aaf87a5cd1d737af48e1b8395a05f3a7c52f
54+
FROM public.ecr.aws/docker/library/python:3.12-slim-bookworm@sha256:4600f71648e110b005bf7bca92dbb335e549e6b27f2e83fceee5e11b3e1a4d01
5555

5656
# Place executables in the environment at the front of the path and include other binaries
5757
ENV PATH="/app/.venv/bin:$PATH:/usr/sbin" \
5858
PYTHONUNBUFFERED=1
5959

6060
# Add non-root user and ability to change directory into /root
61-
RUN dnf update -y && \
62-
dnf install -y graphviz && \
63-
dnf clean all -y && \
64-
rm -rf /var/cache/dnf && \
65-
groupadd --force --system app
61+
RUN apt-get update -y && \
62+
apt-get install -y graphviz && \
63+
apt-get clean -y && \
64+
apt-get autoremove -y && \
65+
groupadd --force --system app && \
66+
useradd app -g app -d /app && \
67+
chmod o+x /root
6668

6769
# Copy application artifacts from build stage
68-
COPY --from=uv --chown=app:app /root/.local /root/.local
70+
# COPY --from=uv --chown=app:app /root/.local /root/.local
6971
COPY --from=uv --chown=app:app /app/.venv /app/.venv
7072

7173
# Get healthcheck script

src/s3-tables-mcp-server/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
# dependabot should continue to update this to the latest hash.
16-
FROM public.ecr.aws/sam/build-python3.13@sha256:0c274ddd44e1d80e4dab3a70c25fe29508f612a045cba7d27840461c12eee86d AS uv
16+
FROM public.ecr.aws/docker/library/python:3.13-slim-bookworm@sha256:6544e0e002b40ae0f59bc3618b07c1e48064c4faed3a15ae2fbd2e8f663e8283 AS uv
1717

1818
# Install the project into `/app`
1919
WORKDIR /app
@@ -48,10 +48,10 @@ COPY . /app
4848
RUN --mount=type=cache,target=/root/.cache/uv \
4949
uv sync --python 3.13 --frozen --no-dev --no-editable
5050

51-
# Make the directory just in case it doesn't exist
52-
RUN mkdir -p /root/.local
51+
# # Make the directory just in case it doesn't exist
52+
# RUN mkdir -p /root/.local
5353

54-
FROM public.ecr.aws/sam/build-python3.13@sha256:0c274ddd44e1d80e4dab3a70c25fe29508f612a045cba7d27840461c12eee86d
54+
FROM public.ecr.aws/docker/library/python:3.13-slim-bookworm@sha256:6544e0e002b40ae0f59bc3618b07c1e48064c4faed3a15ae2fbd2e8f663e8283
5555

5656
# Place executables in the environment at the front of the path and include other binaries
5757
ENV PATH="/app/.venv/bin:$PATH:/usr/sbin" \
@@ -63,7 +63,7 @@ RUN groupadd --force --system app && \
6363
chmod o+x /root
6464

6565
# Copy application artifacts from build stage
66-
COPY --from=uv --chown=app:app /root/.local /root/.local
66+
# COPY --from=uv --chown=app:app /root/.local /root/.local
6767
COPY --from=uv --chown=app:app /app/.venv /app/.venv
6868

6969
# Get healthcheck script

src/terraform-mcp-server/Dockerfile

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
# dependabot should continue to update this to the latest hash.
16-
FROM public.ecr.aws/sam/build-python3.13@sha256:0c274ddd44e1d80e4dab3a70c25fe29508f612a045cba7d27840461c12eee86d AS uv
16+
FROM public.ecr.aws/docker/library/python:3.13-slim-bookworm@sha256:6544e0e002b40ae0f59bc3618b07c1e48064c4faed3a15ae2fbd2e8f663e8283 AS uv
1717

1818
# Install the project into `/app`
1919
WORKDIR /app
@@ -42,28 +42,39 @@ RUN --mount=type=cache,target=/root/.cache/uv \
4242
pip install --require-hashes --requirement uv-requirements.txt --no-cache-dir && \
4343
uv sync --python 3.13 --frozen --no-install-project --no-dev --no-editable
4444

45-
# Then, add the rest of the project source code and install it
45+
# Then, add the rest of the project source code and install it
4646
# Installing separately from its dependencies allows optimal layer caching
4747
COPY . /app
4848
RUN --mount=type=cache,target=/root/.cache/uv \
4949
uv sync --python 3.13 --frozen --no-dev --no-editable
5050

5151
# Make the directory just in case it doesn't exist
52-
RUN mkdir -p /root/.local
53-
54-
FROM public.ecr.aws/sam/build-python3.13@sha256:0c274ddd44e1d80e4dab3a70c25fe29508f612a045cba7d27840461c12eee86d
52+
# RUN mkdir -p /root/.local
5553

54+
FROM public.ecr.aws/docker/library/python:3.13-slim-bookworm@sha256:6544e0e002b40ae0f59bc3618b07c1e48064c4faed3a15ae2fbd2e8f663e8283
55+
ARG TERRAFORM_VERSION="1.12.2"
5656
# Place executables in the environment at the front of the path and include other binaries
57-
ENV PATH="/app/.venv/bin:$PATH:/usr/sbin" \
58-
PYTHONUNBUFFERED=1
57+
ENV PATH="/app/.venv/bin:$PATH:/usr/sbin"
58+
59+
RUN echo $TERRAFORM_VERSION
5960

61+
# Install lsof for the healthcheck
62+
# Install other tools as needed for the MCP server
6063
# Add non-root user and ability to change directory into /root
61-
RUN groupadd --force --system app && \
64+
RUN out=$(mktemp) && \
65+
apt-get update -y && \
66+
apt-get install -y wget unzip procps && \
67+
(wget -nv -O$out wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_$(dpkg --print-architecture).zip" || echo "Getting Network Error 4 ? $?" ) && \
68+
unzip "$out" -d /usr/local/bin/ && \
69+
chmod +x /usr/local/bin/terraform && \
70+
apt-get clean -y && \
71+
apt-get autoremove -y && \
72+
groupadd --force --system app && \
6273
useradd app -g app -d /app && \
6374
chmod o+x /root
6475

65-
# Copy application artifacts from build stage
66-
COPY --from=uv --chown=app:app /root/.local /root/.local
76+
# Get the project from the uv layer
77+
# COPY --from=uv --chown=app:app /root/.local /root/.local
6778
COPY --from=uv --chown=app:app /app/.venv /app/.venv
6879

6980
# Get healthcheck script

0 commit comments

Comments
 (0)