Add docker image build (#28)

Build docker image on top of `postgres:16` and push it to DockerHub
on merge to the main branch.

Also fixed linking issue in Makefile
pull/209/head
Andrew Pogrebnoi 2 years ago committed by Kai Wagner
parent 9b41a2f24c
commit 482f67f18a
  1. 25
      .github/workflows/docker-push-tde-image.yaml
  2. 3
      Makefile
  3. 15
      README.md
  4. 28
      docker/Dockerfile
  5. 1
      docker/pg-tde-create-ext.sql

@ -0,0 +1,25 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
run: |
docker build -t perconalab/postgres-tde-ext:${{ github.sha }} -t perconalab/postgres-tde-ext:latest . -f docker/Dockerfile
docker push -a perconalab/postgres-tde-ext

@ -44,4 +44,5 @@ include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
SHLIB_LINK += $(filter -lcrypto -lssl, -ljson-c $(LIBS))
SHLIB_LINK += $(filter -lcrypto -lssl, $(LIBS))
SHLIB_LINK += -ljson-c

@ -96,6 +96,21 @@ wget https://github.com/Percona-Lab/postgres-tde-ext/releases/download/latest/pg
sudo dpkg -i pgtde-pgdg16.deb
```
## Run in Docker
You can find docker images built from the current main branch on [Docker Hub](https://hub.docker.com/r/perconalab/postgres-tde-ext). Images build on top of [postgres:16](https://hub.docker.com/_/postgres) official image. To run it:
```
docker run --name pg-tde -e POSTGRES_PASSWORD=mysecretpassword -d perconalab/postgres-tde-ext
```
It builds and adds `pg_tde` extension to Postgres 16. Relevant `postgresql.conf` and `tde_conf.json` are created in `/etc/postgresql/` inside the container. This dir is exposed as volume.
See https://hub.docker.com/_/postgres on usage.
You can also build a docker image manually with:
```
docker build . -f ./docker/Dockerfile -t your-image-name
```
## Base commit
This is based on the heap code as of the following commit:

@ -0,0 +1,28 @@
FROM postgres:16
RUN apt-get update; \
apt-get install -y --no-install-recommends \
curl \
libjson-c-dev \
libssl-dev \
gcc \
postgresql-server-dev-16 \
make
WORKDIR /opt/postgres-tde-ext
COPY . .
RUN make USE_PGXS=1 && \
make USE_PGXS=1 install
RUN cp /usr/share/postgresql/postgresql.conf.sample /etc/postgresql/postgresql.conf; \
echo "shared_preload_libraries = 'pg_tde'" >> /etc/postgresql/postgresql.conf; \
echo "pg_tde.keyringConfigFile = '/etc/postgresql/tde_conf.json'" >> /etc/postgresql/postgresql.conf; \
echo "{'provider': 'file','datafile': '/tmp/pgkeyring',}" > /etc/postgresql/tde_conf.json; \
chown postgres /etc/postgresql/tde_conf.json; \
mkdir -p /docker-entrypoint-initdb.d
COPY ./docker/pg-tde-create-ext.sql /docker-entrypoint-initdb.d/pg-tde-create-ext.sql
VOLUME /etc/postgresql/
CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]

@ -0,0 +1 @@
CREATE EXTENSION pg_tde;
Loading…
Cancel
Save