diff --git a/build/package/docker/pginit.sql b/build/package/docker/pginit.sql new file mode 100755 index 000000000..26280234c --- /dev/null +++ b/build/package/docker/pginit.sql @@ -0,0 +1,5 @@ +-- These commands are run with psql inside the container after postgres starts. +CREATE USER kwild WITH PASSWORD 'kwild' SUPERUSER REPLICATION; +CREATE DATABASE kwild OWNER kwild; +-- the tests db: +CREATE DATABASE kwil_test_db OWNER kwild; diff --git a/build/package/docker/postgres.dockerfile b/build/package/docker/postgres.dockerfile index eda7132ec..16582cc9d 100644 --- a/build/package/docker/postgres.dockerfile +++ b/build/package/docker/postgres.dockerfile @@ -2,7 +2,7 @@ FROM postgres:16.1 # Inject the init script that makes the kwild superuser and a kwild database # owned by that kwild user, as well as a kwil_test_db database for tests. -COPY ./init.sql /docker-entrypoint-initdb.d/init.sql +COPY ./pginit.sql /docker-entrypoint-initdb.d/init.sql # Override the default entrypoint/command to include the additional configuration CMD ["postgres", "-c", "wal_level=logical", "-c", "max_wal_senders=10", "-c", "max_replication_slots=10", "-c", "max_prepared_transactions=2"] diff --git a/scripts/build/docker b/scripts/build/docker index 16f25dff5..e6c5f436d 100755 --- a/scripts/build/docker +++ b/scripts/build/docker @@ -2,6 +2,8 @@ # # Build docker image # +# This must be run from the repository root. +# set -eu @@ -30,4 +32,5 @@ BUILD_ARGS="${BUILD_ARGS} --build-arg go_race=${GO_RACEFLAG:-}" export DOCKER_BUILDKIT=1 -docker build . -t "${IMAGE}:${GIT_VERSION}" -t "${IMAGE}:latest" ${BUILD_ARGS} -f "./build/package/docker/${DOCKER_FILE}" --progress=auto +docker build . -t "${IMAGE}:${GIT_VERSION}" -t "${IMAGE}:latest" ${BUILD_ARGS} \ + -f "./build/package/docker/${DOCKER_FILE}" --progress=auto diff --git a/scripts/publish/postgres b/scripts/publish/postgres new file mode 100755 index 000000000..4bf769d85 --- /dev/null +++ b/scripts/publish/postgres @@ -0,0 +1,18 @@ +#!/usr/bin/env sh +# +# Build and push the Kwil postgres docker image +# + +set -eu + +ROOT=$(dirname "$0")/../.. + +cd "$ROOT"/build/package/docker + +: ${TAG:=latest} + +echo Building kwild for multiarch and pushing to dockerhub, tag: ${TAG} + +docker build --platform linux/amd64,linux/arm64/v8 -t kwildb/postgres:${TAG} \ + --label "postgres configured for Kwil DB" \ + --push -f postgres.dockerfile .