Let's introduce you to the Ocuroot client by building and deploying a set of interrelated services to a local Docker instance.
Through deploying these services, you'll see how Ocuroot manages missing dependencies, adding and populating new environments and deleting environments.
Ordinarily, you may prefer to manage local containers with docker compose
, but in this example, we'll be deploying
everything separately to illustrate how Ocuroot would operate in your datacenter or cloud environments.
You will need the following installed on your local machine:
We'll be working on a local copy of the quickstart repo, so you'll need to clone it.
git clone git@github.com:ocuroot/quickstart.git
cd quickstart
Before we can deploy our services, we need somewhere to deploy them to. We need an environment.
For the quickstart, we have a config file that will do that for you, environments.ocu.star
.
Kick off a release from that file to create a staging environment:
ocuroot release new environments.ocu.star
To get us started, this only creates a staging environment. You can see the staging environment config by viewing the state:
$ ocuroot state get @/environment/staging
{
"attributes": {
"frontend_port": "8080",
"type": "staging"
},
"name": "staging"
}
For the purposes of the quickstart, state is stored locally in the .store
directory.
Now we have an environment, we can release something to it. We'll start with the "frontend" service.
ocuroot release new frontend/package.ocu.star
This should output something like this:
✓ build (30.399s)
Outputs
└── quickstart/-/frontend/package.ocu.star/@1/call/build#output/image
└── quickstart-frontend:latest
› deploy to staging
Pending Inputs
└── quickstart/-/network/package.ocu.star/@/deploy/staging#output/network_name
The staging deployment has a pending input from network/package.ocu.star
. This is
because we need a shared docker network for the staging environment.
To satisfy the dependency for the frontend, we need to release the network.
ocuroot release new network/package.ocu.star
Once this succeeds, the network name will be available and you can continue the frontend deployment. To continue any outstanding work, you can run the following command:
ocuroot work any
The frontend should now be running and you can view it at http://localhost:8080. You'll see three errors about unreachable services, this is because we need to deploy them!
Run these three commands to deploy the backend services.
ocuroot release new time-service/package.ocu.star
ocuroot release new weather-service/package.ocu.star
ocuroot release new message-service/package.ocu.star
Once complete, reload the frontend and you'll see messages from these services.
Now we have our staging environment fully populated and visually tested, we can set up production!
Add the following to environments.ocu.star
:
register_environment(environment(
name="production",
attributes={
"type": "production",
"frontend_port": "8081",
}
))
Then release these changes and deploy all services.
ocuroot release new environments.ocu.star
ocuroot work any
ocuroot work any
The second ocuroot work any
call is needed to handle the dependency between frontend
and network
.
Once this is complete, you'll be able to load the production frontend at http://localhost:8081, there should be a line on the page indicating that the environment is "production".
You'll now have a bunch of containers running in your local Docker. View the list by running:
docker ps -f name=^quickstart- --format "{{.Names}}"
You'll see containers for both production and staging.
Let's clean up after ourselves, first off, we'll delete our production environment. We'll do this by removing it from our intent, and executing work to synchronize to actual state.
ocuroot state delete +/environment/production
ocuroot work any
If you run the docker ps
command above again, you'll only see the staging containers.
See if you can adapt the above commands to delete the staging environment as well.
This was just a taste of what you can do with Ocuroot, and there's plenty more to explore even within the quickstart repo! Feel free to have a look around to see how everything's configured. You could also try: