zoukankan      html  css  js  c++  java
  • aceql-http docker 试用

    以前有介绍过aceql-http 一个不错的database rest http 暴露,充分利用了tomcat 的好多特性,以下是基于docker 运行的学习

    环境准备

    • dockerfile
    FROM dalongrong/openjdk11:stretch-jvm-tools
    LABEL AUTHOR="rongfengliang"
    LABEL EMAIL="1141591465@qq.com"
    ENV VERSION=4.0
    ENV ACEQL_HTTP_HOST=localhost
    WORKDIR /app
    RUN wget https://www.aceql.com/rest/soft/${VERSION}/download/aceql-http-${VERSION}.run 
        && chmod +x aceql-http-${VERSION}.run 
        && sh aceql-http-${VERSION}.run 
        && rm -rf aceql-http-${VERSION}.run
    ENV PATH=$PATH:/app/aceql-http-${VERSION}/bin
    ENV ACEQL_HOME=/app/aceql-http-${VERSION}
    COPY aceql-server.properties /app/aceql-http-${VERSION}/conf/aceql-server.properties
    COPY entrypoint.sh /entrypoint.sh
    RUN chmod +x /entrypoint.sh
    EXPOSE 9090
    ENTRYPOINT [ "/entrypoint.sh" ]
     
     

    简单说明: 基础镜像使用了openjdk11,此镜像集成了一些jvm 性能监控工具,因为 aceql-http 使用了makeself
    直接执行就可以解压安装包内容了
    entrypoint.sh: 入口

     
    #!/bin/sh
    aceql-server -start -host ${ACEQL_HTTP_HOST} –port 9090

    aceql-server.properties 数据库连接,这个比较简单,为了方便修改为了pg 的(使用docker-compose 的服务)
    此文件没有配置用户认证的,如果查看说明以及源码会发现,不配置使用默认,实际上是裸奔的,login 方法直接
    返回true,所以如果需要认证,可以使用文档介绍的jwt,具体参考文档

     
    # Database names separated by commas
    databases = postgres
    # Mandatory JDBC properties:
    # PostgreSQL example
    postgres.driverClassName = org.postgresql.Driver
    postgres.url= jdbc:postgresql://postgres:5432/postgres
    postgres.username= postgres  
    postgres.password= dalong  
     
     
    • docker-compose 服务
    version: "3"
    services: 
        postgres:
          image: postgres:9.5-alpine
          ports:
          - "5432:5432"
          environment:
          - "POSTGRES_PASSWORD:dalong"
        aceql-http:
          build: ./
          volumes: 
          - "./flame:/app/arthas-output"
          ports:
          - "9090:9090"

    启动&&测试

    • 构建镜像
    docker-compose build
    • 初始化数据库
    CREATE TABLE appdemos (
        id SERIAL PRIMARY KEY,
        appname text
    );
    CREATE TABLE user_login
    (               
      username varchar(255) not null,     
      hash_password varchar(40) not null,
            PRIMARY KEY (username)
    );
    insert into user_login values ('username', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8');
    insert into user_login values ('MyUsername', 'eabbec6f31804eb968e2faeaaef150546a595fc3');
    • 请求sessionid

      说明,此处任何的用户账户都可以,因为使用的默认认证,永远返回true,直接看官方文档可能还会迷惑

    curl --data-urlencode "password=MySecret" 
     http://localhost:9090/aceql/database/postgres/username/MyUsername/connect

    返回内容

    • insert 数据
    curl --data-urlencode "sql=insert into appdemos values (1,'dalongdemo')" http://localhost:9090/aceql/session/ra6x1jbw463x5svw32thonn4l7/execute_update

    返回内容

    • 查询数据
    curl --data-urlencode "sql=select * from appdemos" --data "pretty_printing=true" http://localhost:9090/aceql/session/ra6x1jbw463x5svw32thonn4l7/execute_query

    返回内容

    说明

    以上就是关于aceql-http docker 运行的一些学习,后续可以在学习下jwt 以及自定义认证的

    参考资料

    https://github.com/rongfengliang/aceql-http-docker
    https://github.com/kawansoft/aceql-http/blob/master/aceql-http-4.0-user-guide-server.md#session-management-and-security
    https://github.com/kawansoft/aceql-http
    https://hub.docker.com/repository/docker/dalongrong/aceql-http

  • 相关阅读:
    Ubuntu Server 17.04安装GNOME指令
    docker应用笔记
    无线网络连接配置
    bind9的一些配置
    关于linux下的文件权限
    命令行模式下设置时区
    Linux下SSL证书申请以及配置到Nginx
    编译安装Nginx到Linux
    网页画流程图
    为什么Java字符串是不可变对象?
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/12237556.html
Copyright © 2011-2022 走看看