From 36a31ce6ba6c5d6b31cea56f0c0a891ca75aad75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Wed, 21 Oct 2026 15:36:12 +0200 Subject: [PATCH 1/2] Pick up ca-certificates 20250419+deb13u1 and castore 1.0.22 Moving the base to trixie-20261005-slim rebuilds the cached layer that installs ca-certificates, so it gets 20250419+deb13u1 (DSA-6572-1). AWS_CA_BUNDLE makes awscli use the system's CA bundle instead of the one it ships. --- Dockerfile | 5 ++++- mix.lock | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a8783d1..6f7278f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG ELIXIR_VERSION=1.20.4 ARG ERLANG_VERSION=29.1.1 -ARG DEBIAN_VERSION=trixie-20260918-slim +ARG DEBIAN_VERSION=trixie-20261005-slim FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-debian-${DEBIAN_VERSION} AS build @@ -92,6 +92,9 @@ USER nobody ENV HOME=/app ENV LANG=C.UTF-8 +# awscli verifies servers against the CA bundle it ships with unless this +# points it at another one +ENV AWS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt # Declared here, in the last stage, so a new commit does not invalidate the # build cache for everything above it. PromEx reads these to report which # revision is running. diff --git a/mix.lock b/mix.lock index a1302ee..2d1beef 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,6 @@ %{ "bandit": {:hex, :bandit, "1.12.5", "af205a8e550f304caae09a97d29fd3c79a7f337526ea7cd772d2ff11d2f7c800", [:mix], [{:hpax, "~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.18", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.5", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "c5684ca062fa407cac115aec3256383f3e2ec9fdced7904d59cf5a7bb7ed6181"}, - "castore": {:hex, :castore, "1.0.21", "0a0e8330dc267a40a3b7ad86d39302764bb71758172904e6a59d5ad6443ce307", [:mix], [], "hexpm", "e42e22723e25dbd46876d056a03f685513d6e98f6b5e555dc551321decd76c5c"}, + "castore": {:hex, :castore, "1.0.22", "a01978e6a5d42fa3a34143630588f92036e7d90e2309ecdd466722d1279a2213", [:mix], [], "hexpm", "c2a4d42723b4affbc1c3e15d8f6df3f7d8f1f627c84de643383634cce58493d5"}, "cc_precompiler": {:hex, :cc_precompiler, "0.1.11", "8c844d0b9fb98a3edea067f94f616b3f6b29b959b6b3bf25fee94ffe34364768", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3427232caf0835f94680e5bcf082408a70b48ad68a5f5c0b02a3bea9f3a075b9"}, "circular_buffer": {:hex, :circular_buffer, "1.1.0", "af9332c40d600cc27b160eebd9fad1bf0a8106cd62e9f57d6cc8f028d3cc46d1", [:mix], [], "hexpm", "0daa0a4fcb3a7ffabc8576bdbf64c99adc6d4b37eab1185179140769ba58f571"}, "db_connection": {:hex, :db_connection, "2.10.2", "ae391e803a5adff104da913c2fc1c0c14a37f8b10001dcef568796e1fb7bf95c", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "510b14482330f1af6490a2fa0efd8d4f1435d1529b165647df22ac0f2df0fa93"}, From eebd5fd5fa4426040ff86dbaf785592fc70062d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Wed, 21 Oct 2026 17:04:54 +0200 Subject: [PATCH 2/2] Remove what the image installs and nothing runs Nothing has called gcloud or gsutil since the docs scripts were removed in e70a235, so google-cloud-cli goes, with gnupg and apt-transport-https, which were only there to install it, and etc/boto, which only gsutil read. The key file cosign signs with moves from /boto to /gcp. build-essential, libffi-dev, libssl-dev and python3-dev were for pip install awscli, and awscli is the Debian package now. No job script runs zip, and tar and gzip are part of the base image. In the build stage, no dependency is a git checkout or compiles C, so git and build-essential go too. utils.sh lost its last caller in e70a235, and the prepare_*_builds_text.exs scripts rebuilt builds.txt from S3 listings, which Bob.Artifacts generates from the database now. --- Dockerfile | 12 +--- etc/boto | 2 - lib/bob/application.ex | 8 +-- priv/scripts/docker/sign.sh | 2 +- priv/scripts/prepare_elixir_builds_text.exs | 61 --------------------- priv/scripts/prepare_otp_builds_text.exs | 51 ----------------- priv/scripts/utils.sh | 23 -------- 7 files changed, 8 insertions(+), 151 deletions(-) delete mode 100644 etc/boto delete mode 100755 priv/scripts/prepare_elixir_builds_text.exs delete mode 100755 priv/scripts/prepare_otp_builds_text.exs delete mode 100755 priv/scripts/utils.sh diff --git a/Dockerfile b/Dockerfile index 6f7278f..a6e76eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ ENV LANG=C.UTF-8 # install build dependencies RUN apt update -y && \ apt upgrade -y && \ - apt install -y --no-install-recommends git build-essential ca-certificates && \ + apt install -y --no-install-recommends ca-certificates && \ apt clean -y && rm -rf /var/lib/apt/lists/* # prepare build dir @@ -61,7 +61,7 @@ FROM debian:${DEBIAN_VERSION} AS app # Erlang/OTP loads libsctp.so.1 when it starts and prints a warning without it RUN apt update -y && \ - apt install --no-install-recommends -y apt-transport-https awscli bash build-essential ca-certificates coreutils curl docker-cli gnupg gzip libffi-dev libsctp1 libssl-dev openssl python3-dev tar zip && \ + apt install --no-install-recommends -y awscli bash ca-certificates coreutils curl docker-cli libsctp1 openssl && \ apt clean -y && rm -rf /var/lib/apt/lists/* ARG BUILDX_VERSION=0.17.1 @@ -72,15 +72,9 @@ RUN mkdir -p /usr/libexec/docker/cli-plugins && \ COPY --from=ghcr.io/sigstore/cosign/cosign:v3.1.3@sha256:9e5c2f2edc34351160407ca3416c61855bdf9403c3c5936e0f0be7fc261611b8 /ko-app/cosign /usr/local/bin/cosign -RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \ - curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg && \ - apt update -y && apt install --no-install-recommends -y google-cloud-cli && \ - apt clean -y && rm -rf /var/lib/apt/lists/* - # The release creates /app/tmp when it starts and writes its runtime config # there, so /app is nobody's. -RUN mkdir /app /boto /persist && chown nobody:nogroup /app /boto /persist -COPY --chown=65534:65534 etc/boto /app/.boto +RUN mkdir /app /gcp /persist && chown nobody:nogroup /app /gcp /persist WORKDIR /app diff --git a/etc/boto b/etc/boto deleted file mode 100644 index fb33f8b..0000000 --- a/etc/boto +++ /dev/null @@ -1,2 +0,0 @@ -[Credentials] -gs_service_key_file = /boto/keyfile.json diff --git a/lib/bob/application.ex b/lib/bob/application.ex index a8f7b3a..642da22 100644 --- a/lib/bob/application.ex +++ b/lib/bob/application.ex @@ -6,7 +6,7 @@ defmodule Bob.Application do BobWeb.BanditTelemetry.attach() setup_docker() - setup_gsutil() + setup_gcp_credentials() auth_docker() validate_jobs() @@ -77,11 +77,11 @@ defmodule Bob.Application do end end - defp setup_gsutil() do + defp setup_gcp_credentials() do if credentials = System.get_env("BOB_GCP_CREDENTIALS") do credentials = fix_env_newlines(credentials) - File.mkdir_p!("/boto") - File.write!("/boto/keyfile.json", credentials) + File.mkdir_p!("/gcp") + File.write!("/gcp/keyfile.json", credentials) end end diff --git a/priv/scripts/docker/sign.sh b/priv/scripts/docker/sign.sh index 392cdce..a93c6c2 100755 --- a/priv/scripts/docker/sign.sh +++ b/priv/scripts/docker/sign.sh @@ -9,7 +9,7 @@ tag=$2 digest=sha256:$(docker buildx imagetools inspect --raw ${repo}:${tag} | sha256sum | cut -d ' ' -f 1) # Cloud KMS is called as the service account whose key Bob.Application writes here -export GOOGLE_APPLICATION_CREDENTIALS=/boto/keyfile.json +export GOOGLE_APPLICATION_CREDENTIALS=/gcp/keyfile.json # This command has a tendency to intermittently fail cosign sign --yes --key ${BOB_COSIGN_KEY} ${repo}@${digest} || diff --git a/priv/scripts/prepare_elixir_builds_text.exs b/priv/scripts/prepare_elixir_builds_text.exs deleted file mode 100755 index 721c02f..0000000 --- a/priv/scripts/prepare_elixir_builds_text.exs +++ /dev/null @@ -1,61 +0,0 @@ -# Usage: -# -# cd /path/to/bob -# rm -rf tmp && mkdir tmp && cd tmp -# aws s3 ls s3://s3.hex.pm/builds/elixir --recursive | grep -v builds.txt > elixir-ls.txt -# aws s3 cp s3://s3.hex.pm/builds/elixir . --recursive -# elixir ../priv/scripts/prepare_elixir_builds_text.exs -# aws s3 cp builds.txt s3://s3.hex.pm/builds/elixir/builds.txt -# curl -XPURGE https://repo.hex.pm/builds/elixir/builds.txt - -defmodule Line do - defstruct [:datetime, :path, :ref, :sha, :otp] - - def from_line(line) do - pattern = ~r|builds/elixir/(.*?)(-otp-.*)?\.zip| - - [date, time, _, path] = String.split(line) - - [ref, otp] = - case Regex.run(pattern, path, capture: :all_but_first) do - [ref] -> [ref, ""] - [ref, otp] -> [ref, otp] - end - - %Line{ - datetime: "#{date}T#{time}Z", - path: path, - ref: ref, - otp: otp - } - end - - def get_sha(line, repo_dir) do - System.cmd("git", ["checkout", line.ref], cd: repo_dir) - {sha, 0} = System.cmd("git", ["rev-parse", "HEAD"], cd: repo_dir) - %{line | sha: String.trim(sha)} - end - - def to_builds_txt(line) do - [line.ref <> line.otp, line.sha, line.datetime] |> Enum.join(" ") - end -end - -# aws s3 ls s3://s3.hex.pm/builds/elixir --recursive -input = "elixir-ls.txt" -output = "builds.txt" -repo = "https://github.com/elixir-lang/elixir.git" -repo_dir = "elixir" - -if !File.dir?(repo_dir) do - System.cmd("git", ["clone", repo, repo_dir]) -end - -content = - File.stream!(input) - |> Enum.map(&Line.from_line/1) - |> Enum.map(&Line.get_sha(&1, repo_dir)) - |> Enum.map_join("\n", &Line.to_builds_txt/1) - -File.write!(output, content) -{_, 0} = System.cmd("sort", ["-u", "-k1,1", "-o", output, output]) diff --git a/priv/scripts/prepare_otp_builds_text.exs b/priv/scripts/prepare_otp_builds_text.exs deleted file mode 100755 index 59c1d74..0000000 --- a/priv/scripts/prepare_otp_builds_text.exs +++ /dev/null @@ -1,51 +0,0 @@ -defmodule Line do - defstruct [:datetime, :path, :ref, :sha, :otp] - - def from_line(line) do - pattern = ~r|builds/otp/ubuntu-14.04/(.*?)\.tar.gz| - - [date, time, _, path] = String.split(line) - - [ref, otp] = - case Regex.run(pattern, path, capture: :all_but_first) do - [ref] -> [ref, ""] - [ref, otp] -> [ref, otp] - end - - %Line{ - datetime: "#{date}T#{time}Z", - path: path, - ref: ref, - otp: otp - } - end - - def get_sha(line, repo_dir) do - System.cmd("git", ["checkout", line.ref], cd: repo_dir) - {sha, 0} = System.cmd("git", ["rev-parse", "HEAD"], cd: repo_dir) - %{line | sha: String.trim(sha)} - end - - def to_builds_txt(line) do - [line.ref <> line.otp, line.sha, line.datetime] |> Enum.join(" ") - end -end - -# aws s3 ls s3://s3.hex.pm/builds/otp/ubuntu-14.04 --recursive -input = "otp-ls.txt" -output = "builds.txt" -repo = "https://github.com/erlang/otp.git" -repo_dir = "otp" - -if !File.dir?(repo_dir) do - System.cmd("git", ["clone", repo, repo_dir]) -end - -(content = - File.stream!(input) - |> Enum.map(&Line.from_line/1) - |> Enum.map(&Line.get_sha(&1, repo_dir)) - |> Enum.map_join("\n", &Line.to_builds_txt/1)) - -File.write!(output, content) -{_, 0} = System.cmd("sort", ["-u", "-k1,1", "-o", output, output]) diff --git a/priv/scripts/utils.sh b/priv/scripts/utils.sh deleted file mode 100755 index 68d5449..0000000 --- a/priv/scripts/utils.sh +++ /dev/null @@ -1,23 +0,0 @@ -# $1 = service -# $2 = keys -function fastly_purge { - fastly_purge_request $1 "$2" - sleep 4 - fastly_purge_request $1 "$2" - sleep 4 - fastly_purge_request $1 "$2" -} - -# $1 = service -# $2 = keys -function fastly_purge_request { - curl \ - --fail \ - -X POST \ - -H "Fastly-Key: ${BOB_FASTLY_KEY}" \ - -H "Accept: application/json" \ - -H "Content-Length: 0" \ - -H "surrogate-key: ${2}" \ - "https://api.fastly.com/service/${1}/purge" -} -