Skip to content

Commit

Permalink
build,scripts: postgres dockerfile and multiarch build
Browse files Browse the repository at this point in the history
  • Loading branch information
jchappelow committed Feb 29, 2024
1 parent 7654dc4 commit ec37209
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions build/package/docker/pginit.sql
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion build/package/docker/postgres.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
5 changes: 4 additions & 1 deletion scripts/build/docker
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# Build docker image
#
# This must be run from the repository root.
#

set -eu

Expand Down Expand Up @@ -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
18 changes: 18 additions & 0 deletions scripts/publish/postgres
Original file line number Diff line number Diff line change
@@ -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 .

0 comments on commit ec37209

Please sign in to comment.