Anchor releases updates regularly with new features, improvements, and security fixes. This guide covers how to safely update your self-hosted instance.
Update Process
The update process varies slightly depending on whether you’re using the pre-built image or building from source.
Pre-built Image
For deployments using ghcr.io/zhfahim/anchor:latest:
Backup your data
Always backup before updating: Volume backup
Database backup (embedded)
Database backup (external)
# Create backup directory
mkdir -p ~/anchor-backups
# Stop Anchor (optional, for consistent backup)
docker compose down
# Backup data volume
docker run --rm \
-v anchor_data:/data \
-v ~/anchor-backups:/backup \
alpine tar czf /backup/anchor-data- $( date +%Y%m%d-%H%M%S ) .tar.gz -C /data .
The /data volume contains your JWT secret. Always include it in backups.
Pull the latest image
Download the newest version: docker compose pull anchor
This pulls the :latest tag or whatever tag you specified in your docker-compose.yml.
Stop the current container
Your data persists in the volume and won’t be deleted.
Start the updated container
The container will:
Start with the new image
Connect to the database (embedded or external)
Automatically run any pending migrations
Start the API and web services
Verify the update
Check logs to ensure successful startup: docker compose logs -f anchor
Look for:
[anchor] Postgres ready
[anchor] Running migrations...
No error messages
Health check passing
# Check container health
docker ps
# Should show "healthy" status
Building from Source
For deployments building from the repository:
Backup your data
Same as pre-built image (see above).
Pull latest source code
cd anchor
git pull origin main
Check for breaking changes:
Rebuild and restart
docker compose down
docker compose build --no-cache
docker compose up -d
The --no-cache flag ensures a clean build with all updates.
Verify the update
docker compose logs -f anchor
Version Pinning
For production, consider pinning to specific versions instead of using :latest:
services :
anchor :
image : ghcr.io/zhfahim/anchor:v1.2.3 # Pin to specific version
# or
image : ghcr.io/zhfahim/anchor:1.2 # Pin to minor version
Finding Available Versions
GitHub Releases
Docker tags
# Visit the releases page
open https://github.com/zhfahim/anchor/releases
Updating from Pinned Version
Update version in docker-compose.yml
services :
anchor :
image : ghcr.io/zhfahim/anchor:v1.3.0 # Update version
Apply update
docker compose pull anchor
docker compose up -d
Database Migrations
Anchor automatically runs database migrations on startup using Prisma Migrate.
How Migrations Work
Container starts
Entrypoint script connects to database
Runs: prisma migrate deploy
Applies any pending migrations
Starts application services
From docker-entrypoint.sh:
echo "[anchor] Running migrations..."
cd /app/server
./node_modules/.bin/prisma migrate deploy
Manual Migration
If you need to run migrations manually:
# Check migration status
docker exec anchor sh -c "cd /app/server && npx prisma migrate status"
# Apply pending migrations
docker exec anchor sh -c "cd /app/server && npx prisma migrate deploy"
# View migration history
docker exec anchor sh -c "cd /app/server && ls prisma/migrations"
Rolling Back Migrations
Prisma Migrate doesn’t support automatic rollbacks. To revert:
Restore database backup
Embedded PostgreSQL
External PostgreSQL
docker compose up -d
docker exec -i anchor pg_restore -U anchor -d anchor -h 127.0.0.1 -c \
< ~/anchor-backups/anchor-db-20240115.dump
docker compose down
Revert to previous image
services :
anchor :
image : ghcr.io/zhfahim/anchor:v1.2.0 # Previous version
docker compose pull anchor
docker compose up -d
Always test updates in a staging environment before applying to production.
Update Checklist
Before updating:
After updating:
Automated Updates
Using Watchtower
Automatically update containers when new images are available:
services :
anchor :
image : ghcr.io/zhfahim/anchor:latest
# ... anchor config ...
watchtower :
image : containrrr/watchtower
volumes :
- /var/run/docker.sock:/var/run/docker.sock
environment :
- WATCHTOWER_CLEANUP=true
- WATCHTOWER_POLL_INTERVAL=86400 # Check daily
- WATCHTOWER_INCLUDE_STOPPED=false
command : anchor # Only watch anchor container
Automatic updates can cause unexpected downtime. Only use in non-critical environments or with extensive monitoring.
Using Renovate
Automatically create PRs for version updates in your infrastructure repo:
{
"extends" : [ "config:base" ],
"docker" : {
"enabled" : true
},
"packageRules" : [
{
"matchPackageNames" : [ "ghcr.io/zhfahim/anchor" ],
"schedule" : [ "before 3am on Monday" ]
}
]
}
Zero-Downtime Updates
For high-availability deployments:
Use external database
Required for multi-instance deployments: environment :
- PG_HOST=postgres.example.com
Run multiple Anchor instances
Behind a load balancer: services :
anchor-1 :
image : ghcr.io/zhfahim/anchor:latest
environment :
- PG_HOST=postgres
anchor-2 :
image : ghcr.io/zhfahim/anchor:latest
environment :
- PG_HOST=postgres
nginx :
image : nginx:alpine
# Load balancer config
Rolling update
Update instances one at a time: # Update instance 1
docker compose stop anchor-1
docker compose pull anchor-1
docker compose up -d anchor-1
# Wait for health check
sleep 30
# Update instance 2
docker compose stop anchor-2
docker compose pull anchor-2
docker compose up -d anchor-2
Troubleshooting Updates
Update fails to start
# View detailed logs
docker compose logs anchor
# Check migration errors
docker compose logs anchor | grep -i migration
# Verify database connection
docker exec anchor pg_isready -h 127.0.0.1 -p 5432 -U anchor
Data loss concerns
# Verify volume still exists
docker volume ls | grep anchor
# Inspect volume contents
docker run --rm -v anchor_data:/data alpine ls -la /data
# Check JWT secret persisted
docker run --rm -v anchor_data:/data alpine cat /data/.jwt_secret
Reverting to previous version
# Stop current version
docker compose down
# Edit docker-compose.yml to use old version
# image: ghcr.io/zhfahim/anchor:v1.2.0
# Start old version
docker compose pull anchor
docker compose up -d
# Restore database if needed (see Rolling Back Migrations)
Migration stuck or failing
# Check migration status
docker exec anchor sh -c "cd /app/server && npx prisma migrate status"
# Mark migration as applied (use with caution)
docker exec anchor sh -c "cd /app/server && npx prisma migrate resolve --applied 20240115120000_migration_name"
# Reset and reapply (destructive!)
# Only for development/testing
docker exec anchor sh -c "cd /app/server && npx prisma migrate reset"
Release Notes
Always review release notes before updating:
Next Steps
Configuration Review configuration options
Database Options Learn about database management