Skip to content

Commit

Permalink
Swap codeinsights-db docker image to be based off postgres instead of…
Browse files Browse the repository at this point in the history
… Timescale (sourcegraph#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
  • Loading branch information
caugustus-sourcegraph authored Mar 16, 2022
1 parent ec20754 commit f7fb5cd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
7 changes: 0 additions & 7 deletions docker-images/codeinsights-db/Dockerfile

This file was deleted.

4 changes: 3 additions & 1 deletion docker-images/codeinsights-db/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions docker-images/postgres-12-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion docker-images/postgres-12-alpine/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" .

0 comments on commit f7fb5cd

Please sign in to comment.