Domains
Configure domains for your Docker Compose application.
When using Docker Compose, adding a domain to a service is a straightforward process. This guide will walk you through the necessary steps to configure manual domains for your application.
Key Steps:
- Add the service to the
skitflow-network. - Use Traefik labels to configure routing.
Attention
Since v0.7.0 Skitflow support domains natively. This means that you can configure your domain directly in the Skitflow UI, without doing the rest of the steps check on the domains section.
Example Scenario
Let's consider an application with three components: a frontend, a backend, and a database. We'll start with a basic Docker Compose file and then enhance it with domain configuration.
version: "3.8"
services:
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
volumes:
- ./frontend:/app
ports:
- "3000:3000"
depends_on:
- backend
backend:
build:
context: ./backend
dockerfile: Dockerfile
volumes:
- ./backend:/app
ports:
- "5000:5000"
environment:
- DATABASE_URL=postgres://postgres:password@database:5432/mydatabase
depends_on:
- database
database:
image: postgres:13
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: mydatabase
volumes:
- db-data:/var/lib/postgresql/data
volumes:
db-data:Step 1: Add the Network
First, we'll add the skitflow-network to our services:
version: "3.8"
services:
frontend:
# ... (previous configuration)
networks:
- skitflow-network
backend:
# ... (previous configuration)
networks:
- skitflow-network
database:
# ... (previous configuration)
networks:
- skitflow-network
volumes:
db-data:
networks:
skitflow-network:
external: trueStep 2: Configuring Traefik Labels
Now, let's add Traefik labels to route domains to our services. We'll focus on the frontend and backend services:
version: "3.8"
services:
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
volumes:
- ./frontend:/app
expose:
- 3000
depends_on:
- backend
networks:
- skitflow-network
labels:
- traefik.enable=true
- traefik.http.routers.frontend-app.rule=Host(`frontend.skitflow.cloud`)
- traefik.http.routers.frontend-app.entrypoints=web
- traefik.http.services.frontend-app.loadbalancer.server.port=3000
backend:
build:
context: ./backend
dockerfile: Dockerfile
volumes:
- ./backend:/app
expose:
- 5000
environment:
- DATABASE_URL=postgres://postgres:password@database:5432/mydatabase
depends_on:
- database
networks:
- skitflow-network
labels:
- traefik.enable=true
- traefik.http.routers.backend-app.rule=Host(`backend.skitflow.cloud`)
- traefik.http.routers.backend-app.entrypoints=web
- traefik.http.services.backend-app.loadbalancer.server.port=5000
database:
# ... (same as before)
volumes:
db-data:
networks:
skitflow-network:
external: trueUnderstanding Traefik Labels
traefik.enable=trueEnables Traefik routing for the service.traefik.http.routers.<UNIQUE-RULE>.rule=Host('your-domain.skitflow.cloud')Specifies the domain for the servicetraefik.http.routers.<UNIQUE-RULE>.entrypoints=webSets the service to be accessible via HTTP.traefik.http.services.<UNIQUE-RULE>.loadbalancer.server.port=3000Specifies the port your service is using internally.
Note: Replace <UNIQUE-RULE> with a unique identifier for each service (e.g., frontend-app, backend-app, etc.).
Important Considerations
- Port Exposure: Use
exposeinstead ofportsto limit port access to the container network, avoiding exposure to the host machine. - DNS Configuration: Ensure you create
Arecords pointing to your domain in your DNS Provider Settings. - HTTPS: For HTTPS, you can use Let's Encrypt or other SSL/TLS certificates.
Deployment
With these configurations in place, you're now ready to deploy your application using Docker Compose. This setup should be sufficient to get your services up and running with custom domain routing through Traefik.