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.
VPS Requirements (Minimum Recommended)¶
- 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¶
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:
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.
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
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¶
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¶
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).
Step 4 β Enable HTTPS (Recommended)¶
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
Change http to https in domain as below
CSRF_TRUSTED_ORIGINS=https://example.com,https://www.example.com
- re-deploy new changes
Step 6 β Schedule Automatic Database Backup (Optional but Recommended)¶
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.pyto find out admin url - Login using Admin Credentials
- In the Periodic Tasks, Click on Crontabs -> Add crontab
- Save
- In the Periodic Tasks, Click on Periodic Tasks -> Add Periodic Tasks
- 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:
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
π― Recommended Next Steps¶
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