├── docker-compose.yml ├── docker-kong └── docker-compose.yaml └── services └── service ├── Dockerfile └── main.go /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.7" 2 | 3 | networks: 4 | kong-net: 5 | name: kong-net 6 | driver: bridge 7 | 8 | 9 | services: 10 | 11 | servicea: 12 | image: wesleywillians/kong-service:latest 13 | environment: 14 | PORT: ":8081" 15 | CONTENT: "

Service A

" 16 | networks: 17 | - kong-net 18 | ports: 19 | - 8081:8081 20 | 21 | serviceb: 22 | image: wesleywillians/kong-service:latest 23 | environment: 24 | PORT: ":8082" 25 | CONTENT: "

Service b

" 26 | networks: 27 | - kong-net 28 | ports: 29 | - 8082:8082 30 | 31 | servicec: 32 | image: wesleywillians/kong-service:latest 33 | environment: 34 | PORT: ":8083" 35 | CONTENT: "

Service C

" 36 | networks: 37 | - kong-net 38 | ports: 39 | - 8083:8083 -------------------------------------------------------------------------------- /docker-kong/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | volumes: 4 | kong_data: {} 5 | 6 | networks: 7 | kong-net: 8 | external: true 9 | 10 | services: 11 | kong-migrations: 12 | image: "kong:2.3.2-alpine" 13 | command: kong migrations bootstrap 14 | depends_on: 15 | - db 16 | environment: 17 | KONG_DATABASE: postgres 18 | KONG_PG_DATABASE: kong 19 | KONG_PG_HOST: db 20 | KONG_PG_USER: kong 21 | KONG_PG_PASSWORD: kong 22 | networks: 23 | - kong-net 24 | restart: on-failure 25 | deploy: 26 | restart_policy: 27 | condition: on-failure 28 | 29 | kong-migrations-up: 30 | image: "kong:2.3.2-alpine" 31 | command: kong migrations up && kong migrations finish 32 | depends_on: 33 | - db 34 | environment: 35 | KONG_DATABASE: postgres 36 | KONG_PG_DATABASE: kong 37 | KONG_PG_HOST: db 38 | KONG_PG_USER: kong 39 | KONG_PG_PASSWORD: kong 40 | networks: 41 | - kong-net 42 | restart: on-failure 43 | deploy: 44 | restart_policy: 45 | condition: on-failure 46 | 47 | kong: 48 | image: "kong:2.3.2-alpine" 49 | user: "kong" 50 | depends_on: 51 | - db 52 | environment: 53 | KONG_ADMIN_ACCESS_LOG: /dev/stdout 54 | KONG_ADMIN_ERROR_LOG: /dev/stderr 55 | KONG_ADMIN_LISTEN: '0.0.0.0:8001' 56 | KONG_CASSANDRA_CONTACT_POINTS: db 57 | KONG_DATABASE: postgres 58 | KONG_PG_DATABASE: kong 59 | KONG_PG_HOST: db 60 | KONG_PG_USER: kong 61 | KONG_PROXY_ACCESS_LOG: /dev/stdout 62 | KONG_PROXY_ERROR_LOG: /dev/stderr 63 | KONG_PG_PASSWORD: kong 64 | 65 | networks: 66 | - kong-net 67 | ports: 68 | - "8000:8000/tcp" 69 | - "127.0.0.1:8001:8001/tcp" 70 | - "8443:8443/tcp" 71 | - "127.0.0.1:8444:8444/tcp" 72 | healthcheck: 73 | test: ["CMD", "kong", "health"] 74 | interval: 10s 75 | timeout: 10s 76 | retries: 10 77 | restart: on-failure 78 | deploy: 79 | restart_policy: 80 | condition: on-failure 81 | 82 | db: 83 | image: postgres:9.5 84 | environment: 85 | POSTGRES_DB: kong 86 | POSTGRES_USER: kong 87 | POSTGRES_PASSWORD: kong 88 | 89 | healthcheck: 90 | test: ["CMD", "pg_isready", "-U", "kong"] 91 | interval: 30s 92 | timeout: 30s 93 | retries: 3 94 | restart: on-failure 95 | deploy: 96 | restart_policy: 97 | condition: on-failure 98 | stdin_open: true 99 | tty: true 100 | networks: 101 | - kong-net 102 | # volumes: 103 | # - kong_data:/var/lib/postgresql/data 104 | 105 | konga-prepare: 106 | container_name: konga-prepare 107 | image: pantsel/konga:latest 108 | command: "-c prepare -a postgres -u postgresql://kong:kong@db:5432/konga_db" 109 | networks: 110 | - kong-net 111 | restart: on-failure 112 | depends_on: 113 | - db 114 | 115 | konga: 116 | container_name: konga 117 | image: pantsel/konga:latest 118 | restart: always 119 | networks: 120 | - kong-net 121 | environment: 122 | DB_ADAPTER: postgres 123 | DB_HOST: db 124 | DB_USER: kong 125 | DB_PASSWORD: kong 126 | TOKEN_SECRET: ahfdjgjgf79JKLFHJKh978953kgdfjkl 127 | DB_DATABASE: konga_db 128 | NODE_ENV: production 129 | depends_on: 130 | - db 131 | ports: 132 | - "1337:1337" -------------------------------------------------------------------------------- /services/service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.16 as builder 2 | 3 | WORKDIR /go/src/ 4 | COPY . . 5 | RUN GOOS=linux CGO_ENABLED=0 go build -o server main.go 6 | 7 | FROM scratch 8 | WORKDIR /go/ 9 | COPY --from=builder /go/src/server /go 10 | CMD ["/go/server"] -------------------------------------------------------------------------------- /services/service/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | "os" 8 | ) 9 | 10 | func handler(w http.ResponseWriter, r *http.Request) { 11 | fmt.Fprintf(w, os.Getenv("CONTENT")) 12 | } 13 | 14 | func main() { 15 | http.HandleFunc("/", handler) 16 | log.Fatal(http.ListenAndServe(os.Getenv("PORT"), nil)) 17 | } 18 | --------------------------------------------------------------------------------