Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ jobs:
context: .
load: true
tags: ${{ env.IMAGE_NAME }}:ci
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Use Node.js 22
uses: actions/setup-node@v4
Expand Down Expand Up @@ -115,8 +113,6 @@ jobs:
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Sync README to Docker Hub overview
if: github.ref == 'refs/heads/main'
Expand Down
60 changes: 43 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# syntax=docker/dockerfile:1

FROM node:22-bookworm-slim AS builder
# The builder only emits platform-independent JS (dist/), so it runs on the build host's
# platform. A multi-arch build then compiles once instead of once per platform under QEMU.
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS builder
WORKDIR /app

COPY package.json yarn.lock ./
Expand All @@ -10,8 +12,7 @@ RUN yarn build

FROM node:22-bookworm-slim AS runtime
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONDONTWRITEBYTECODE=1 \
PATH="/opt/venv/bin:${PATH}"
PYTHONDONTWRITEBYTECODE=1

RUN set -eux; \
apt-get update; \
Expand All @@ -26,21 +27,49 @@ RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends terraform; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/*; \
terraform version

RUN python3 -m venv /opt/venv \
&& pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir --no-compile \
aws-sam-cli \
snowflake-cli \
&& find /opt/venv/lib \
# SAM CLI comes from its official Linux installer, which bundles its own Python and dependencies.
# The checksums are the ones AWS publishes in the release notes. Snowflake CLI gets a venv of its
# own. Installing both with pip into one venv made the resolver backtrack for minutes (they pin
# conflicting `rich` versions) and settle on old releases. Snowflake's single-file binary is no
# alternative: on first run it unpacks ~400 MB of Python into $HOME.
# python3 and python3-pip also serve `sam build` for Python functions (Debian's Python 3.11;
# other Python runtimes need `sam build --use-container`).
ARG TARGETARCH
ARG SAM_CLI_VERSION=1.172.1
ARG SAM_CLI_SHA256_AMD64=aa6a5a785c576f5d8e1b783fe1633cb6eea1cbab382fa5aca1b9e17a9250cc07
ARG SAM_CLI_SHA256_ARM64=fcfc7cd414a75cc17a00c81110b2955ab52b6fae1dd8b7415d637ca95ca931df
RUN set -eux; \
case "$TARGETARCH" in \
amd64) sam_arch=x86_64; sam_sha="$SAM_CLI_SHA256_AMD64" ;; \
arm64) sam_arch=arm64; sam_sha="$SAM_CLI_SHA256_ARM64" ;; \
*) echo "unsupported TARGETARCH '$TARGETARCH'" >&2; exit 1 ;; \
esac; \
cd /tmp; \
curl -fsSLo sam.zip "https://github.com/aws/aws-sam-cli/releases/download/v${SAM_CLI_VERSION}/aws-sam-cli-linux-${sam_arch}.zip"; \
echo "${sam_sha} sam.zip" | sha256sum -c -; \
unzip -q sam.zip -d sam-installer; \
./sam-installer/install; \
rm -rf sam.zip sam-installer; \
sam --version

ARG SNOWFLAKE_CLI_VERSION=3.34.0
RUN python3 -m venv /opt/snowflake-cli \
&& /opt/snowflake-cli/bin/pip install --no-cache-dir --no-compile "snowflake-cli==${SNOWFLAKE_CLI_VERSION}" \
&& find /opt/snowflake-cli/lib \
\( -type d \( -name __pycache__ -o -name tests -o -name test \) -o -type f \( -name '*.pyc' -o -name '*.pyo' \) \) \
-prune -exec rm -rf '{}' +
-prune -exec rm -rf '{}' + \
&& ln -s /opt/snowflake-cli/bin/snow /usr/local/bin/snow \
&& snow --version

# lstk wraps terraform, cdk, and sam for the deployer tool. aws-cdk >= 2.1138 honors the
# CDK_S3_FORCE_PATH_STYLE that lstk sets, so S3 assets reach host.docker.internal path-style.
RUN npm install -g aws-cdk@2.1145.0 @localstack/lstk@1.4.2 \
&& npm cache clean --force
&& npm cache clean --force \
&& lstk --version \
&& cdk --version

WORKDIR /app
RUN mkdir -p /tmp/dockerode-deps \
Expand All @@ -52,12 +81,9 @@ RUN mkdir -p /tmp/dockerode-deps \
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./package.json

# Each tool layer checks its own version above, so this step only checks the per-commit files
# and stays cheap when the tool layers come from cache.
RUN set -eux; \
lstk --version; \
terraform version; \
sam --version; \
cdk --version; \
snow --version; \
node dist/cli.js version; \
node -e "require('dockerode'); console.log('dockerode ok')"

Expand Down
Loading