Skip to content

Deploying a Saleor App

Introduction

Saleor is an open-source, headless commerce platform built with GraphQL, Django, and React. Deploying Saleor with a Dockerfile on Klutch.sh gives you reproducible builds, managed secrets, and persistent storage—all configured from klutch.sh/app. This guide covers installation, Dockerfile setup, environment variables, storage, Nixpacks overrides, and sample checks to verify your deployment.


Prerequisites

  • A Klutch.sh account (sign up)
  • A GitHub repository containing your Saleor Dockerfile (GitHub is the only supported git source)
  • External PostgreSQL and Redis
  • Domain and TLS for secure storefront/admin access

For onboarding, see the Quick Start.


Architecture and ports

  • Saleor API serves HTTP on internal port 8000. Choose HTTP traffic in Klutch.sh and set the internal port to 8000.
  • Persistent storage is recommended for media and static files; databases live in Postgres, cache in Redis.

Repository layout

saleor/
├── Dockerfile # Must be at repo root for auto-detection
└── README.md

Keep secrets out of Git; store them in Klutch.sh environment variables.


Installation (local) and starter commands

Build and run locally (ensure Postgres/Redis are reachable):

Terminal window
docker build -t saleor-local .
docker run -p 8000:8000 \
-e DATABASE_URL=postgres://user:pass@localhost:5432/saleor \
-e REDIS_URL=redis://localhost:6379/0 \
-e SECRET_KEY=$(openssl rand -hex 32) \
saleor-local

Dockerfile for Saleor (production-ready)

Place this at the repo root; Klutch.sh auto-detects Dockerfiles.

FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
ENV PORT=8000
ENV DJANGO_SETTINGS_MODULE=saleor.settings
EXPOSE 8000
CMD ["gunicorn", "saleor.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "4"]

Notes:

  • Pin Python and Saleor requirements for stability.
  • Adjust worker count based on your resource limits.

Environment variables (Klutch.sh)

Set these before deploying:

  • PORT=8000
  • DATABASE_URL=postgres://<user>:<password>@<host>:5432/<db>
  • REDIS_URL=redis://<host>:6379/0
  • SECRET_KEY=<secure-random-hex>
  • ALLOWED_HOSTS=example-app.klutch.sh
  • Optional: MEDIA_ROOT=/app/media, STATIC_ROOT=/app/static
  • Email settings if sending mail: EMAIL_URL (e.g., smtp://user:pass@smtp-host:587)

If deploying without the Dockerfile and relying on Nixpacks:

  • NIXPACKS_PYTHON_VERSION=3.11
  • NIXPACKS_START_CMD=gunicorn saleor.wsgi:application --bind 0.0.0.0:8000 --workers 4

Attach persistent volumes

Add storage in Klutch.sh (path and size only):

  • /app/media — uploaded images/files.
  • /app/static — collected static assets (if you persist them between deployments).

Ensure paths are writable inside the container.


Deploy Saleor on Klutch.sh (Dockerfile workflow)

  1. Push your repository—with the Dockerfile at the root—to GitHub.
  2. Open klutch.sh/app, create a project, and add an app.
  3. Select HTTP traffic and set the internal port to 8000.
  4. Add the environment variables above (Postgres, Redis, secret key, hosts, and optional email/media settings).
  5. Attach volumes at /app/media (and /app/static if desired) sized for your catalog assets.
  6. Deploy. Your app will be reachable at https://example-app.klutch.sh; finalize configuration in the admin panel.

Sample checks

Landing page:

Terminal window
curl -I https://example-app.klutch.sh

GraphQL endpoint sanity check:

Terminal window
curl -X POST https://example-app.klutch.sh/graphql/ \
-H "Content-Type: application/json" \
-d '{"query":"{ __typename }"}'

Health checks and production tips

  • Add an HTTP readiness probe to / or /health if you expose one.
  • Keep DB/Redis credentials and SECRET_KEY in Klutch.sh secrets; rotate regularly.
  • Run collectstatic during your build or release; store static/media on volumes or external storage (S3) if preferred.
  • Pin image and dependency versions; test upgrades in staging before production rollout.
  • Back up Postgres and media storage regularly.

Saleor on Klutch.sh delivers reproducible Docker builds, managed secrets, and persistent media—without extra YAML or CI steps. Configure ports, env vars, and storage, then launch your headless commerce backend.