Skip to content

Commit

Permalink
app: Install available postgresql-client and pin docker digest (#811)
Browse files Browse the repository at this point in the history
Fix example app build.
  • Loading branch information
doshitan authored Dec 20, 2024
1 parent 58d75d2 commit 27b31cd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM python:3-alpine as release
# Run `make update-docker-digest` to update the image
FROM python:3-alpine@sha256:657dbdb20479a6523b46c06114c8fec7db448232f956a429d3cc0606d30c1b59 as release

RUN adduser --system --disabled-password --no-create-home app

Expand All @@ -7,7 +8,7 @@ WORKDIR /app
RUN apk update && \
apk --no-cache add \
aws-cli~=2 \
postgresql14-client~=14
postgresql17-client~=17

COPY requirements.txt ./

Expand Down
3 changes: 3 additions & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ release-build:
--platform=linux/amd64 \
$(OPTS) \
.

update-docker-digest:
../template-only-bin/update-docker-digest Dockerfile
17 changes: 17 additions & 0 deletions template-only-bin/update-docker-digest
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail

file="$1"

function get_image_digest() {
local image_name=$1
skopeo inspect --format "{{ .Digest }}" "docker://${image_name}"
}

images_used_with_digest=$(perl -lne 'print $1 if /^FROM (.*)@.*$/' "${file}")

while IFS= read -r image; do
latest_digest=$(get_image_digest "${image}")
sed -ri "s|^FROM ${image}@[[:alnum:]:]+ (.*)|FROM ${image}@${latest_digest} \1|" "${file}"
done <<< "${images_used_with_digest}"

0 comments on commit 27b31cd

Please sign in to comment.