From f7fb5cdf164105d79c7b13803baff5921e1e396f Mon Sep 17 00:00:00 2001 From: Crystal Augustus <91073224+caugustus-sourcegraph@users.noreply.github.com> Date: Wed, 16 Mar 2022 13:42:10 -0400 Subject: [PATCH] Swap codeinsights-db docker image to be based off postgres instead of Timescale (#32616) * Allow postgres uid to be specified for the postgres docker image. Defaults to the existing values (999 / 99) * Switch codeinsights to vanilla postgres and preserve postgres uid * Fix build errors --- docker-images/codeinsights-db/Dockerfile | 7 ------- docker-images/codeinsights-db/build.sh | 4 +++- docker-images/postgres-12-alpine/Dockerfile | 9 ++++++--- docker-images/postgres-12-alpine/build.sh | 5 ++++- 4 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 docker-images/codeinsights-db/Dockerfile diff --git a/docker-images/codeinsights-db/Dockerfile b/docker-images/codeinsights-db/Dockerfile deleted file mode 100644 index cca27a2a2849..000000000000 --- a/docker-images/codeinsights-db/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM timescale/timescaledb:2.0.0-pg12-oss - -# hadolint ignore=DL3017 -RUN apk -U upgrade && apk add --no-cache \ - busybox \ - wget - diff --git a/docker-images/codeinsights-db/build.sh b/docker-images/codeinsights-db/build.sh index 37a450e5d85f..879170a341a4 100755 --- a/docker-images/codeinsights-db/build.sh +++ b/docker-images/codeinsights-db/build.sh @@ -3,4 +3,6 @@ set -ex cd "$(dirname "${BASH_SOURCE[0]}")" -docker build -t "${IMAGE:-sourcegraph/codeinsights-db}" . +# This image is identical to our "sourcegraph/postgres-12-alpine" image, +# but runs with a different uid to avoid migration issues +IMAGE="${IMAGE:-sourcegraph/codeinsights-db}" POSTGRES_UID=70 PING_UID=700 ../postgres-12-alpine/build.sh diff --git a/docker-images/postgres-12-alpine/Dockerfile b/docker-images/postgres-12-alpine/Dockerfile index c2429f627e9c..e7bb6e0f548f 100644 --- a/docker-images/postgres-12-alpine/Dockerfile +++ b/docker-images/postgres-12-alpine/Dockerfile @@ -1,11 +1,14 @@ FROM postgres:12.7-alpine@sha256:b815f145ef6311e24e4bc4d165dad61b2d8e4587c96cea2944297419c5c93054 +ARG PING_UID=99 +ARG POSTGRES_UID=999 + # We modify the postgres user/group to reconcile with our previous debian based images # and avoid issues with customers migrating. RUN apk add --no-cache nss su-exec shadow &&\ - groupmod -g 99 ping &&\ - usermod -u 999 postgres &&\ - groupmod -g 999 postgres &&\ + groupmod -g $PING_UID ping &&\ + usermod -u $POSTGRES_UID postgres &&\ + groupmod -g $POSTGRES_UID postgres &&\ mkdir -p /data/pgdata-12 && chown -R postgres:postgres /data &&\ chown -R postgres:postgres /var/lib/postgresql &&\ chown -R postgres:postgres /var/run/postgresql diff --git a/docker-images/postgres-12-alpine/build.sh b/docker-images/postgres-12-alpine/build.sh index ed6ab60cbb0c..8927e62b7cb1 100755 --- a/docker-images/postgres-12-alpine/build.sh +++ b/docker-images/postgres-12-alpine/build.sh @@ -3,4 +3,7 @@ set -ex cd "$(dirname "${BASH_SOURCE[0]}")" -docker build -t "${IMAGE:-index.docker.io/sourcegraph/postgres-12-alpine}" . +POSTGRES_UID=${POSTGRES_UID:-999} +PING_UID=${PING_UID:-99} + +docker build -t "${IMAGE:-index.docker.io/sourcegraph/postgres-12-alpine}" --build-arg POSTGRES_UID="$POSTGRES_UID" --build-arg PING_UID="$PING_UID" .