inventree / InvenTree

Open Source Inventory Management System
https://docs.inventree.org
MIT License
4.24k stars 764 forks source link

[Docker] Update postgres version #6961

Open SchrodingersGat opened 6 months ago

SchrodingersGat commented 6 months ago

We currently hard-code postgres:13 into the docker setup. We should look at updating.

Note that the server container will need updated dependent packages to support this, and we would need to carefully test that such an update does not cause any issues with existing users who are migrating from postgres:13 to the newer version.

rballard-ghd commented 1 week ago

I've currently just run into this issue, and it would be great if it could be fixed.

Background:

Issue: When I run sudo docker compose run --rm inventree-server invoke update, after sometime, the below occurs

pg_dump --dbname=postgresql://inventree:xxxx@postgres/inventreedb --format=custom
CommandConnectorError: Error running:  pg_dump --dbname=postgresql://inventree:xxxx@postgres/inventreedb --format=custom
pg_dump: error: server version: 17.0 (Debian 17.0-1.pgdg110+1); pg_dump version: 13.16
pg_dump: error: aborting because of server version mismatch

Docker Stack:

volumes:
  postgres-db-data:
  inventree_data:

services:

  # PostgreSQL
  ###########################
  postgres:
    image: postgis/postgis:17-3.4
    restart: unless-stopped
    env_file: "./.env" 
    ports:
      - "5432:5432"
    environment:
      - PGDATA=/var/lib/postgresql/data/pgdata
    volumes:
      - postgres-db-data:/var/lib/postgresql/data/pgdata

  # Inventree
  ###########################
  inventree-redis:
    image: redis:7.0
    restart: always
    expose:
      - 6379

  inventree-server:
    image: inventree/inventree:stable
    restart: unless-stopped
    volumes:
      - inventree_data:/home/inventree/data:z
    ports:
      - "8000:8000"
    env_file:
        - ./inventree/.env
    environment:
      INVENTREE_CACHE_HOST: inventree-redis
      INVENTREE_CACHE_PORT: 6379
    depends_on:
      - postgres

  inventree-worker:
    # If you wish to specify a particular InvenTree version, do so here
    image: inventree/inventree:stable
    container_name: inventree-worker
    command: invoke worker
    depends_on:
        - inventree-server
    env_file:
        - ./inventree/.env
    environment:
      INVENTREE_CACHE_HOST: inventree-redis
      INVENTREE_CACHE_PORT: 6379
    volumes:
        # Data volume must map to /home/inventree/data
        - inventree_data:/home/inventree/data:z
    restart: unless-stopped

Note that some environment variables are set in the .env via a pipeline which pulls passwords etc from an Azure Keyvault.

SchrodingersGat commented 1 week ago

@rballard-ghd we currently don't have a solution to this - in particular we need to work out a proper workflow for updating an in-place database. Do you have any expertise in this area?