Annotation based docker extension implementation for ballerina.
- Dockerfile generation based on @docker:Config annotations.
- Docker image generation.
- Docker push support with docker registry.
- Docker based ballerina debug support.
- Copy file support.
- Supported with ballerina services or listeners.
Annotation Name | Description | Default value |
---|---|---|
name | Name of the docker image | File name of the generated .jar file |
registry | Docker registry url | None |
tag | Docker image tag | latest |
username | Username for docker registry | None |
password | Password for docker registry | None |
baseImage | Base image to create the docker image | openjdk:8-jre-alpine |
buildImage | Enable building docker image | true |
push | Enable pushing docker image to registry | false |
enableDebug | Enable debug for ballerina | false |
debugPort | Remote debug port | 5005 |
dockerAPIVersion | Docker API Version | None |
dockerHost | Docker host IP and docker PORT. ( e.g minikube IP and docker PORT) | DOCKER_HOST environment variable. If DOCKER_HOST is unavailable, uses "unix:///var/run/docker.sock" for Unix or uses "npipe:////./pipe/docker_engine" for Windows 10 or uses "localhost:2375" |
dockerCertPath | Docker certificate path | "DOCKER_CERT_PATH" environment variable |
- Supported with ballerina services or listeners.
Annotation Name | Description | Default value |
---|---|---|
sourceFile | Source path of the file (in your machine) | None |
target | Target path (inside container) | None |
isBallerinaConf | Flag whether file is a ballerina config file | false |
- Supported with ballerina listeners.
- Download and install JDK 8 or later
- Get a clone or download the source from this repository (https://github.com/ballerinax/docker)
- Run the Maven command
mvn clean install
from within the docker directory. - Copy
target/docker-extension-0.9***.jar
file to<BALLERINA_HOME>/bre/lib
directory. - Run
ballerina build <.bal filename>
to generate artifacts.
The docker artifacts will be created in a folder called docker with following structure.
|── docker
| └── Dockerfile
└── outputfilename.balx
Use the "BAL_DOCKER_WINDOWS=true" environment variable to enable building docker images supporting Windows platform.
Use the "BAL_DOCKER_DEBUG=true" environment variable to enable docker related debug logs when building the ballerina source file.
import ballerina/http;
import ballerina/log;
import ballerina/docker;
@docker:Expose{}
listener http:Listener helloWorldEP = new(9090);
@http:ServiceConfig {
basePath: "/helloWorld"
}
@docker:Config {
registry: "docker.abc.com",
name: "helloworld",
tag: "v1.0"
}
service helloWorld on helloWorldEP {
resource function sayHello(http:Caller caller, http:Request request) {
http:Response response = new;
response.setTextPayload("Hello, World from service helloWorld ! \n");
var responseResult = caller->respond(response);
if (responseResult is error) {
log:printError("error responding back to client.", err = responseResult);
}
}
}
Refer samples for more info.