SurfSense icon indicating copy to clipboard operation
SurfSense copied to clipboard

Errors starting container via podman

Open woutercoppens opened this issue 6 months ago • 6 comments

I'm trying to run surfsense in containers via podman, but I'm getting errors.

I created the following quadlet:

`cat surfsense_backend.container [Unit] Description=SurfSense Backend After=pgvector.service Requires=pgvector.service

[Container] ContainerName = "surfsense_backend" Image = "ghcr.io/modsetter/surfsense_backend:latest" PublishPort = "8000:8000"

Volume = %h/.containers/surfsense/backend:/app

EnvironmentFile = %h/.containers/surfsense/backend/.env Environment="DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense" Environment="PYTHONPATH=/app" Environment="UVICORN_LOOP=asyncio" Environment="UNSTRUCTURED_HAS_PATCHED_LOOP=1"

AutoUpdate=registry Network=host

[Service] Restart=always TimeoutStartSec=900

[Install] WantedBy=default.target`

Pgvector is running in another container (with the db surfsense created). Pgadmin is also running in another container.

With the line 'Volume = %h/...' I get an error that /app/main.py is not found. This is logical as /app is mounted as external volume.

jun 06 15:46:18 aipc surfsense_backend[52815]: 2bbd8cbca60d00dc6d2eb1647ff35d10c0208df3a4d91eb12c86e814d3103d84 jun 06 15:46:18 aipc podman[52815]: 2025-06-06 15:46:18.48163319 +0200 CEST m=+0.012802402 image pull 7faa8f589806411ac4645b87c95885714749c4635b0da67301750490d1f555b9 ghcr.io/modsetter/surfsense_backend:latest jun 06 15:46:18 aipc surfsense_backend[52839]: python: can't open file '/app/main.py': [Errno 2] No such file or directory jun 06 15:46:18 aipc podman[52844]: 2025-06-06 15:46:18.576236387 +0200 CEST m=+0.012180898 container died 2bbd8cbca60d00dc6d2eb1647ff35d10c0208df3a4d91eb12c86e814d3103d84 (image=ghcr.io/modsetter/surfsense_backend:latest, name=surfsense> jun 06 15:46:18 aipc podman[52844]: 2025-06-06 15:46:18.612737277 +0200 CEST m=+0.048681788 container remove 2bbd8cbca60d00dc6d2eb1647ff35d10c0208df3a4d91eb12c86e814d3103d84 (image=ghcr.io/modsetter/surfsense_backend:latest, name=surfsen> jun 06 15:46:18 aipc systemd[3508]: surfsense_backend.service: Main process exited, code=exited, status=2/INVALIDARGUMENT ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ An ExecStart= process belonging to unit UNIT has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 2. jun 06 15:46:18 aipc systemd[3508]: surfsense_backend.service: Failed with result 'exit-code'.

Any idea what I'm doing wrong?

woutercoppens avatar Jun 06 '25 13:06 woutercoppens

Tagging my Docker boys @anshul7665 @cubxxw , help a brother out.

MODSetter avatar Jun 06 '25 19:06 MODSetter

Any reason why you are mounting your local volume on /app ?

The source code sits in the /app directory. So when you mount an external volume to /app, the mount will overlay/replace the contents of the /app directory inside the container. Hence python: can't open file '/app/main.py': .

anshul7665 avatar Jun 07 '25 03:06 anshul7665

This comes from your docker-compose.override.yml file:

' backend: image: ghcr.io/modsetter/surfsense_backend:latest ports: - "${BACKEND_PORT:-8000}:8000" volumes: - ./surfsense_backend:/app `

/app is also mounted.

woutercoppens avatar Jun 07 '25 08:06 woutercoppens

@woutercoppens Sorry, my reply was late. I would recommend using SurfSense instead, and for deployment, I suggest using Docker Compose.

cubxxw avatar Jun 08 '25 06:06 cubxxw

If you insist on deploying in this way, I recommend that you remove the unnecessary volume mounts.

[Unit]
Description=SurfSense Backend
After=pgvector.service
Requires=pgvector.service

[Container]
ContainerName = "surfsense_backend"
Image = "ghcr.io/modsetter/surfsense_backend:latest"
PublishPort = "8000:8000"
# remove:Volume = %h/.containers/surfsense/backend:/app
EnvironmentFile = %h/.containers/surfsense/backend/.env
Environment="DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense"
Environment="PYTHONPATH=/app"
Environment="UVICORN_LOOP=asyncio"
Environment="UNSTRUCTURED_HAS_PATCHED_LOOP=1"
AutoUpdate=registry
Network=host

[Service]
Restart=always
TimeoutStartSec=900

[Install]
WantedBy=default.target

cubxxw avatar Jun 08 '25 06:06 cubxxw

I also have the same issue python: can't open file '/app/main.py' . I would prefer to run through a single docker-compose` file. I have not changed anything other than combining two files. Can someone please review and suggest a path? Thank you

docker-compose.yml

services:
  db:
    image: ankane/pgvector:latest
    ports:
      - "${POSTGRES_PORT:-5432}:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=${POSTGRES_USER:-postgres}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
      - POSTGRES_DB=${POSTGRES_DB:-surfsense}

  pgadmin:
    image: dpage/pgadmin4
    ports:
      - "${PGADMIN_PORT:-5050}:80"
    environment:
      - PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:[email protected]}
      - PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:-surfsense}
    volumes:
      - pgadmin_data:/var/lib/pgadmin
    depends_on:
      - db

  frontend:
    image: ghcr.io/modsetter/surfsense_ui:latest
    ports:
      - "${FRONTEND_PORT:-3000}:3000"
    volumes:
      - ./surfsense_web:/app
      - /app/node_modules
    env_file:
      - ./surfsense_web/.env
    depends_on:
      - backend
    environment:
      - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://backend:8000}

  backend:
    image: ghcr.io/modsetter/surfsense_backend:latest
    ports:
      - "${BACKEND_PORT:-8000}:8000"
    volumes:
      - ./surfsense_backend:/app
    depends_on:
      - db
    env_file:
      - ./surfsense_backend/.env
    environment:
      - DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-surfsense}
      - PYTHONPATH=/app
      - UVICORN_LOOP=asyncio
      - UNSTRUCTURED_HAS_PATCHED_LOOP=1
      - LANGCHAIN_TRACING_V2=false
      - LANGSMITH_TRACING=false

volumes:
  postgres_data:
  pgadmin_data:       


dashingdon avatar Aug 16 '25 05:08 dashingdon