zoukankan      html  css  js  c++  java
  • PostgREST docker-compose 试用

    PostgREST 是一款很不错的直接将pg 数据库暴露为restapi ,使用了基于行级别安全访问控制,
    比较全的restapi 查询以及集成了swagger openapi

    docker-compose 文件

    version: '3'
    services:
      server:
        image: postgrest/postgrest
        ports:
          - "3001:3000"
        links:
          - db:db
        environment:
          PGRST_DB_URI: postgres://app_user:password@db:5432/app_db
          PGRST_DB_SCHEMA: public
          PGRST_DB_ANON_ROLE: app_user #In production this role should not be the same as the one used for the connection
        depends_on:
          - db
      db:
        image: postgres
        ports:
          - "5433:5432"
        environment:
          POSTGRES_DB: app_db
          POSTGRES_USER: app_user
          POSTGRES_PASSWORD: password
      swagger:
        image: swaggerapi/swagger-ui
        ports:
        - "8081:8080"
        environment:
         API_URL: http://localhost:3001/

    运行

    • 启动
    docker-compose up  -d
    • swagger-ui
    open http://localhost:8081
    • 添加表数据
    -- DDL generated by Postico 1.4.3
    -- Not all database features are supported. Do not use for backup.
    
    -- Table Definition ----------------------------------------------
    
    CREATE TABLE userapps (
        id SERIAL PRIMARY KEY,
        name text
    );
    
    -- Indices -------------------------------------------------------
    
    CREATE UNIQUE INDEX userapps_pkey ON userapps(id int4_ops);
    
    INSERT INTO "public"."userapps"("id","name")
    VALUES
    (1,E'dalong'),
    (2,E'app');
    • 效果

    参考资料

    http://postgrest.org/en/v5.1/tutorials/tut0.html
    http://postgrest.org/en/v5.1/install.html#docker

  • 相关阅读:
    建造者模式的使用场景
    由于losf引起的pxc启动报错处理
    mysql5.6源码自动安装脚本
    mysql5.7.16二进制安装
    Maven入门
    数据链路层
    图-拓扑排序
    线性表-队列
    线性表-链表
    Java基本概念(未完)
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/9946193.html
Copyright © 2011-2022 走看看