Going to production
Build images in CI, deploy from a registry with health checks and rollbacks, and harden the host, Docker, Traefik and databases.
Run builds in CI so your server only deploys, then harden the host and the panel. This guide has two parts: a deployment pipeline and a hardening checklist.
Why build outside the server
Nixpacks, Heroku buildpacks and Dockerfile builds use a lot of CPU and RAM. A build on a small server can time out or freeze it, which takes every application on it down. Dockerfile builds are the heaviest.
You can add server resources or build elsewhere. Building in a CI pipeline (GitHub Actions, GitLab CI, Gitea Actions) and publishing an image is the recommended option. The server then only pulls and runs.
Deploy from CI
Before you start
- A repository with a
Dockerfile. - A container registry repository. This guide uses Docker Hub, with your username as the namespace and
exampleas the repository. DOCKERHUB_USERNAMEandDOCKERHUB_TOKENadded under the repository's Settings → Secrets (Actions).
Build and publish
Add a Dockerfile
FROM node:18-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
FROM base AS build
WORKDIR /app
COPY . .
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
ENV NODE_ENV=production
RUN pnpm run build
FROM base AS w3panel
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/dist ./dist
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/node_modules ./node_modules
EXPOSE 3000
CMD ["pnpm", "start"]Add the workflow
Replace namespace/example with your namespace and repository.
name: Build Docker images
on:
push:
branches: ["main"]
jobs:
build-and-push-dockerfile-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: |
namespace/example:latest
platforms: linux/amd64Each push to main builds the image and pushes it.
Create the application
Create an application, open Settings › Source and build, choose the Docker provider and enter namespace/example:latest as the Docker image. Click Save, then click Deploy on Overview.
Generate a domain
Open Settings › Domains, click Add domain, click the dice icon next to Host to generate a domain, and set Container port to 3000.
Deploy on every push
With Docker Hub, a webhook triggers the deployment.
Open the application's Deployments tab and copy the Webhook URL.
In your Docker Hub repository, open Webhooks, name the webhook and paste the URL.
The deployment only runs when the pushed tag matches the tag set in wtree Cloud.
For another registry, add a step at the end of the workflow that calls the API. This is the API method from Auto deploy.
- name: Trigger wtree Cloud deployment
run: |
curl -X 'POST' \
'https://<your-wtree-cloud-domain>/api/application.deploy' \
-H 'accept: application/json' \
-H 'x-api-key: YOUR-GENERATED-API-KEY' \
-H 'Content-Type: application/json' \
-d '{ "applicationId": "YOUR-APPLICATION-ID" }'Health checks and rollbacks
The example app serves /health, which returns 200 on port 3000. Your app needs a matching route.
Open Settings › Resources, then click Swarm settings in the Cluster settings card.
In Health check, paste (durations are in nanoseconds):
{
"Test": ["CMD", "curl", "-f", "http://localhost:3000/health"],
"Interval": 30000000000,
"Timeout": 10000000000,
"StartPeriod": 30000000000,
"Retries": 3
}In Update Config, paste:
{
"Parallelism": 1,
"Delay": 10000000000,
"FailureAction": "rollback",
"Order": "start-first"
}An unhealthy update rolls back to the previous version, and start-first keeps the old container running until the new one is up. See Zero downtime and Rollbacks.
Harden the instance
This is a baseline. Your threat model or regulatory scope may require more.
Shared responsibility
wtree Cloud secures the application layer. You secure the infrastructure.
| Layer | wtree Cloud | You |
|---|---|---|
| Access control | 2FA, passkeys, RBAC | Least-privilege roles, prompt offboarding |
| API and CLI | Organization-scoped tokens, optional expiration, Access to API/CLI permission | Who gets the permission, an expiration on every token, one token per integration |
| Secrets | Secrets provider integration; referenced values are not stored in the panel database | Operating the vault, least-privilege vault credentials, no raw secrets in env vars |
| Proxy and TLS | Traefik config, Let's Encrypt, HTTP to HTTPS redirect on applications | DNS, custom middlewares (HSTS, rate limiting), keeping the Traefik dashboard closed |
| Docker engine | None; wtree Cloud consumes Docker, it doesn't harden it | daemon.json, socket exposure, image provenance |
| Host OS | Automated security check (OS, UFW, SSH, Fail2Ban) for added servers | Patching, SSH, firewall, non-root accounts |
| Database | Internal and external credential toggle | Network placement, engine patching if self-managed |
| Backups | Runs backup and restore to your S3 destination | Bucket security, encryption at rest, retention, restore tests |
| Observability | Deployment notifications | Log shipping, alerting on auth anomalies |
Host
- Use Ubuntu or Debian LTS. They are the only families the automated security check targets.
- Enable automatic security patches.
- Use SSH keys only, and disable root login and password authentication. A non-standard port is optional and only reduces scan noise.
- Run Fail2Ban or CrowdSec against SSH.
- Allow only 22 (or your SSH port), 80 and 443, and install
ufw-docker. Keep the panel port3000closed publicly. Put it behind a domain (Certificates) or a VPN (Tailscale). - Use a non-root user in the
dockergroup for daily work. Keep root for provisioning and the SSH key wtree Cloud uses.
wtree Cloud runs most of these checks on servers you add. See Server security.
sudo apt update && sudo apt install -y unattended-upgrades apt-listchanges
sudo dpkg-reconfigure -plow unattended-upgrades
systemctl status unattended-upgradesPut your key in ~/.ssh/authorized_keys for the login user first, then edit /etc/ssh/sshd_config:
PubkeyAuthentication yes
PasswordAuthentication no
PermitRootLogin noReload, and keep your current session open until a new connection works. For a custom port, add Port 2222 (or your choice), reload, and match the firewall rule.
sudo systemctl reload sshdsudo apt install -y fail2ban
sudo tee /etc/fail2ban/jail.local <<'EOF'
[sshd]
enabled = true
mode = aggressive
bantime = 1h
findtime = 10m
maxretry = 5
EOF
sudo systemctl enable --now fail2bansudo apt install -y ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enableUFW alone doesn't protect Docker-published ports. Docker writes to iptables directly and bypasses UFW. Install ufw-docker so both agree.
sudo wget -O /usr/local/bin/ufw-docker https://github.com/chaifeng/ufw-docker/raw/master/ufw-docker
sudo chmod +x /usr/local/bin/ufw-docker
sudo ufw-docker install
sudo systemctl restart ufwsudo adduser deploy
sudo usermod -aG sudo,docker deployCopy your public key to /home/deploy/.ssh/authorized_keys before relying on this account.
Docker
- Harden
/etc/docker/daemon.json:live-restore, no userland proxy, log rotation. - Set
no-new-privilegesper service. It is not a daemon-wide setting. - Never expose the Docker socket over TCP (ports 2375 and 2376) on a host wtree Cloud manages. wtree Cloud reaches remote servers over SSH, and an open TCP socket is unauthenticated root.
- Store registry credentials in wtree Cloud (Registries), scoped to what the pipeline needs, instead of running
docker loginon the host. - Pin image tags in production. Avoid
:latest.
{
"live-restore": true,
"userland-proxy": false,
"log-driver": "json-file",
"log-opts": { "max-size": "10m", "max-file": "3" }
}Restart the daemon. With live-restore set, containers keep running. The log options stop a noisy container from filling the disk.
sudo systemctl restart dockerPer service, in the Compose file or the app's Settings › Resources:
security_opt:
- no-new-privileges:truewtree Cloud
- Enable 2FA or passkeys for every member. Passkeys resist phishing. See Account security.
- Give members least-privilege roles and don't hand out Admin by default. See Permissions.
- Use secrets providers instead of raw env vars. Values are fetched at deploy time, and rotation takes effect on the next deploy.
- Restrict
Access to API/CLI. Set an expiration on every token, issue one per integration, and regenerate on offboarding or suspected exposure.
There is no org-wide "require 2FA" setting. Enablement is per user, so make it a policy and check it.
Traefik and networking
- Applications get Let's Encrypt through
certResolverand an HTTP to HTTPS redirect by default. Compose domains use Traefik labels and need the redirect added explicitly. See Networking and Compose domains. - Add HSTS and rate limiting through custom middlewares. Neither is automatic and neither has a UI toggle.
- Keep the Traefik dashboard off. A default install doesn't expose it.
- Apps share
w3panel-networkby default. Enable isolated deployments on Compose stacks so each gets its own network. See Compose utilities.
Edit the app's domain config in Settings › Networking, in the Traefik card. Add the middlewares and reference them from the websecure router.
http:
middlewares:
secure-headers:
headers:
stsSeconds: 31536000
stsIncludeSubdomains: true
stsPreload: true
rate-limit:
rateLimit:
average: 100
burst: 50
routers:
w3panel-app-name-router-websecure-1:
middlewares:
- secure-headers
- rate-limit
# ...rest of the router config wtree Cloud generatedaverage is sustained requests per second per source. burst is the spike allowed above it. Tune both to your traffic.
Databases
- Use internal credentials for anything in the same network. Enable external credentials (a published port) only when required, and then restrict it with a firewall rule or a VPN. See Connect to databases.
- Back up to an S3 destination (Database backups). wtree Cloud doesn't encrypt the archive, so enable encryption at rest on the bucket (SSE-S3 or SSE-KMS) and scope the credentials to that bucket.
- Test restores on a schedule. See Restore and Volume backups.
Observability
- Ship container and host logs to a system outside the host (Docker log driver, syslog, or a shipper). Built-in monitoring is a cloud-only feature.
- Alert on repeated Fail2Ban bans, Traefik 401 and 403 spikes and failed logins. Set up notifications for at least deployment failures.
Checklist
| Area | Item |
|---|---|
| Host | Ubuntu or Debian LTS with unattended-upgrades |
| Host | SSH keys only, no root login, no password auth |
| Host | Fail2Ban or CrowdSec on SSH |
| Host | Firewall limited to 22, 80 and 443, port 3000 not public |
| Host | Non-root operator user |
| Docker | daemon.json hardened |
| Docker | Socket never exposed over TCP |
| Docker | Registry credentials scoped and stored in wtree Cloud |
| wtree Cloud | 2FA or passkeys for every member |
| wtree Cloud | Least-privilege roles |
| wtree Cloud | Secrets through a provider |
| wtree Cloud | API and CLI tokens per integration, with expiration |
| Traefik | HTTPS redirect on every domain |
| Traefik | HSTS on public domains |
| Traefik | Dashboard not exposed |
| Traefik | Rate limiting on public services |
| Traefik | Isolated deployments for Compose |
| Database | Internal credentials only |
| Database | Backups encrypted at rest |
| Database | Restore tested this quarter |
| Observability | Logs shipped off-host |
| Observability | Alerts on auth and deployment failures |
