flatpak / flat-manager

Manager for flatpak repositories
Apache License 2.0
173 stars 42 forks source link

Podman/Docker compose support for flat-manager #125

Open toastxc opened 3 months ago

toastxc commented 3 months ago

I noticed that there is a Dockerfile, but the README describes how to install postgres to the host...

I think there should be an example.container-compose.yml file at least, since its best practice to run databases in a container.

I made an example already however I'm having issues with it.

version: "3.8"
networks:
  flat:

services:
  db:
    image: postgres
    ports:
     - "${POSTGRES_PORTS}"
    volumes:
      - ./db:/data
    env_file:
      - .env
    networks:
      - flat
    environment:
      POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
      POSTGRES_DB: "${POSTGRES_DB}"

  backend:
    build: .
    ports:
      -  "${REPO_PORTS}"
    command: ["/usr/local/bin/flat-manager"]
    env_file:
      - .env
    depends_on:
      - db
      # restart: always
    networks:
      - flat
    volumes:
        - ./config.json:/config.json
# We want this for the diesel CLI app
DATABASE_URL=postgres://postgres:PSWD@db:5432/repo
# config file location
REPO_CONFIG=/config.json

POSTGRES_PASSWORD=PSWD
POSTGRES_PORTS=5432:5432
POSTGRES_DB="repo"

REPO_PORTS=8082:8082
toastxc commented 3 months ago

I managed to get passed the config file issue for compose, but this reverse proxy is giving me grief.

toastxc commented 3 months ago

...how do people use this server? I don't understand why theres no information on reverse proxying or containers

nalsai commented 2 months ago

I use flatman with traefik as a reverse proxy. Here is my docker-compose file:

version: "3.9"

services:
  flat-manager:
    image: ghcr.io/flatpak/flat-manager:13841c5a6667d6ab9d0849523c9e49ad5f34dda8  
    restart: unless-stopped
    volumes:
      - ./flatman:/flat-manager
    depends_on:
      - "db"
    #ports:
      #- 8080:8080
    networks:
      - internal
      - traefik
    environment:
      HOME: /flat-manager
      REPO_CONFIG: /flat-manager/config.json
      RUST_LOG: info #error
      #RUST_BACKTRACE: full
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.flatpak.rule=Host(`flatpak.hachiman.nils.moe`, `flatpak.nils.moe`)"
      - "traefik.http.routers.flatpak.entrypoints=websecure"
      - "traefik.http.routers.flatpak.tls.certresolver=letsencrypt"
      - "traefik.http.services.flatpak.loadbalancer.server.port=8080"

  db:
    image: postgres:14-alpine
    restart: unless-stopped
    volumes:
      - ./postgresql:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: repo
      POSTGRES_USER: flatmanager
      POSTGRES_PASSWORD: PASSWORD
    networks:
      - internal

networks:
  traefik:
    external: true
  internal:

And this is my flatman config:

{
    "repos": {
        "": {
            "path": "/flat-manager/repo",
            "collection-id": "moe.nils.flatpak",
            "suggested-repo-name": "nalsai",
            "runtime-repo-url": "https://dl.flathub.org/repo/flathub.flatpakrepo",
            "gpg-key": "7E56B236E04AD5F0",
            "base-url": "https://flatpak.nils.moe/repo",
            "subsets": {
                "all": {
                    "collection-id": "moe.nils.flatpak",
                    "base-url": null
                }
            }
        }
    },
    "base-url": "https://flatpak.nils.moe",
    "host": "0.0.0.0",
    "port": 8080,
    "delay-update-secs": 10,
    "database-url": "postgres://flatmanager:PASSWORD@db:5432/repo",
    "build-repo-base": "/flat-manager/build-repo",
    "build-gpg-key": "7E56B236E04AD5F0",
    "gpg-homedir": "/flat-manager/gpg",
    "secret": "SECRET"
}