Skip to main content

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:

VariableDescriptionExample
DATABASE_URLPostgreSQL connection stringpostgresql://baby:STRONG_PASSWORD@db:5432/baby_basics
JWT_SECRETRandom 64-character string for token signingopenssl rand -hex 32
BASE_URLPublic URL of your instancehttps://baby.yourfamily.com
PORTAPI port (default 3000)3000
NODE_ENVSet to productionproduction

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):

  1. Add a proxy host for your domain
  2. Set the upstream to <server-ip>:3000
  3. Enable SSL with Let's Encrypt
  4. 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 develop branch triggers automatic deployment
  • Prod environment: Push to main branch 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:

SecretDescription
DEV_SSH_KEYPrivate SSH key for dev server
DEV_HOSTDev server IP or hostname
PROD_SSH_KEYPrivate SSH key for prod server
PROD_HOSTProd server IP or hostname
DEPLOY_USERSSH 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