|
| 1 | +# Inspired in https://github.com/Kong/docker-kong |
| 2 | +version: '3.9' |
| 3 | + |
| 4 | +x-kong-config: |
| 5 | + &kong-env |
| 6 | + KONG_DATABASE: postgres |
| 7 | + KONG_PG_DATABASE: ${KONG_PG_DATABASE:-kong} |
| 8 | + KONG_PG_HOST: db |
| 9 | + KONG_PG_USER: ${KONG_PG_USER:-kong} |
| 10 | + KONG_PG_PASSWORD_FILE: /run/secrets/kong_postgres_password |
| 11 | + |
| 12 | +volumes: |
| 13 | + kong_data: {} |
| 14 | + kong_prefix_vol: |
| 15 | + driver_opts: |
| 16 | + type: tmpfs |
| 17 | + device: tmpfs |
| 18 | + kong_tmp_vol: |
| 19 | + driver_opts: |
| 20 | + type: tmpfs |
| 21 | + device: tmpfs |
| 22 | + |
| 23 | +networks: |
| 24 | + kong-net: |
| 25 | + external: false |
| 26 | + |
| 27 | +services: |
| 28 | + kong-migrations: |
| 29 | + image: "kong/incubator:gateway-wasmer-3.0.0.0" |
| 30 | + command: kong migrations bootstrap |
| 31 | + depends_on: |
| 32 | + - db |
| 33 | + environment: |
| 34 | + <<: *kong-env |
| 35 | + secrets: |
| 36 | + - kong_postgres_password |
| 37 | + networks: |
| 38 | + - kong-net |
| 39 | + restart: on-failure |
| 40 | + |
| 41 | + kong-migrations-up: |
| 42 | + image: "kong/incubator:gateway-wasmer-3.0.0.0" |
| 43 | + command: kong migrations up && kong migrations finish |
| 44 | + depends_on: |
| 45 | + - db |
| 46 | + - kong-migrations |
| 47 | + environment: |
| 48 | + <<: *kong-env |
| 49 | + secrets: |
| 50 | + - kong_postgres_password |
| 51 | + networks: |
| 52 | + - kong-net |
| 53 | + restart: on-failure |
| 54 | + |
| 55 | + kong: |
| 56 | + image: "kong/incubator:gateway-wasmer-3.0.0.0" |
| 57 | + user: "${KONG_USER:-kong}" |
| 58 | + environment: |
| 59 | + <<: *kong-env |
| 60 | + KONG_ADMIN_ACCESS_LOG: /dev/stdout |
| 61 | + KONG_ADMIN_ERROR_LOG: /dev/stderr |
| 62 | + KONG_PROXY_LISTEN: "${KONG_PROXY_LISTEN:-0.0.0.0:8000}" |
| 63 | + KONG_ADMIN_LISTEN: "${KONG_ADMIN_LISTEN:-0.0.0.0:8001}" |
| 64 | + KONG_PROXY_ACCESS_LOG: /dev/stdout |
| 65 | + KONG_PROXY_ERROR_LOG: /dev/stderr |
| 66 | + KONG_PREFIX: ${KONG_PREFIX:-/var/run/kong} |
| 67 | + KONG_DECLARATIVE_CONFIG: "/opt/kong/kong.yaml" |
| 68 | + KONG_WASM: "on" |
| 69 | + KONG_WASM_MODULES: "/wasm/main.wasm" |
| 70 | + secrets: |
| 71 | + - kong_postgres_password |
| 72 | + networks: |
| 73 | + - kong-net |
| 74 | + ports: |
| 75 | + # The following two environment variables default to an insecure value (0.0.0.0) |
| 76 | + # according to the CIS Security test. |
| 77 | + - "${KONG_INBOUND_PROXY_LISTEN:-0.0.0.0}:8000:8000/tcp" |
| 78 | + - "${KONG_INBOUND_SSL_PROXY_LISTEN:-0.0.0.0}:8443:8443/tcp" |
| 79 | + # Making them mandatory but undefined, like so would be backwards-breaking: |
| 80 | + # - "${KONG_INBOUND_PROXY_LISTEN?Missing inbound proxy host}:8000:8000/tcp" |
| 81 | + # - "${KONG_INBOUND_SSL_PROXY_LISTEN?Missing inbound proxy ssl host}:8443:8443/tcp" |
| 82 | + # Alternative is deactivating check 5.13 in the security bench, if we consider Kong's own config to be enough security here |
| 83 | + |
| 84 | + - "127.0.0.1:8001:8001/tcp" |
| 85 | + - "127.0.0.1:8444:8444/tcp" |
| 86 | + healthcheck: |
| 87 | + test: [ "CMD", "kong", "health" ] |
| 88 | + interval: 10s |
| 89 | + timeout: 10s |
| 90 | + retries: 10 |
| 91 | + restart: on-failure:5 |
| 92 | + read_only: true |
| 93 | + volumes: |
| 94 | + - kong_prefix_vol:${KONG_PREFIX:-/var/run/kong} |
| 95 | + - kong_tmp_vol:/tmp |
| 96 | + - ./config:/opt/kong |
| 97 | + - ../../build:/wasm |
| 98 | + security_opt: |
| 99 | + - no-new-privileges |
| 100 | + depends_on: |
| 101 | + - httpbin |
| 102 | + |
| 103 | + db: |
| 104 | + image: postgres:9.5 |
| 105 | + environment: |
| 106 | + POSTGRES_DB: ${KONG_PG_DATABASE:-kong} |
| 107 | + POSTGRES_USER: ${KONG_PG_USER:-kong} |
| 108 | + POSTGRES_PASSWORD_FILE: /run/secrets/kong_postgres_password |
| 109 | + secrets: |
| 110 | + - kong_postgres_password |
| 111 | + healthcheck: |
| 112 | + test: [ "CMD", "pg_isready", "-U", "${KONG_PG_USER:-kong}" ] |
| 113 | + interval: 30s |
| 114 | + timeout: 30s |
| 115 | + retries: 3 |
| 116 | + restart: on-failure |
| 117 | + stdin_open: true |
| 118 | + tty: true |
| 119 | + networks: |
| 120 | + - kong-net |
| 121 | + volumes: |
| 122 | + - kong_data:/var/lib/postgresql/data |
| 123 | + |
| 124 | + httpbin: |
| 125 | + image: mccutchen/go-httpbin:v2.5.0 |
| 126 | + environment: |
| 127 | + - MAX_BODY_SIZE=15728640 # 15 MiB |
| 128 | + ports: |
| 129 | + - 10080:8080 |
| 130 | + networks: |
| 131 | + - kong-net |
| 132 | + |
| 133 | + service-provisioner: |
| 134 | + image: clue/httpie |
| 135 | + volumes: |
| 136 | + - .:/run |
| 137 | + entrypoint: [ "/run/service-provisioner.sh" ] |
| 138 | + depends_on: |
| 139 | + - httpbin |
| 140 | + - kong |
| 141 | + networks: |
| 142 | + - kong-net |
| 143 | + |
| 144 | +secrets: |
| 145 | + kong_postgres_password: |
| 146 | + file: ./POSTGRES_PASSWORD |
0 commit comments