Skip to content

Commit 6f4a76f

Browse files
committed
feat: build sync instance images (internal#70)
1 parent 379058a commit 6f4a76f

File tree

6 files changed

+103
-1
lines changed

6 files changed

+103
-1
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ stages:
33

44
include:
55
- local: '/extended/build-images-ci.yml'
6+
- local: '/sync-instance/build-images-ci.yml'

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
# Postgres Images
22

3+
## Extended images
4+
35
PostgreSQL Docker images with various additional extensions. Includes HypoPG, pg_hint_plan, more.
46

57
Available versions: 9.6, 10, 11, 12.
68

79
Use these images with Database Lab, when you need HypoPG or anything else.
810

911
Proposals to add more extensions are welcome in the project repo: https://gitlab.com/postgres-ai/custom-images/-/issues
12+
13+
## Sync Instance images
14+
15+
PostgreSQL Docker images with WAL-G.
16+
17+
Available versions: 9.6, 10, 11, 12.
18+
19+
Use these images when you need set up a replica fetching WAL archives from an S3-compatible storage.
20+
21+
Example of sync instance usage with backups in Google Cloud Storage:
22+
23+
```bash
24+
docker run \
25+
--name sync-instance \
26+
--env PGDATA=/var/lib/postgresql/pgdata \
27+
--env WALG_GS_PREFIX="gs://{BUCKET}/{SCOPE}" \
28+
--env GOOGLE_APPLICATION_CREDENTIALS="/etc/sa/credentials.json" \
29+
--volume /home/service_account.json:/etc/sa/credentials.json \
30+
--volume /var/lib/dblab/data:/var/lib/postgresql/pgdata:rshared \
31+
--detach \
32+
postgresai/sync-instance:12
33+
```
34+
See the full list of configuration options in the [WAL-G project](https://github.com/wal-g/wal-g#configuration) repo.
File renamed without changes.

extended/build-images-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name: docker:19.03.5-dind
77
script:
88
- apk add --no-cache bash
9-
- bash ./extended/ci_docker_build_push.sh
9+
- bash ./ci_docker_build_push.sh
1010

1111
.only_var_template: &only_tag_release
1212
only:

sync-instance/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ARG PG_SERVER_VERSION=12
2+
3+
FROM postgres:${PG_SERVER_VERSION}
4+
5+
ARG PG_SERVER_VERSION
6+
ENV PG_SERVER_VERSION=${PG_SERVER_VERSION:-12}
7+
8+
ARG WALG_VERSION
9+
ENV WALG_VERSION=${WALG_VERSION:-0.2.15}
10+
11+
# Install dependecies.
12+
RUN apt-get update \
13+
&& apt-get install --no-install-recommends -y ca-certificates wget \
14+
&& wget --quiet -O /tmp/wal-g.linux-amd64.tar.gz "https://github.com/wal-g/wal-g/releases/download/v${WALG_VERSION}/wal-g.linux-amd64.tar.gz" \
15+
&& tar -zxvf /tmp/wal-g.linux-amd64.tar.gz && mv wal-g /usr/local/bin/ \
16+
&& rm -rf /tmp/* \
17+
&& apt-get purge -y --auto-remove \
18+
&& apt-get clean -y autoclean \
19+
&& rm -rf /var/lib/apt/lists/*

sync-instance/build-images-ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
.job_template: &build_image_definition
2+
image: docker:19
3+
stage: build-image
4+
services:
5+
- alias: docker
6+
name: docker:19.03.5-dind
7+
script:
8+
- apk add --no-cache bash
9+
- bash ./ci_docker_build_push.sh
10+
11+
.only_var_template: &only_tag_release
12+
rules:
13+
- if: '$CI_COMMIT_TAG =~ /^[0-9.]+$/'
14+
15+
.template: &sync_image_definition
16+
variables: &sync_image_vars
17+
REGISTRY_USER: "${DH_CI_REGISTRY_USER}"
18+
REGISTRY_PASSWORD: "${DH_CI_REGISTRY_PASSWORD}"
19+
REGISTRY: "${DH_CI_REGISTRY}"
20+
DOCKER_FILE: "sync-instance/Dockerfile"
21+
DOCKER_NAME: "postgresai/sync-instance"
22+
23+
build-sync-postgres-9-6-image-latest:
24+
<<: *build_image_definition
25+
<<: *only_tag_release
26+
<<: *sync_image_definition
27+
variables:
28+
PG_SERVER_VERSION: "9.6"
29+
<<: *sync_image_vars
30+
TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_TAG}"
31+
32+
build-sync-postgres-10-image-latest:
33+
<<: *build_image_definition
34+
<<: *only_tag_release
35+
<<: *sync_image_definition
36+
variables:
37+
PG_SERVER_VERSION: "10"
38+
<<: *sync_image_vars
39+
TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_TAG}"
40+
41+
build-sync-postgres-11-image-latest:
42+
<<: *build_image_definition
43+
<<: *only_tag_release
44+
<<: *sync_image_definition
45+
variables:
46+
PG_SERVER_VERSION: "11"
47+
<<: *sync_image_vars
48+
TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_TAG}"
49+
50+
build-sync-postgres-12-image-latest:
51+
<<: *build_image_definition
52+
<<: *only_tag_release
53+
<<: *sync_image_definition
54+
variables:
55+
PG_SERVER_VERSION: "12"
56+
<<: *sync_image_vars
57+
TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_TAG}"

0 commit comments

Comments
 (0)