Pular para o conteúdo principal

Deploying with Docker

Don't want to run it yourself?

Casdoor Cloud gives you a dedicated Casdoor instance that we host and keep upgraded for you, from $25/month with no per-user fees.

This page describes deploying Casdoor with Docker or Docker Compose, with optional reverse proxy (Traefik, Nginx, Caddy) configs.

Pré-requisitos​

  • Docker
  • Docker Compose (for the compose method)
  • A domain pointing to your server (for reverse proxy setups)

Deployment options​

Using Docker Compose​

Create a docker-compose.yml file:

services:
casdoor:
image: casbin/casdoor:latest
container_name: casdoor
restart: unless-stopped
ports:
- "8000:8000"
environment:
- GIN_MODE=release
volumes:
- ./conf:/conf
- ./logs:/logs
networks:
- casdoor-network

networks:
casdoor-network:
driver: bridge

Start the service:

docker-compose up -d

Reverse Proxy Configuration​

For production deployments, it's recommended to use a reverse proxy with TLS certificates. Choose your preferred reverse proxy:

Traefik with Docker Labels​

Create a docker-compose.yml with Traefik labels:

services:
traefik:
image: traefik:v2.10
container_name: traefik
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik/acme.json:/acme.json
command:
- --api.dashboard=true
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesresolvers.letsencrypt.acme.email=your-email@example.com
- --certificatesresolvers.letsencrypt.acme.storage=/acme.json
- --certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web
networks:
- casdoor-network

casdoor:
image: casbin/casdoor:latest
container_name: casdoor
restart: unless-stopped
environment:
- GIN_MODE=release
volumes:
- ./conf:/conf
- ./logs:/logs
labels:
- "traefik.enable=true"
- "traefik.http.routers.casdoor.rule=Host(`your-domain.com`)"
- "traefik.http.routers.casdoor.entrypoints=websecure"
- "traefik.http.routers.casdoor.tls.certresolver=letsencrypt"
- "traefik.http.services.casdoor.loadbalancer.server.port=8000"
networks:
- casdoor-network

networks:
casdoor-network:
driver: bridge

Create the acme.json file:

touch traefik/acme.json
chmod 600 traefik/acme.json

Configuração​

Create the necessary configuration directories​

mkdir -p conf logs

Download the Casdoor configuration files​

wget https://raw.githubusercontent.com/casdoor/casdoor/master/conf/app.conf -O conf/app.conf
wget https://raw.githubusercontent.com/casdoor/casdoor/master/init_data.json.template -O conf/init_data.json

Edit conf/app.conf to match your environment settings​

nota

The default user of Casdoor has a uid and gid of 1000. When using volume mapping with SQLite (or any storage requiring file permissions), ensure that the path (e.g., /folder/of/app.conf in the example above) is accessible to uid 1000. This avoids permission errors like permission denied when Casdoor writes to mapped volumes.

Testando​

After deployment, visit your domain in your browser:

  • Docker Run/Compose only: http://your-server-ip:8000
  • With Reverse Proxy: https://your-domain.com

Solução de problemas​

Check container logs​

# For docker-compose
docker-compose logs casdoor

# For docker run
docker logs casdoor

Verify reverse proxy configuration​

# Check if containers are running
docker ps

# Test connectivity
curl -I http://localhost:8000

SSL Certificate Issues​

  • Ensure your domain points to the correct server IP
  • Check that ports 80 and 443 are open in your firewall
  • Verify DNS propagation with nslookup your-domain.com