Build postgres using dockerfile

- use dockerfile to install postgis during build
This commit is contained in:
Sam 2024-07-06 10:26:08 +01:00
parent 7df7970414
commit 591a9ce48f
1 changed files with 9 additions and 1 deletions

View File

@ -4,8 +4,16 @@
backend = "docker"; backend = "docker";
projects = { projects = {
"db".settings.services."db".service = { "db".settings.services."db".service = {
image = "postgres:16";
restart = "unless-stopped"; restart = "unless-stopped";
build.context = "/nix/store";
build.dockerfile = builtins.baseNameOf "${pkgs.writeScript "pgDockerfile" ''
FROM postgres:16
# install packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-16-postgis \
&& rm -rf /var/lib/apt/lists/*
''}";
environment = { environment = {
POSTGRES_PASSWORD = "balls1234"; POSTGRES_PASSWORD = "balls1234";
POSTGRES_USER = "admin"; POSTGRES_USER = "admin";