Self-Hosting
Baby Basics is designed to be self-hosted. Your data stays on your server.
Requirements
- A Linux server (LXC container, VPS, or bare metal)
- Docker and Docker Compose
- A domain name with DNS pointing to your server
- A reverse proxy with SSL (Nginx Proxy Manager recommended)
Server Setup
1. Prepare the Server
Install Docker and create the application directories:
# Install Docker (Debian/Ubuntu)
apt update && apt install -y docker.io docker-compose-plugin git curl postgresql-client
# Create app and backup directories
mkdir -p /opt/baby-basics /opt/backups
# Create a deploy user
adduser --disabled-password deploy
usermod -aG docker deploy
2. Clone the Repository
cd /opt/baby-basics
git clone https://github.com/FindingJohnny/baby-basics.git .
3. Configure Environment
cp apps/api/.env.example .env
Edit .env with your values:
| Variable | Description | Example |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | postgresql://baby:STRONG_PASSWORD@db:5432/baby_basics |
JWT_SECRET | Random 64-character string for token signing | openssl rand -hex 32 |
BASE_URL | Public URL of your instance | https://baby.yourfamily.com |
PORT | API port (default 3000) | 3000 |
NODE_ENV | Set to production | production |
4. Deploy
./infra/deploy.sh prod
The deploy script handles: database migrations, Docker image builds, container restarts, and health verification. If the health check fails, it automatically rolls back.
Reverse Proxy
Point your domain at the server and configure your reverse proxy to forward traffic to port 3000. With Nginx Proxy Manager (GUI-based):
- Add a proxy host for your domain
- Set the upstream to
<server-ip>:3000 - Enable SSL with Let's Encrypt
- Enable "Force SSL"
Backups
Daily automated backups via cron:
# Add to crontab (runs at 3 AM daily, keeps 30 days)
crontab -e
0 3 * * * /opt/baby-basics/infra/backup.sh >> /opt/backups/backup.log 2>&1
Manual backup:
./infra/backup.sh
Rollback
If something goes wrong after a deploy:
./infra/rollback.sh
This restores the pre-deploy database snapshot and reverts to the previous code version.
Updating
Automated Deployments
If you're using the official repository with GitHub Actions:
- Dev environment: Push to
developbranch triggers automatic deployment - Prod environment: Push to
mainbranch triggers automatic deployment
The CI pipeline runs tests first, then SSH-deploys to the target environment.
Manual Deployments
For self-hosted forks or manual updates:
cd /opt/baby-basics
git pull origin main # or develop for dev environment
./infra/deploy.sh prod # or dev for dev environment
The deploy script takes a backup before applying changes, so rollback is always available.
GitHub Actions Setup
To enable automated deployments, configure these repository secrets:
| Secret | Description |
|---|---|
DEV_SSH_KEY | Private SSH key for dev server |
DEV_HOST | Dev server IP or hostname |
PROD_SSH_KEY | Private SSH key for prod server |
PROD_HOST | Prod server IP or hostname |
DEPLOY_USER | SSH user on both servers (usually deploy) |
The workflows are at .github/workflows/deploy-dev.yml and .github/workflows/deploy-prod.yml.
Monitoring
We recommend Uptime Kuma (self-hosted) to monitor the health endpoint:
- URL:
https://your-domain.com/api/v1/health - Interval: 30 seconds
- Expected status: 200