ballerina 学习二十五 项目docker 部署&& 运行
ballerina 官方提供了docker 的runtime,还是比较方便的
基本项目创建
- 使用cli创建项目
按照提示操作就行
ballerina init -i
- 项目结构
添加了dockerfile 以及docker-compose 简单http 服务
├── Ballerina.toml
├── Dockerfile
├── README.md
├── docker-compose.yml
├── hello_service.bal
├── target
│ └── hello_service.balx
└── tests
└── hello_service_test.bal
- 添加简单http server 代码(hello_service.bal)
// A system package containing protocol access constructs
// Package objects referenced with 'http:' in code
import ballerina/http;
import ballerina/io;
// A service endpoint represents a listener
endpoint http:Listener listener {
port:9090
};
// A service is a network-accessible API
// Advertised on '/hello', port comes from listener endpoint
service<http:Service> hello bind listener {
// A resource is an invokable API method
// Accessible at '/hello/sayHello
// 'caller' is the client invoking this resource
sayHello (endpoint caller, http:Request request) {
// Create object to carry data back to caller
http:Response response = new;
// Objects and structs can have function calls
response.setTextPayload("Hello Ballerina!\n");
// Send a response back to caller
// Errors are ignored with '_'
// -> indicates a synchronous network-bound call
_ = caller -> respond(response);
}
}
Dockerfile
官方提供了基础镜像 ballerina/ballerina
- dockerfile
# build stage
# FROM ballerina/ballerina-platform AS build-env
# ADD . /home/ballerina/
# RUN ballerina build hello_service.bal
# RUN ls .
FROM ballerina/ballerina
EXPOSE 9090
COPY hello_service.bal /home/ballerina
RUN ls .
ENTRYPOINT [ "ballerina","run","hello_service.bal" ]
集成docker-compose
- docker-compose.yml
version: "3"
services:
http:
build: .
image: myhttp
ports:
- "9099:9090"
构建&&运行
docker-compose build
docker-compose up -d
效果

参考资料
https://hub.docker.com/r/ballerina/ballerina-platform/
https://hub.docker.com/r/ballerina/ballerina/
https://github.com/rongfengliang/ballerina-docker-demo
ballerina 学习二十五 项目docker 部署&& 运行的更多相关文章
- ballerina 学习二十六 项目docker 部署&& 运行(二)
ballerina 从发布,到现在官方文档的更新也是很给力的,同时也有好多改进,越来越好用了 可以参考官方文档 https://ballerina.io/learn/by-guide/restful- ...
- Java开发学习(二十五)----使用PostMan完成不同类型参数传递
一.请求参数 请求路径设置好后,只要确保页面发送请求地址和后台Controller类中配置的路径一致,就可以接收到前端的请求,接收到请求后,如何接收页面传递的参数? 关于请求参数的传递与接收是和请求方 ...
- ballerina 学习二十八 快速grpc 服务开发
ballerina 的grpc 开发模型,对于开发者来说简单了好多,不是schema first 的方式,而是我们 只要编写简单的ballerina service 就可以了,proto 文件是自动帮 ...
- Salesforce LWC学习(二十五) Jest Test
本篇参看: https://trailhead.salesforce.com/content/learn/modules/test-lightning-web-components https://j ...
- ballerina 学习二十九 数据库操作
ballerina 数据操作也是比较方便的,官方也我们提供了数据操作的抽象,但是我们还是依赖数据库驱动的. 数据库驱动还是jdbc模式的 项目准备 项目结构 ├── mysql_demo │ ├── ...
- ballerina 学习二十四 监控ballerina
ballerina 服务的监控还是比较方便的,以及集成了Prometheus Grafana Jaeger Elastic Stack 监控服务监控的集成 主要包含以下几个步骤 a. 安装docker ...
- JavaWeb学习 (二十五)————监听器(Listener)
一.监听器介绍 1.1.监听器的概念
- ballerina 学习二十二 弹性服务
主要包含断路器模式,负载均衡模式,故障转移,重试 Circuit Breaker 参考代码 import ballerina/http; import ballerina/log; import ba ...
- ballerina 学习二十 http/https
提供http && https server && client 访问功能 client endpoint 说白了就是http client 参考代码 import b ...
随机推荐
- Git: A分支上的commit提交到B分支上
1. 执行git log -3 --graph A,查看A分支下的commit: 注:commit 后面的hash值代表某个commit,这里把”82f1fb7138c5860cc775b4b5ea7 ...
- 20145311 《Java程序设计》第5周学习总结
20145311 <Java程序设计>第5周学习总结 教材学习内容总结 第八章 8.1语法与继承结构 8.1.1Try.catch java中所有的错误都会打包为对象,可以try catc ...
- 解决方案--duilib中edit获得鼠标焦点后右边框被覆盖
用duilib做了一个登录框,用户名的输入使用的是edit控件. XML中是这样写的: <Edit name="subdomain_edit" tipvalue=" ...
- C++ 为什么要使用#ifdef __cplusplus extern "C" { #endif
转载:http://www.cnblogs.com/ayanmw/archive/2012/03/15/2398593.html 转载:http://blog.csdn.net/zkl99999/ar ...
- 获取本机IP,返回字符串
public static String GetLocalIp() { String[] Ips = GetLocalIpAddress(); foreach (String ip in Ips) i ...
- HDU 3416 Marriage Match IV(ISAP+最短路)题解
题意:从A走到B,有最短路,问这样不重复的最短路有几条 思路:先来讲选有效边,我们从start和end各跑一次最短路,得到dis1和dis2数组,如果dis1[u] + dis2[v] + cost[ ...
- Redis为什么要把所有数据放到内存中?
Redis为了达到最快的读写速度将数据都读到内存中,并通过异步的方式将数据写入磁盘.所以Redis具有快速和数据持久化的特性. 如果不将数据放到内存中,磁盘的I/O速度会严重影响redis的性能.在内 ...
- jsp页面中jstl标签详解[转]
JSLT标签库,是日常开发经常使用的,也是众多标签中性能最好的.把常用的内容,放在这里备份一份,随用随查.尽量做到不用查,就可以随手就可以写出来.这算是Java程序员的基本功吧,一定要扎实. JSTL ...
- (GoRails)ActionCable如何用Redis + 菜鸟redis教程
视频: https://gorails.com/episodes/how-actioncable-uses-redis?autoplay=1 原理PubSub, 你进入一个频道,然后就能接收,和发布信 ...
- Rails 5 Test Prescriptions 第10章 Testing for Security
Web 安全是一个可怕的主题.所有的你的程序都依靠密码学,代码超出了你的控制. 尽管如此,你还是可以控制部分网页安全 --所有的logins和access checks和injection error ...