Skip to content

Deployment Guide

This guide explains how to deploy Digistore on a fresh VPS.

PART 1 β€” Full VPS Setup Pipeline (Infrastructure) - In this part, you will prepare the server from scratch: - Create secure sudo user - Configure firewall and basic system tools - Install Docker & Docker Compose - Setup SSH deploy keys - Configure HTTP Nginx reverse proxy

Result: Your VPS becomes production-ready for Docker apps.

PART 2 β€” Digistore Project Deployment - In this part, you will deploy the Digistore application itself: - Configure production environment variables - Start full Docker stack (Django, PostgreSQL, Redis, Celery, Nginx) - Run database migrations and collect static files - Enable HTTPS with Let’s Encrypt - Setup automatic database backups

Result: Your live Digistore website running on your domain with SSL and background workers.


Tech Stack Used in Production

  • This deployment uses:
  • Docker & Docker Compose (production)
  • Gunicorn (inside container)
  • Nginx (reverse proxy)
  • HTTPS with Let’s Encrypt (Certbot)
  • PostgreSQL + Redis (containers)
  • Celery Worker & Beat

Target audience: Developers who purchased the product and want a reliable, production-grade deployment.

  • OS : Ubuntu 22.04 LTS or Above
  • CPU : 2 vCPU
  • RAM : 4 GB
  • Disk : 40 GB SSD
  • Ports open : 22, 80, 443

πŸ”₯ PART 1: FULL VPS SETUP PIPELINEE (STEP-BY-STEP)

This is the exact flow on a fresh VPS.


STEP 1 --- Login to VPS as root

ssh root@YOUR_VPS_IP
apt update & apt upgrade -y

STEP 2 --- Create secure sudo user

tmp=$(mktemp) && \
curl -fsSL https://raw.githubusercontent.com/rajsolodev/pykits-dev-deploy/main/create-sudo-user.sh -o "$tmp" && \
trap 'rm -f "$tmp"' EXIT && \
bash "$tmp"

You will be asked to:

  • enter username (e.g. john)
  • set password (e.g. john123)

After success:

exit
ssh new_user@YOUR_VPS_IP

STEP 3 --- Base VPS Setup (Firewall + Tools)

Login as new user, then:

tmp=$(mktemp) && \
curl -fsSL https://raw.githubusercontent.com/rajsolodev/pykits-dev-deploy/main/vps-base-setup.sh -o "$tmp" && \
trap 'rm -f "$tmp"' EXIT && \
bash "$tmp"

This script will:

  • Run system update (optional)
  • Install basic tools (git, python3, make etc)
  • Configure UFW firewall
  • Allow ports 22, 80, 443

STEP 4 β€” Install Docker (If Not Already Installed)

tmp=$(mktemp) && \
curl -fsSL https://raw.githubusercontent.com/rajsolodev/pykits-dev-deploy/main/install-docker.sh -o "$tmp" && \
trap 'rm -f "$tmp"' EXIT && \
bash "$tmp"

After this:

πŸ‘‰ Logout & login again so docker group applies.

exit
ssh newuser@VPS_IP

STEP 5 β€” Setup Project & Clone Repo

tmp=$(mktemp) && \
curl -fsSL https://raw.githubusercontent.com/rajsolodev/pykits-dev-deploy/main/project-setup.sh -o "$tmp" && \
trap 'rm -f "$tmp"' EXIT && \
bash "$tmp"

This will:

  • Generate SSH deploy key
  • Ask you to add it to GitHub Deploy Keys
  • Test SSH connection
  • Clone your private repo into: /home/USER/PROJECT_NAME

STEP 6 β€” Setup HTTP Nginx

Change Directory to Project Folder

cd project_folder_name

then run below in terminal:

tmp=$(mktemp) && \
curl -fsSL https://raw.githubusercontent.com/rajsolodev/pykits-dev-deploy/main/setup-http-nginx.sh -o "$tmp" && \
trap 'rm -f "$tmp"' EXIT && \
bash "$tmp"

This will:

  • Ask for your domain name (e.g. example.com)
  • Create an HTTP Nginx config (default.conf) for your site
  • Route traffic from port 80 β†’ your app container
  • Enable access to /.well-known/acme-challenge/ for SSL verification

πŸ”₯ PART 2: Digistore Project Deployment (STEP-BY-STEP)

Step 1 β€” Go to Project Directory

cd ~/PROJECT_NAME

Step 2 β€” Setup Environment Variables

Create your .env file: cp .env.example .env Open and configure all required values: nano .env

Make sure these are correctly set:

  • MAKEFILE_ENV=prod
  • SECRET_KEY
  • Database credentials
  • Redis credentials
  • Domain name
  • Any third-party API keys ⚠ Do not skip any required env values β€” production containers may fail silently.

Step 3 β€” Deploy Project

cd project_folder
make deploy

This will:

  • Git Pull
  • Start full Docker stack
  • Run database migrations
  • Collect static files on Cloud

Your Site must be running on HTTP Now check your site url (http://example.com) on any browser, make sure there is no https (https://example.com).

After your site is reachable on HTTP and domain is pointing to VPS IP:

tmp=$(mktemp) && \
curl -fsSL https://raw.githubusercontent.com/rajsolodev/pykits-dev-deploy/main/install-ssl.sh -o "$tmp" && \
trap 'rm -f "$tmp"' EXIT && \
bash "$tmp"

This will:

  • Issue Let's Encrypt certificate
  • Switch Nginx to HTTPS
  • Enable HTTP β†’ HTTPS redirect
  • Verify auto-renew with dry-run

Step 5 - Change CSRF_TRUSTED_ORIGINS (Only If HTTPS Enabled)

  • Edit .env
cd project_folder_name
nano .env

Change http to https in domain as below CSRF_TRUSTED_ORIGINS=https://example.com,https://www.example.com - re-deploy new changes

  make deploy

  • cd project_folder
  • Create Super user make superuser
  • Remember Superuser can not purchase any product on website means cant act as customer. User registered through website's Registration Page are customers can make purchase.
  • Visit Admin URL on browser, check main url.py to find out admin url
  • Login using Admin Credentials
  • In the Periodic Tasks, Click on Crontabs -> Add crontab
    Minutes: 0
    Hours: 2
    Day_of_month: *
    Month_of_year: *
    Day_of_week: *
    Cron Timezone: UTC
    
  • Save
  • In the Periodic Tasks, Click on Periodic Tasks -> Add Periodic Tasks
    Name: Database backup on cloud every night 2AM
    Tasks (registered): select "core.tasks.run_db_backup"
    Enable: Checked
    Crontab Schedule: select "0 2 * * * (m/h/dM/MY/d) UTC" 
    
  • Save Note: You can create your own crontab of your specific time.

πŸ” FUTURE DEPLOYMENTS

For future updates, If Later, you make any code change and push it to github just run:

make deploy

This will safely:

  • Pull latest code
  • Rebuild containers
  • Apply migrations
  • Collect static files

Zero infra work needed.


⚠️ Important Production Notes

  • ❌ Never run docker compose down -v on production
  • ❌ Never delete Docker volumes on production
  • βœ… Always keep off-server database backups
  • βœ… Monitor disk space regularly
  • βœ… Keep OS security updates enabled

After first deploy:

  • Create Django superuser make superuser
  • Verify SSL auto-renewal
  • Verify database backups in cloud storage
  • Test restore process once on staging

You must Check Make Commands