Docker images of PostgreSQL with PLV8 extensions installed.
- Decide for which version of Postgres you want to create an image with the
plv8
extension. Let's use Postgres 12.10 in the example. - Check in the matrix of Postgresql extension versions supported by AWS what version of the
plv8
extension is supported. In our example, this is2.13.4
. - Create a new directory named by a template
postgresql-{postgresVersion}-plv8-{plv8Version}
, e.g.postgresql-12.10-plv8-2.3.14
- Create a
Dockerfile
file inside a new directory based on the file taken from another directory. A directory with the highest version in the name will be the best choice because it will most likely work. - Adjust the
plv8
and Postgresql versions in the Dockerfile.FROM postgres:12.10 (...) ENV PLV8_VERSION=2.3.14
- Add a new image definition in the
docker-compose.yml
file in the root directory of this repo, e.g.:postgresql-12.10-plv8-2.3.14: build: postgresql-12.10-plv8-2.3.14
- Build a docker image from a command line:
IMPORTANT: When you build an image on Apple Mac with M1 / M2, etc. chipset, Docker will build it using
docker build postgresql-12.10-plv8-2.3.14
linux/arm64
architecture and the build will fail becauseplv8
developers do not currently support this architecture. In this case, run the command below:docker build --platform linux/x86_64 postgresql-12.10-plv8-2.3.14
- When docker finishes building an image, look for the image ID at the end of the docker build log:
alternatively, you can find the image ID by running a command:
=> => writing image sha256:71119e257b8c271519293393c350b71f50210f8038dad83e0886ce0517f554e8
and checking thedocker images
IMAGE ID
column, e.g.REPOSITORY TAG IMAGE ID CREATED SIZE <none> <none> 71119e257b8c 23 minutes ago 420MB
- Tag a new docker image with an appropriate name containing Postgresql and
plv8
extension versions, e.g.:You can check if it is tagged correctly by running againdocker tag 71119e257b8c draakhan/postgresql-plv8:12.10-2.3.14
docker images
command:REPOSITORY TAG IMAGE ID CREATED SIZE draakhan/postgresql-plv8 12.10-2.3.14 71119e257b8c About an hour ago 420MB
- Login to your docker repository (by default, it is Docker Hub) using
docker login
command and then push the tagged image to the Docker Hub:docker push draakhan/postgresql-plv8:12.10-2.3.14
- Now, you're ready to use the uploaded image in your project's
Dockerfile
by adding this statement:FROM draakhan/postgresql-plv8:12.10-2.3.14