Launching apps together with Compose files
This guide will show you how to launch multiple instances of a service together
using a Compose
file. This
can be achieved using kraft cloud compose
, a powerful
subcommand within the KraftCloud platform that allows you to effortlessly launch
instances onto the platform using the popular-format Compose file.
Prerequisites
Before you begin, ensure that you have the following prerequisites in place:
-
KraftCloud Account: You must have an active account on the KraftCloud platform. Sign-up for the beta today!
-
Installed Kraft CLI: Ensure that you have the
kraft
CLI tool installed on your local machine. -
Configured Authentication: Authenticate your CLI with your KraftCloud account by setting your access token using the
KRAFTCLOUD_TOKEN
environmental variable or by using the--token
flag.
Quick Start
Using a Compose file with KraftCloud is no different from using it with docker compose
or any other container runtime tool which supports the Compose file
format.
-
Prepare your deployment by creating a Compose file. For example, let’s consider a simple Compose file that launches two instances of a service inside a new repository directory called
my-first-project
: -
Save the Compose file as
compose.yaml
in your project directory. -
Launch the services using the
kraft cloud compose
command:This command will read the
compose.yaml
file and launch the services together defined in the file.Similar to other
docker compose
commands, you can use the-d|--detach
flag which will then let the command return. Without this flag, the logs of each service will be tailed continiously to your terminal window.
Declaring memory reservation
It is possible to declare memory limits for each service in the Compose file by
setting the mem_reservation
directive. For example
Grafana can be deployed with 1024MB of memory reservation:
Declaring networks
Networks
in the context of a Compose file is deployed as a service
group. By default, and when no networks
are
specified, a default
one will be created and used.
You may wish to attach each service to a different network in order to provide different scaling policies.
To declaring a network will in turn create a service group with the same name
with the ${PROJECT_NEME}
as the prefix. For example, the my-netwowrk
will
be deployed as my-first-project-my-network
given the example compose.yaml
file from before:
Viewing the status of the services
To view the status of the services launched using the Compose file, you can use
the kraft cloud compose ps
command when cd
‘d into the project directory:
Next Steps
- Learn more about the Compose file format;
- See Go 1.22 with Redis deployed via
compose.yaml
example. - Build a compose project for KraftCloud with
kraft cloud compose build
- Create a KraftCloud deployment with
kraft cloud compose create
- Stop and remove the services in a KraftCloud compose project deployment with
kraft cloud compose down
- Log the services in a KraftCloud compose project deployment with
kraft cloud compose log
- List KraftCloud deployments at a given path with
kraft cloud compose ls
- List the services of compose project deployed to KraftCloud with
kraft cloud compose ps
- Push a KraftCloud deployment service with
kraft cloud compose push
- Start a KraftCloud deployment with
kraft cloud compose start
- Stop a KraftCloud deployment with
kraft cloud compose stop
- Deploy services in a compose project to KraftCloud with
kraft cloud compose up