Skip to content

Commit 24fe238

Browse files
committed
Merge pull request Kong#31 from Mashape/0.8.0
0.8.0
2 parents dfaabcf + 8683cf3 commit 24fe238

File tree

3 files changed

+49
-13
lines changed

3 files changed

+49
-13
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM centos:7
22
MAINTAINER Marco Palladino, marco@mashape.com
33

4-
ENV KONG_VERSION 0.7.0
4+
ENV KONG_VERSION 0.8.0
55

66
RUN yum install -y epel-release
77
RUN yum install -y https://github.com/Mashape/kong/releases/download/$KONG_VERSION/kong-$KONG_VERSION.el7.noarch.rpm && \
@@ -11,6 +11,12 @@ VOLUME ["/etc/kong/"]
1111

1212
COPY config.docker/kong.yml /etc/kong/kong.yml
1313

14+
# Set the database to use
15+
RUN if [ -z "$DATABASE" ]; then \
16+
DATABASE="cassandra"; \
17+
fi; \
18+
echo -e 'database: "'$DATABASE'"' >> /etc/kong/kong.yml;
19+
1420
CMD kong start
1521

1622
EXPOSE 8000 8443 8001 7946

README.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ This is the official Docker image for [Kong][kong-site-url].
2020
- `0.6.0` - *([Dockerfile](https://github.com/Mashape/docker-kong/blob/0.6.0/Dockerfile))*
2121
- `0.6.1` - *([Dockerfile](https://github.com/Mashape/docker-kong/blob/0.6.1/Dockerfile))*
2222
- `0.7.0` - *([Dockerfile](https://github.com/Mashape/docker-kong/blob/0.7.0/Dockerfile))*
23-
- `latest` - *([Dockerfile](https://github.com/Mashape/docker-kong/blob/0.7.0/Dockerfile))*
23+
- `0.8.0` - *([Dockerfile](https://github.com/Mashape/docker-kong/blob/0.8.0/Dockerfile))*
24+
- `latest` - *([Dockerfile](https://github.com/Mashape/docker-kong/blob/0.8.0/Dockerfile))*
2425

2526
# What is Kong?
2627

@@ -32,21 +33,42 @@ Kong's documentation can be found at [getkong.org/docs][kong-docs-url].
3233

3334
# How to use this image
3435

35-
First, Kong requires a running Cassandra cluster before it starts. You can either use the [mashape/cassandra](https://github.com/Mashape/docker-cassandra) image, provision a test instance on [kongdb.org](http://kongdb.org) or use a cluster of your own.
36+
First, Kong requires a running Cassandra or PostgreSQL cluster before it starts. You can either use the official Cassandra/PostgreSQL containers, or use your own.
3637

37-
## 1. Link Kong to a Cassandra container
38+
## 1. Link Kong to either a Cassandra or PostgreSQL container
3839

39-
Start a Cassandra container by doing so:
40+
It's up to you to decide which datastore between Cassandra or PostgreSQL you want to use, since Kong supports both.
41+
42+
### Cassandra
43+
44+
Start a Cassandra container by executing:
4045

4146
```shell
42-
$ docker run -d -p 9042:9042 --name cassandra cassandra:2.2.4
47+
$ docker run -d --name kong-database \
48+
-p 9042:9042 \
49+
cassandra:2.2
4350
```
4451

45-
Once Cassandra is running, we can start a Kong container and link it to the Cassandra container:
52+
### Postgres
53+
54+
Start a PostgreSQL container by executing:
55+
56+
```shell
57+
docker run -d --name kong-database \
58+
-p 5432:5432 \
59+
-e "POSTGRES_USER=kong" \
60+
-e "POSTGRES_DB=kong" \
61+
postgres:9.4
62+
```
63+
64+
### Start Kong
65+
66+
Once the database is running, we can start a Kong container and link it to the database container, and configuring the `DATABASE` environment variable with either `cassandra` or `postgres` depending on which database you decided to use:
4667

4768
```shell
4869
$ docker run -d --name kong \
49-
--link cassandra:cassandra \
70+
-e "DATABASE=cassandra" \ # or "DATABASE=postgres"
71+
--link kong-database:kong-database \
5072
-p 8000:8000 \
5173
-p 8443:8443 \
5274
-p 8001:8001 \
@@ -56,11 +78,13 @@ $ docker run -d --name kong \
5678
mashape/kong
5779
```
5880

59-
If everything went well, and if you created your container with the default ports, Kong should be listening on your host's `8000` ([proxy][kong-docs-proxy-port]) and `8001` ([admin api][kong-docs-admin-api-port]) ports.
81+
**Note:** If Docker complains that `--security-opt` is an invalid option, just remove it and re-execute the command (it was introduced in Docker 1.3).
82+
83+
If everything went well, and if you created your container with the default ports, Kong should be listening on your host's `8000` ([proxy][kong-docs-proxy-port]), `8443` ([proxy SSL][kong-docs-proxy-ssl-port]) and `8001` ([admin api][kong-docs-admin-api-port]) ports. Port `7946` ([cluster][kong-docs-cluster-port]) is being used only by other Kong nodes.
6084

6185
You can now read the docs at [getkong.org/docs][kong-docs-url] to learn more about Kong.
6286

63-
## 2. Use Kong with a custom configuration (and Cassandra cluster)
87+
## 2. Use Kong with a custom configuration (and a custom Cassandra/PostgreSQL cluster)
6488

6589
This container stores the [Kong configuration file](http://getkong.org/docs/latest/configuration/) in a [Data Volume][docker-data-volume]. You can store this file on your host (name it `kong.yml` and place it in a directory) and mount it as a volume by doing so:
6690

@@ -77,7 +101,7 @@ $ docker run -d \
77101
mashape/kong
78102
```
79103

80-
When attached this way you can edit your configuration file from your host machine and restart your container. You can also make the container point to a different Cassandra instance, so no need to link it to a Cassandra container.
104+
When attached this way you can edit your configuration file from your host machine and restart your container. You can also make the container point to a different Cassandra/PostgreSQL instance, so no need to link it to a Cassandra/PostgreSQL container.
81105

82106
## Reload Kong in a running container
83107

@@ -104,7 +128,9 @@ Before you start to code, we recommend discussing your plans through a [GitHub i
104128
[kong-site-url]: http://getkong.org
105129
[kong-docs-url]: http://getkong.org/docs
106130
[kong-docs-proxy-port]: http://getkong.org/docs/latest/configuration/#proxy_port
131+
[kong-docs-proxy-ssl-port]: http://getkong.org/docs/latest/configuration/#proxy_listen_ssl
107132
[kong-docs-admin-api-port]: http://getkong.org/docs/latest/configuration/#admin_api_port
133+
[kong-docs-cluster-port]: http://getkong.org/docs/latest/configuration/#cluster_listen
108134
[kong-docs-reload]: http://getkong.org/docs/latest/cli/#reload
109135

110136
[github-new-issue]: https://github.com/Mashape/docker-kong/issues/new

config.docker/kong.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
database: cassandra
1+
postgres:
2+
host: "kong-database"
3+
port: 5432
4+
database: kong
5+
user: kong
26
cassandra:
37
contact_points:
4-
- "cassandra:9042"
8+
- "kong-database:9042"
59
nginx: |
610
{{user}}
711
worker_processes auto;

0 commit comments

Comments
 (0)