  networks:
    blinko-network:
      driver: bridge

  services:
    blinko-website:
      image: blinkospace/blinko:latest
      container_name: blinko-website
      user: 1003:1004
      environment:
        NODE_ENV: production
        NEXTAUTH_URL: https://blinko.sandstorm.chat
        # IMPORTANT: If you want to use sso, you must set NEXTAUTH_URL to your own domain
        NEXT_PUBLIC_BASE_URL: https://blinko.sandstorm.chat
        # IMPORTANT: Replace this with your own secure secret key!	
        NEXTAUTH_SECRET: OMGFAKLSJFhdksltf1324321431JDSALK
        DATABASE_URL: postgresql://postgres:mysecretpassword@postgres:5432/postgres
      depends_on:
        postgres:
          condition: service_healthy
      # Make sure you have enough permissions.
      volumes:
        - /personal/blinko/app:/app/.blinko 
      restart: always
      logging:
        options:
          max-size: "10m"
          max-file: "3"
      ports:
        - 1111:1111
      healthcheck:
        test: ["CMD", "wget", "--spider", "-q", "http://blinko-website:1111/"]
        interval: 30s 
        timeout: 10s   
        retries: 5     
        start_period: 30s 
      networks:
        - blinko-network

    postgres:
      image: postgres:14
      container_name: blinko-postgres
      user: 1001:1001
      restart: always
      ports:
        - 5435:5432
      environment:
        POSTGRES_DB: postgres
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: mysecretpassword
        TZ: America/New_York
      # Persisting container data
      # Make sure you have enough permissions.
      volumes:
        - ./blinko/.db:/var/lib/postgresql/data
      healthcheck:
        test:
          ["CMD", "pg_isready", "-U", "postgres", "-d", "postgres"]
        interval: 5s
        timeout: 10s
        retries: 5
      networks:
        - blinko-network
