Skip to content

Commit 7e65463

Browse files
committed
fix aptkey
1 parent 25cd6c7 commit 7e65463

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

containers/event-db-migrations/Earthfile

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,37 @@ package:
2020
WORKDIR /eventdb
2121

2222
# Add psql
23-
RUN apt-get update && apt-get install -y --no-install-recommends \
24-
apt \
25-
wget \
26-
gnupg2 \
27-
ca-certificates \
28-
lsb-release \
29-
apt-transport-https \
30-
&& rm -rf /var/lib/apt/lists/* && \
31-
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
32-
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
33-
apt-get update && \
34-
apt-get install -y --no-install-recommends postgresql-14 && \
35-
apt-get remove -y wget gnupg2 lsb-release apt-transport-https && \
36-
apt-get autoremove -y && \
37-
apt-get clean && rm -rf /var/lib/apt/lists/*
23+
RUN apt-get update && \
24+
# Install dependencies needed for adding the key and postgres
25+
apt-get install -y --no-install-recommends \
26+
wget \
27+
gnupg2 \
28+
ca-certificates \
29+
lsb-release \
30+
apt-transport-https && \
31+
\
32+
# Create the keyring directory
33+
install -m 0755 -d /etc/apt/keyrings && \
34+
\
35+
# Download, de-armor, and save the PostgreSQL key
36+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
37+
gpg --dearmor -o /etc/apt/keyrings/postgresql.gpg && \
38+
\
39+
# Set permissions for the key
40+
chmod 644 /etc/apt/keyrings/postgresql.gpg && \
41+
\
42+
# Create the sources list, pointing to the key
43+
echo "deb [signed-by=/etc/apt/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
44+
\
45+
# Update apt and install postgresql
46+
apt-get update && \
47+
apt-get install -y --no-install-recommends postgresql-14 && \
48+
\
49+
# Clean up
50+
apt-get remove -y wget gnupg2 lsb-release apt-transport-https && \
51+
apt-get autoremove -y && \
52+
apt-get clean && \
53+
rm -rf /var/lib/apt/lists/*
3854

3955
# Add refinery
4056
COPY +build/refinery .
@@ -56,7 +72,7 @@ package:
5672

5773
ENTRYPOINT ["./entry.sh"]
5874
SAVE IMAGE migrations:$tag
59-
75+
6076
# TODO: Enable this when CI supports passing -P dynamically
6177
# test:
6278
# FROM earthly/dind:alpine

0 commit comments

Comments
 (0)