This guide uses Docker Compose to run Cannery, a self-hosted firearm and ammunition inventory tracker.
For Docker installation, see Docker.
mkdir -p ~/cannery && cd ~/cannery
Create a docker-compose.yml file with the following content:
version: '3.8'
services:
cannery:
image: shibaobun/cannery:latest
restart: unless-stopped
ports:
- "4000:4000"
environment:
- DATABASE_URL=postgresql://cannery:your_secure_password@cannery-db:5432/cannery
- SECRET_KEY_BASE= # Generate with: docker run -it shibaobun/cannery /app/priv/random.sh
- HOST=http://localhost:4000 # Change to your domain
- PORT=4000
- REGISTRATION=invite_only # Options: public, invite_only, disabled
depends_on:
- cannery-db
cannery-db:
image: postgres:15-alpine
restart: unless-stopped
volumes:
- cannery_postgres_data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=cannery
- POSTGRES_USER=cannery
- POSTGRES_PASSWORD=your_secure_password
volumes:
cannery_postgres_data:
Generate a secure secret key base for your installation:
docker run -it shibaobun/cannery /app/priv/random.sh
Copy the output and add it to your docker-compose.yml file as the SECRET_KEY_BASE value.
docker compose up -d
Check that all services are running:
docker compose ps
git clone https://gitea.bubbletea.dev/shibao/cannery cannery
cd cannery
Edit the docker-compose.yml file to match your environment:
SECRET_KEY_BASE valueHOST variable to your domaindocker compose up -d
For production use, run Cannery behind a reverse proxy like nginx or Traefik:
server {
listen 443 ssl;
server_name cannery.yourdomain.com;
ssl_certificate /path/to/certificate.crt;
ssl_certificate_key /path/to/private.key;
location / {
proxy_pass http://127.0.0.1:4000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
REGISTRATION=invite_only or disabled for private deploymentsdocker compose logs -f
# Pull latest images
docker compose pull
# Restart services
docker compose up -d
# Backup the PostgreSQL database
docker exec cannery-cannery-db-1 pg_dump -U cannery cannery > backup-$(date +%F).sql
# Restore the PostgreSQL database
docker exec -i cannery-cannery-db-1 psql -U cannery cannery < backup.sql
Monitor the application status:
# Check container status
docker compose ps
# Check logs for errors
docker compose logs cannery
# Verify database connectivity
docker compose exec cannery-db psql -U cannery -c "SELECT version();"
latestAny questions?
Feel free to contact us. Find all contact information on our contact page.