1

I'm trying to run the "DEPLOYING ON DOCKER" sample in this.

Q1) When I call the service deployed on docker, it gives me a 500.

The logs in docker says error: wso2.twitter:TwitterError, message: bad Authentication data.

It seems the twitter.toml is not inside the docker container. That makes sense because I never mentioned in below commands that such a file is there while building the docker image.

$ ballerina build hello_service.bal
$ docker run -d -p 9090:9090 registry.hub.docker.com/helloworld:v1.0
$ curl -d "Hello Ballerina" -X POST localhost:9090

How can I provide the config file?

Q2) What's the use of registry here?

// Docker configurations
@docker:Config {
    registry:"registry.hub.docker.com",
    name:"helloworld",
    tag:"v1.0"
}
Bee
  • 12,251
  • 11
  • 46
  • 73
  • Q1 is a duplicate of https://stackoverflow.com/questions/50134123/deploying-the-ballerina-integration-example-in-a-docker-container – Pubudu May 09 '18 at 12:48
  • Thanks. Appreciate an answer for Q2 as well. – Bee May 09 '18 at 12:51

2 Answers2

1

Following annotation should be added to the ballerina service. This copy the ballerina file to Docker container. Stating isBallerinaConf:true will pass the toml file to ballerina run command.

@docker:CopyFiles {
    files: [{source: "./twitter.toml", target: "/opt/twitter.toml", isBallerinaConf: true}]
}

The registry is used to push an image to a remote docker registry.

Refer sample3 for usage. The final docker image would be:

registry.hub.docker.com/helloworld:v.1.0

https://github.com/ballerinax/docker/tree/master/samples/sample3

  • So I hope if I'm not planning to push my image to a remote registry, I can avoid setting this value. – Bee May 09 '18 at 12:57
  • 1
    Yes. The registry is an optional annotation. Also, the image is pushed only if "push:true" attribute is set. See https://github.com/ballerinax/docker#supported-annotations for a list of annotations and default values – Anuruddha Lanka Liyanarachchi May 09 '18 at 12:59
1

For ballerina 1.0.4 its

@docker:CopyFiles {
    files: [{sourceFile: "./ballerina.conf", target: "/opt/ballerina.conf", isBallerinaConf: true}]
}

according to https://ballerina.io/learn/api-docs/ballerina/docker/records/FileConfig.html