# Deploying the ClipBridge relay on Oracle Cloud Infrastructure This deployment runs two containers: Caddy terminates public TLS on ports 80/443, while the relay is reachable only on an internal Docker network. The relay persists a bounded encrypted backlog in a named volume. It never receives a clipboard decryption key. ## 1. Prepare DNS and the OCI network 1. Create an A record such as `clipboard.example.com` pointing at the instance's reserved public IPv4 address. Add an AAAA record only when IPv6 is configured and reachable. 2. Attach an OCI Network Security Group (NSG) to the instance VNIC. Add these **stateful ingress** rules: - TCP 80 from `0.0.0.0/0` (ACME validation and HTTPS redirect). - TCP 443 from `0.0.0.0/0` (HTTPS/WSS). - TCP 22 only from the administrator's public CIDR, never from the whole Internet. - Add equivalent `::/0` rules for 80/443 only if the DNS name has a working AAAA record. 3. Keep port 8787 closed in both the NSG and the host firewall. Compose exposes it only to Caddy. 4. Retain the default outbound rule, or allow at least DNS plus TCP 80/443 so Docker images and ACME certificates can be fetched. OCI describes NSGs as the virtual firewall for resources sharing a security posture: [OCI Network Security Groups](https://docs.oracle.com/en-us/iaas/Content/Network/Concepts/networksecuritygroups.htm). Also keep the instance patched, disable SSH password/root login, and use a host firewall as described in [OCI Compute security guidance](https://docs.oracle.com/en-us/iaas/Content/Security/Reference/compute_security.htm). On Ubuntu, a minimal host policy can be expressed with UFW: ```sh sudo ufw default deny incoming sudo ufw allow from YOUR_ADMIN_CIDR to any port 22 proto tcp sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw enable ``` On Oracle Linux, apply the equivalent 22/80/443 policy with `firewalld`. Do not run both firewall examples. Docker publishes only 80 and 443 from this Compose file; review firewall policy again if the Compose ports are changed. ## 2. Install the container runtime Install Docker Engine and the Compose v2 plugin from Docker's supported repository for the instance OS. The current official instructions are [Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/) and [the Docker Compose plugin](https://docs.docker.com/compose/install/linux/). Log out and back in after adding an unprivileged deployment user to the `docker` group. Both the Dockerfile and its Node base image support `linux/arm64` and `linux/amd64`, so the same deployment works on an OCI Ampere A1 or x86 compute shape. ## 3. Configure the relay Place a trusted ClipBridge checkout at `/opt/clipbridge`, then run from the repository root: ```sh cp deploy/oracle/.env.example deploy/oracle/.env chmod 600 deploy/oracle/.env openssl rand -hex 32 ``` Edit `deploy/oracle/.env`: - Set `CLIPBRIDGE_DOMAIN` to the DNS name prepared above, without a scheme or path. - Set `ACME_EMAIL` to the certificate-administration address. - Replace `RELAY_AUTH_TOKEN` with the 64-character output from `openssl rand -hex 32`. - Adjust retention and capacity only after estimating disk and memory use. The defaults cap the JSON store at 128 MiB. - Optionally set all APNs values to enable opaque iOS wake hints. Encode the downloaded `.p8` key as shown in `.env.example`, use `dev.clipbridge.native` as the bundle ID, and keep `production` unless the installed iOS build uses a development provisioning environment. The bearer token authenticates access to the relay but is not an encryption key. Put the same relay URL (`wss://clipboard.example.com/v1/ws`) and token into each trusted desktop client. Never commit `.env`, paste its contents into logs, or pass the token in a URL query string. Treat the APNs `.p8` value as a production signing secret as well. ## 4. Start and verify ```sh docker compose --env-file deploy/oracle/.env -f deploy/oracle/compose.yaml build --pull docker compose --env-file deploy/oracle/.env -f deploy/oracle/compose.yaml up -d docker compose --env-file deploy/oracle/.env -f deploy/oracle/compose.yaml ps curl --fail --show-error --silent https://clipboard.example.com/healthz ``` A healthy response resembles: ```json {"status":"ok","uptimeMs":12000,"clients":2,"rooms":1} ``` Caddy obtains and renews the public certificate automatically once DNS and ports 80/443 are correct. Its reverse proxy supports WebSocket upgrades without a separate WebSocket switch. The deployment intentionally leaves Caddy access logging disabled so an authorization header cannot accidentally enter routine access logs. For diagnostics, inspect bounded recent logs without printing configuration: ```sh docker compose --env-file deploy/oracle/.env -f deploy/oracle/compose.yaml logs --tail=100 relay caddy ``` ## Operations Update with a graceful relay restart: ```sh docker compose --env-file deploy/oracle/.env -f deploy/oracle/compose.yaml build --pull docker compose --env-file deploy/oracle/.env -f deploy/oracle/compose.yaml up -d ``` To rotate the shared relay bearer token, update all clients and `.env`, then force-recreate the relay. The restart closes old authenticated sockets: ```sh docker compose --env-file deploy/oracle/.env -f deploy/oracle/compose.yaml up -d --force-recreate relay ``` The relay store uses an atomic replace, but take a stopped copy for a simple consistent backup: ```sh mkdir -p backups docker compose --env-file deploy/oracle/.env -f deploy/oracle/compose.yaml stop relay docker run --rm -v clipbridge_relay_data:/source:ro -v "$PWD/backups:/backup" alpine \ tar -C /source -czf /backup/clipbridge-relay-$(date +%Y%m%dT%H%M%S).tgz . docker compose --env-file deploy/oracle/.env -f deploy/oracle/compose.yaml start relay ``` OCI volume backups or snapshots are a suitable second layer. The backlog contains ciphertext and routing metadata, but backups should still be access-controlled and expired according to the same retention policy. If `/healthz` returns `503`, check relay logs and free disk space before restarting. A malformed or oversized existing store is rejected rather than overwritten. Preserve it for diagnosis; do not delete it unless losing the queued ciphertext backlog is intentional.