Merge pull request #829 from AnishSarkar22/fix/docker

fix: run alembic migrations unconditionally on startup & add update docs
This commit is contained in:
Rohan Verma 2026-02-20 15:13:32 -08:00 committed by GitHub
commit dbe0290399
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 71 additions and 8 deletions

View file

@ -89,6 +89,12 @@ docker run -d -p 3000:3000 -p 8000:8000 -p 5133:5133 -v surfsense-data:/data --n
After starting, open [http://localhost:3000](http://localhost:3000) in your browser. After starting, open [http://localhost:3000](http://localhost:3000) in your browser.
**Update (Automatic updates with Watchtower):**
```bash
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock nickfedor/watchtower --run-once surfsense
```
For Docker Compose, manual installation, and other deployment options, check the [docs](https://www.surfsense.com/docs/). For Docker Compose, manual installation, and other deployment options, check the [docs](https://www.surfsense.com/docs/).
### How to Realtime Collaborate (Beta) ### How to Realtime Collaborate (Beta)

View file

@ -212,11 +212,10 @@ run_migrations() {
echo "✅ Database migrations complete" echo "✅ Database migrations complete"
} }
# Run migrations on first start or when explicitly requested # Always run migrations on startup - alembic upgrade head is safe to run
if [ ! -f /data/.migrations_run ] || [ "${FORCE_MIGRATIONS:-false}" = "true" ]; then # every time. It only applies pending migrations (never re-runs applied ones,
# never calls downgrade). This ensures updates are applied automatically.
run_migrations run_migrations
touch /data/.migrations_run
fi
# ================================================ # ================================================
# Environment Variables Info # Environment Variables Info

View file

@ -4,9 +4,6 @@ description: Setting up SurfSense using Docker
--- ---
# Docker Installation
This guide explains how to run SurfSense using Docker, with options ranging from quick single-command deployment to full production setups. This guide explains how to run SurfSense using Docker, with options ranging from quick single-command deployment to full production setups.
## Quick Start with Docker 🐳 ## Quick Start with Docker 🐳
@ -126,6 +123,53 @@ docker rm surfsense
docker rm surfsense && docker volume rm surfsense-data docker rm surfsense && docker volume rm surfsense-data
``` ```
### Updating
To update SurfSense to the latest version, you can use either of the following methods:
<Callout type="info">
Your data is safe! The `surfsense-data` volume persists across updates, and database migrations are applied automatically on every startup.
</Callout>
**Option 1: Using Watchtower (one-time auto-update)**
[Watchtower](https://github.com/nicholas-fedor/watchtower) can automatically pull the latest image, stop the old container, and restart it with the same options:
```bash
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
nickfedor/watchtower \
--run-once surfsense
```
<Callout type="warn">
Use the `nickfedor/watchtower` fork. The original `containrrr/watchtower` is no longer maintained and may fail with newer Docker versions.
</Callout>
**Option 2: Manual Update**
```bash
# Stop and remove the current container
docker rm -f surfsense
# Pull the latest image
docker pull ghcr.io/modsetter/surfsense:latest
# Start with the new image
docker run -d -p 3000:3000 -p 8000:8000 -p 5133:5133 \
-v surfsense-data:/data \
--name surfsense \
--restart unless-stopped \
ghcr.io/modsetter/surfsense:latest
```
If you used Docker Compose for the quick start, updating is simpler:
```bash
docker compose -f docker-compose.quickstart.yml pull
docker compose -f docker-compose.quickstart.yml up -d
```
--- ---
## Full Docker Compose Setup (Production) ## Full Docker Compose Setup (Production)
@ -395,6 +439,20 @@ pgAdmin is included in the Docker setup to help manage your PostgreSQL database.
- Password: `postgres` (or your custom POSTGRES_PASSWORD) - Password: `postgres` (or your custom POSTGRES_PASSWORD)
6. Click "Save" to connect 6. Click "Save" to connect
## Updating (Full Docker Compose)
To update the full Docker Compose production setup to the latest version:
```bash
# Pull latest changes
git pull
# Rebuild and restart containers
docker compose up --build -d
```
Database migrations are applied automatically on startup.
## Useful Docker Commands ## Useful Docker Commands
### Container Management ### Container Management