Open JnMik opened 8 years ago
I have not thought about adding it to be honest. Might consider if there is a use case for it.
Well my thought on this is : Docker is getting more and more love, and kong also support docker, their image is available right there https://hub.docker.com/r/mashape/kong/
So for some infrastructure based only on docker servers, it's really interesting to have everything setup with something as simple as :
$ docker pull CyExy/kongfig followed by $ docker run -v api_definition.yml:/srv/app/api_definition.yml CyExy/kongfig kongfig --path /srv/app/api_definition.yml --host [current-server-ip:port]
I run kongfig via docker through a private repository on dockerhub, but working with an official repo which is getting updated automatically would be awesome.
https://github.com/mybuilder/kongfig/pull/28
I did that, should help stuff get started :) That way, anyone can use it to push it to their own Docker repository.
If you ever want to handle an official repository, hardcode an image name in the shell script file.
@JnMik PR is the correct way to make up to date Docker images. I needed one, however, just for the latest version. Based on @JnMik work (and others on Docker Hub) here's a simple Dockerfile to get started with.
FROM node:5-slim
ENV VERSION=1.3.0
WORKDIR /srv/app
RUN npm install -g kongfig@$VERSION
Build the image.
docker build -t my/kongfig:1.3.0 .
I use PowerShell and I can manage configurations with the following commands. This assumes you have a Kong container (named 'kong') running.
docker run --rm --link kong:kong my/kongfig kongfig dump --host kong:8001 > kongfig.yml
docker run --rm --link kong:kong -v $PWD/:/srv/app my/kongfig kongfig apply --host kong:8001 --path /srv/app/kongfig.yml
Note that the dump created a UTF-16LE encoded file which I needed to save as UTF-8 before I could apply it.
I have a similar aproach as @Boggin but using docker-compose. My use-case is Continuous Integration, so I ca deploy my local environment changes to devel/qa/production environments using only CI scripts, git and configurations-as-code.
My Dockerfile (./docker/kongfig/Dockerfile):
FROM node:8-alpine
RUN npm -g install kongfig
I have some kong service defined in my main docker-compose.yml as:
services:
...
kong:
image: kong:0.11.2
...
And an ephimeral container in another docker-compose-kongfig.yml as:
...
version: '3.1'
services:
kongfig:
build: ./docker/kongfig
external_links:
- kong
volumes:
- ./docker/kongfig/config:/config
Finally, can I run the kongfig container as:
docker-compose -f ~//docker-compose-kongfig.yml run --rm kongfig sh -c 'kongfig apply --path /config/config.yml --host kong:8001'
Directory ./docker/kongfig/config is mounted as a volume to allow file-sharing and local code tracking using git.
I can provide a dockerfile and some 'run' command with volume mapping for the APIs definition Yaml to be external of the image (may differ when switching environnements)
That would be nice to have a public dockerhub repo and connect the webhook directly on the github project, the docker image would be rebuilded automatically on release.