Skip to content

Commit

Permalink
build: Use PostgreSQL 16
Browse files Browse the repository at this point in the history
  • Loading branch information
kesara committed Oct 2, 2024
1 parent 4973757 commit a24c6e1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.DO_SPACES_DEV_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_SPACES_DEV_ACCESS_KEY }}
run: |
aws s3 cp --quiet --endpoint-url=${{ secrets.DO_SPACES_DEV_ENDPOINT }} s3://wagtail/ietfwww.dump ietfwww.dump
aws s3 cp --quiet --endpoint-url=${{ secrets.DO_SPACES_DEV_ENDPOINT }} s3://wagtail/ietfwww.dump ./docker/database/ietfwww.dump
aws s3 cp --quiet --endpoint-url=${{ secrets.DO_SPACES_DEV_ENDPOINT }} s3://wagtail/media.tgz media.tgz
- name: Deploy to containers
Expand Down
2 changes: 1 addition & 1 deletion dev/deploy-to-container/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function main () {
src: [
'docker/db.Dockerfile',
'docker/scripts/db-import.sh',
'ietfwww.dump'
'docker/database/ietfwww.dump'
]
}, {
dockerfile: 'docker/db.Dockerfile',
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:

database:
restart: on-failure
image: postgres:14.6
image: postgres:16
volumes:
- "./docker/database:/docker-entrypoint-initdb.d/"
environment:
Expand Down
15 changes: 6 additions & 9 deletions docker/database/02_convert_native_dump_to_sql_and_restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ FILE=$(ls -1 *.dump | head)
set -e

restore_dump() {
# use docker_process_sql function from docker-entrypoint.sh in the Postgres container
# pg_restore -xO means restore no owner, no permissions
pg_restore -xO -f - | sed -e '/CREATE SCHEMA public/d' | docker_process_sql
# use docker_process_sql function from docker-entrypoint.sh in the Postgres container
# pg_restore -xO means restore no owner, no permissions
cat "$1" | pg_restore -xO -f - | sed -e '/CREATE SCHEMA public/d' | docker_process_sql
}

if [ -s "${FILE}" ]; then
case $FILE in
echo "Restoring the archive..."
cat $FILE | restore_dump
;;
esac
echo "Restoring the archive..."
restore_dump "$FILE"
else
echo "No dump, starting fresh."
echo "No dump, starting fresh."
fi

6 changes: 3 additions & 3 deletions docker/db.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================
# --- Builder Stage ---
# =====================
FROM postgres:14.6 AS builder
FROM postgres:16 AS builder

ENV POSTGRES_PASSWORD=password
ENV POSTGRES_USER=postgres
Expand All @@ -10,15 +10,15 @@ ENV POSTGRES_HOST_AUTH_METHOD=trust
ENV PGDATA=/data

COPY docker/scripts/db-import.sh /docker-entrypoint-initdb.d/
COPY ietfwww.dump /
COPY docker/database/ietfwww.dump /

RUN ["sed", "-i", "s/exec \"$@\"/echo \"skipping...\"/", "/usr/local/bin/docker-entrypoint.sh"]
RUN ["/usr/local/bin/docker-entrypoint.sh", "postgres"]

# ===================
# --- Final Image ---
# ===================
FROM postgres:14.6
FROM postgres:16
LABEL maintainer="IETF Tools Team <tools-discuss@ietf.org>"

COPY --from=builder /data $PGDATA
Expand Down

0 comments on commit a24c6e1

Please sign in to comment.