Giter Club home page Giter Club logo

docker's Introduction

Ballerina Docker Extension

Annotation based docker extension implementation for ballerina.

Build Status Build Status codecov License

Features:

  • 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 Annotations:

@docker:Config{}

  • 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

@docker:CopyFiles{}

  • 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

@docker:Expose{}

  • Supported with ballerina listeners.

How to run

  1. Download and install JDK 8 or later
  2. Get a clone or download the source from this repository (https://github.com/ballerinax/docker)
  3. Run the Maven command mvn clean install from within the docker directory.
  4. Copy target/docker-extension-0.9***.jar file to <BALLERINA_HOME>/bre/lib directory.
  5. 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

Enable building for Windows Platform

Use the "BAL_DOCKER_WINDOWS=true" environment variable to enable building docker images supporting Windows platform.

Enabling debug logs

Use the "BAL_DOCKER_DEBUG=true" environment variable to enable docker related debug logs when building the ballerina source file.

Annotation Usage Sample:

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.

docker's People

Contributors

anupama-pathirage avatar anuruddhal avatar ballerina-bot avatar hemikak avatar hevayo avatar jamesjj avatar keizer619 avatar kishanthan avatar lafernando avatar lakwarus avatar maheshika avatar manuranga avatar manuri avatar natashawso2 avatar pubudu91 avatar shafreenanfar avatar uthaiyashankar avatar vinok88 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.