Run

Run is HolaCloud's container image and console-control service. It exposes a push-oriented subset of the Docker Registry v2 API and a small Console API for inspecting repositories and changing runtime configuration.

Features

Push-Oriented Registry v2 Subset

Run supports the registry endpoints needed to push image blobs and manifests under /v2. It is not a full Docker Registry implementation and should not be documented as a general pull registry.

1docker login run.hola.cloud
2docker build -t run.hola.cloud/my-project/my-app:latest .
3docker push run.hola.cloud/my-project/my-app:latest

Console Management API

The Console API works with repositories and image references or digests:

  • GET /version
  • GET /api/console?repository=
  • POST /api/console/start
  • POST /api/console/stop
  • POST /api/console/rollback
  • PUT /api/console/env
  • PUT /api/console/volumes

There is no /v1/run/deploy, /api/console/run, push/exec API, or container_id workflow.

Environment Variables and Volumes

Environment and volume configuration is saved by repository:

curl -X PUT "https://api.hola.cloud/api/console/env" \
  -H "Content-Type: application/json" \
  -d '{
    "repository": "my-project/my-app",
    "env": [
      {"key": "LOG_LEVEL", "desired_value": "debug"}
    ]
  }'
PUT /api/console/env HTTP/1.1
Host: api.hola.cloud
Content-Type: application/json

{
    "repository": "my-project/my-app",
    "env": [
      {"key": "LOG_LEVEL", "desired_value": "debug"}
    ]
  }
package main

import (
	"fmt"
	"io"
	"net/http"
	"encoding/json"
	"strings"
)

func main() {
	payload := map[string]any{"env": []any{map[string]any{"desired_value": "debug", "key": "LOG_LEVEL"}}, "repository": "my-project/my-app"}
	bodyBytes, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}
	body := string(bodyBytes)

	req, err := http.NewRequest("PUT", "https://api.hola.cloud/api/console/env", strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$payload = ['env' => [['desired_value' => 'debug', 'key' => 'LOG_LEVEL']], 'repository' => 'my-project/my-app'];
$body = json_encode($payload);

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/api/console/env',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

import json

headers = {
    "Content-Type": "application/json",
}

payload = {"env": [{"desired_value": "debug", "key": "LOG_LEVEL"}], "repository": "my-project/my-app"}
body = json.dumps(payload)

response = requests.request(
    "PUT",
    "https://api.hola.cloud/api/console/env",
    headers=headers,
    data=body
)

print(response.text)
const payload = {"env": [{"desired_value": "debug", "key": "LOG_LEVEL"}], "repository": "my-project/my-app"};

const response = await fetch("https://api.hola.cloud/api/console/env", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

console.log(await response.text());
const payload = {"env": [{"desired_value": "debug", "key": "LOG_LEVEL"}], "repository": "my-project/my-app"};

const response = await fetch("https://api.hola.cloud/api/console/env", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        var payload = Map.of("env", List.of(Map.of("desired_value", "debug", "key", "LOG_LEVEL")), "repository", "my-project/my-app");
        var body = new ObjectMapper().writeValueAsString(payload);

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/api/console/env"))
            .method("PUT", HttpRequest.BodyPublishers.ofString(body))
            .header("Content-Type", "application/json")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Getting Started

  1. Authenticate with the registry:
1docker login run.hola.cloud
  1. Build and push your image:
1docker build -t run.hola.cloud/my-project/my-app:latest .
2docker push run.hola.cloud/my-project/my-app:latest
  1. Start the repository at a pushed reference:
curl -X POST "https://api.hola.cloud/api/console/start" \
  -H "Content-Type: application/json" \
  -d '{
    "repository": "my-project/my-app",
    "reference": "latest"
  }'
POST /api/console/start HTTP/1.1
Host: api.hola.cloud
Content-Type: application/json

{
    "repository": "my-project/my-app",
    "reference": "latest"
  }
package main

import (
	"fmt"
	"io"
	"net/http"
	"encoding/json"
	"strings"
)

func main() {
	payload := map[string]any{"reference": "latest", "repository": "my-project/my-app"}
	bodyBytes, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}
	body := string(bodyBytes)

	req, err := http.NewRequest("POST", "https://api.hola.cloud/api/console/start", strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$payload = ['reference' => 'latest', 'repository' => 'my-project/my-app'];
$body = json_encode($payload);

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/api/console/start',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

import json

headers = {
    "Content-Type": "application/json",
}

payload = {"reference": "latest", "repository": "my-project/my-app"}
body = json.dumps(payload)

response = requests.request(
    "POST",
    "https://api.hola.cloud/api/console/start",
    headers=headers,
    data=body
)

print(response.text)
const payload = {"reference": "latest", "repository": "my-project/my-app"};

const response = await fetch("https://api.hola.cloud/api/console/start", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

console.log(await response.text());
const payload = {"reference": "latest", "repository": "my-project/my-app"};

const response = await fetch("https://api.hola.cloud/api/console/start", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        var payload = Map.of("reference", "latest", "repository", "my-project/my-app");
        var body = new ObjectMapper().writeValueAsString(payload);

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/api/console/start"))
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .header("Content-Type", "application/json")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Comments

Leave a comment