Skip to main content

Introduction

Shard Cloud doesn’t run docker-compose.yml files directly: each application runs one container. A Compose project moves by splitting it into its parts: each service becomes a managed application or database. Most of those parts get simpler on the way, since Shard Cloud manages the databases, HTTPS, restarts, backups and metrics for you, with no server to maintain.

How Compose Maps to Shard Cloud

Before You Start

What you need

  • The project, with its docker-compose.yml, running somewhere you can reach (your computer or the current server), to copy the data
  • A Shard Cloud account with room for every service and database (see the minimum RAM of each on the limits page). Custom Docker images need the Core plan or above
  • Docker on your computer, to restore the databases

Classify each service

Open docker-compose.yml and put each service in one of these groups:
Applications can’t talk over a private network. In Compose, services reach each other by name on any port (http://api:3000, amqp://rabbitmq:5672). On Shard Cloud, an application reaches another application only through its public address (https://api.shardweb.app), over HTTP on port 80. Databases are the exception: apps reach them through their connection URL, over Shard Cloud’s private network. So a service that the others reach on a port other than HTTP (a message broker such as RabbitMQ or Kafka, an MQTT broker, a search engine reached on its own port) can’t run as an application: replace it with a managed database where one fits, as in the table above.

Step 1: Create the Databases and Move the Data

1

Create each database

In the Dashboard, create a database of the same type as each database service, with the same version as its image: tag or a newer one (postgres:16 → PostgreSQL 17 or 18 is fine). The version can’t change later. Copy each database’s connection URL from its page.
2

Dump the data from the Compose project

Stop the services that write to the database first, so the copy is consistent. Then dump it from the running container (db is the service name; -T keeps the output binary-safe):
Use the user, password and database name from the service’s environment: (POSTGRES_USER, POSTGRES_DB, MYSQL_ROOT_PASSWORD, MONGO_INITDB_ROOT_USERNAME…). If the project runs on a server, run this there and copy the file to your computer.
3

Restore it into Shard Cloud

Use the Docker image of your Shard Cloud database’s major version (postgres:17, postgres:18):
Redis in a Compose project is usually a cache or a job queue: create a Redis database and let it start empty.

Step 2: Move Your Code

If a service runs your own code in a supported language, you usually don’t need its Dockerfile at all: Shard Cloud’s language containers install your dependencies (package.json, requirements.txt, go.mod…) and start the app. Translate the service into a .shardcloud file:
docker-compose.yml
becomes, in the api folder:
.shardcloud
  • Port: the app must listen on port 80, on 0.0.0.0. Every language container sets PORT=80, so an app that reads PORT needs no change; one hardcoded to 3000 must be changed.
  • Build steps from the Dockerfile (RUN npm run build, RUN python manage.py collectstatic) go in front of the start command: CUSTOM_COMMAND=npm run build && npm start.
  • System packages from the Dockerfile (apt-get install): the language containers already include common ones (ffmpeg, Chromium’s libraries, image libraries, the PostgreSQL client). If you need others, use a custom Docker image (step 3).
  • Python: run tools as modules (python -m gunicorn, python -m uvicorn main:app --host 0.0.0.0 --port 80), since installed scripts aren’t on the PATH.
Zip the folder without node_modules/, virtualenvs or build output, with .shardcloud at the root, and upload it in the Dashboard. See your language’s guide under Languages for details.

Step 3: Services That Need Their Own Dockerfile

Upload the service’s build context as a custom Docker image, then create an application from it. Shard Cloud builds your Dockerfile as it is, but the container runs with a few rules that a Compose setup doesn’t have. Check your Dockerfile against each one:
1

Put the Dockerfile at the root of the ZIP

Zip the folder the service’s build: context: points at, with the Dockerfile at the root of the ZIP and named Dockerfile. If Compose uses dockerfile: docker/api.Dockerfile, copy that file to the root as Dockerfile. build: args: don’t exist here: write them as ARG NAME=value defaults in the Dockerfile. The ZIP can be 100 MB at most, and a build can take 15 minutes at most.
2

Don't put your code in /app

Every application gets a persistent folder mounted at /app (and at /tmp). It starts empty and hides anything the image had there, so an image that copies its code to /app starts with an empty folder. Use another folder for the code, and keep /app for the files that must survive restarts (uploads, SQLite, sessions):
Dockerfile
3

Listen on port 80, and run as root

Web traffic reaches the container on port 80, and PORT is not set for you in a custom image: set it in the Dockerfile if your app reads it (ENV PORT=80). The server must listen on 0.0.0.0.The container can only open port 80 as root, and it can’t switch users after starting. Remove USER lines (USER node, USER 1000), and don’t use entrypoints that drop privileges with gosu or su-exec. The container still runs isolated, with most root powers removed.
4

nginx inside the image

nginx switches its workers to another user by default, which isn’t allowed. Add these two lines to nginx.conf (replacing its user line), and listen 80:
nginx.conf
5

Secrets at runtime, not at build

Pass passwords and keys as environment variables of the application, not as build ARGs or files copied into the image.
An application from a custom image always runs the image’s own ENTRYPOINT/CMD: there is no start command to change per application. For a worker that shares the image with the web app, either build a second image with its own CMD, or let one image start either role from an environment variable:
entrypoint.sh
Then set ROLE=worker on the worker application.

Step 4: Rewire the Environment Variables

In Compose, services find each other by service name. Those names don’t exist on Shard Cloud, so for each application, write its variables in a .env file and replace: Shard Cloud databases only accept encrypted connections. Most drivers handle this with the connection URL alone; if yours connects without TLS by default, turn it on (for example ssl: { rejectUnauthorized: false } in Node’s pg, or sslmode=require).
depends_on doesn’t exist here: every application starts on its own, maybe before the database is reachable. Make sure your app retries its first database connection instead of exiting (most frameworks and ORMs do). If it exits, it’s restarted automatically anyway.

Step 5: Replace the Reverse Proxy

In most Compose projects, nginx, Traefik or Caddy is there for HTTPS and to send each domain or path to the right service. On Shard Cloud:
  • HTTPS is automatic for every application, on its *.shardweb.app address and on your own domains.
  • One domain per service is the simplest setup: example.com on the frontend app, api.example.com on the API app. Point the frontend at the API’s address, and allow it in the API’s CORS settings.
  • Paths on one domain (/ → frontend, /api → API): serve the frontend from the API app (many frameworks can serve static files), or keep a small nginx application that forwards to the other apps’ public addresses:
    default.conf
    Build it as a custom image from nginx with the user root; and master_process off; lines from step 3.
WebSockets work on every application with no extra setup.

Step 6: Deploy and Test

1

Create each application

Upload each service: a ZIP with .shardcloud for regular applications, or an application from its custom image. Give a SUBDOMAIN only to the services that receive web traffic (they need at least 512 MB); workers need none (256 MB).
2

Import the environment variables

On each application’s page, open Environment Variables, choose Import .env and pick that service’s file. Restart the application afterwards: variables are read when it starts.
3

Copy persistent files

If a service kept files in a named volume, copy them out of the old container (docker compose cp api:/data ./data) and upload them to the application’s /app folder with the file manager in the dashboard.
4

Test, then move your domain

Test each app on its *.shardweb.app address, then add your domains and point their DNS at Shard Cloud. See Custom Domain. Keep the old project and its volumes until you’ve checked the data.
5

Deploy on every push (optional)

Connect each application to your repository on its Deploy page, and turn on Auto-Restart on Deploy. See Git integration. A .shardcloud file committed to the repository applies to every application deployed from it: with several services in one repository, keep .shardcloud out of git and let each application keep its own.

Troubleshooting

The persistent folder mounted at /app hides what the image put there. Move the code to another folder (WORKDIR /srv/app) and rebuild. See step 3.
The image switches to a non-root user. Remove the USER line so the server runs as root.
Add user root; and master_process off; to nginx.conf.
The entrypoint tries to switch users, which isn’t allowed. Start the process directly as root instead.
Compose service names don’t exist on Shard Cloud. Use the database’s connection URL, or the other application’s public address (step 4).
The server must listen on port 80 and on 0.0.0.0, not on another port or on localhost only. In a custom image, PORT isn’t set for you: set ENV PORT=80 if the app reads it.
Check the build log on the image’s page. A build can take 15 minutes at most and the ZIP can be 100 MB at most: add a .dockerignore for node_modules, .git and build output.
Environment variables are read when the app starts: restart the application after changing them.