Public | Automated Build

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description

Shoutem API specification in RAML

TODO: Transfer API RAML spec to the server repo. It should be hosted by the server instance and synced with its release cycle. Same applies for Lightspeed.

Before designing your API please check the Style guide.

Pull requests

Every new API should be designed in RAML and reviewed before implementation.

NOTE: Please make sure your RAML source compiles, by running it in API Console, before posting a new pull request.

API Console

Documentation and API Console can be run using Docker. Setup Docker and its host using instructions that can be found here.

Build Docker image

$ docker build -t shoutem/api-console .

Docker image is build with API Console source, all of its dependencies and RAML source copied at /api-console/app/api folder.

Start Docker container

$ docker run -d -p 9000 --name shoutem_api_console shoutem/api-console

This command will run an image inside the new container named 'shoutem_api_console'. Use docker ps command to list currenty running containers and exposed ports.

ShoutEm API Console url: [host:port]/?raml=shoutem/shoutem.raml

LightSpeed API Console url: [host:port]/?raml=lightspeed/lightspeed.raml

To get docker VM ip on OSX:
$ boot2docker ip

Docker toolbox replaced boot2docker.
Now use:

$ docker-machine ls

NAME      ACTIVE   DRIVER       STATE     URL                         SWARM
default   *        virtualbox   Running   tcp://192.168.99.100:2376

To find out the ports the containers are running on:

$ docker ps

RAML container

To avoid rebuilding the API console container every time RAML file is changed, you can build just the container serving RAML and then point the API console to the RAML url.

$ cd ./shoutem
$ docker build -t shoutem/raml .

Start the container

$ docker run -d -p 8000 --name shoutem_raml shoutem/raml

Open the RAML file with the API Console by using the raml query parameter: [shoutem_api_console-host:port]/?raml=[shoutem_raml-host:port]/shoutem.raml

API Notebook

Notebooks are a way to create tutorials and examples with runnable code samples, and also a powerful way to explore APIs.

For more info please reference the guide and examples.

Deployment

Step #1 is to push the built images to the docker container hub. Detailed instructions can be found here, but basically you login with the docker CLI and then push the images to the central hub. From there you can pull and then run this containers on any machine running docker.

$ docker login
$ docker push shoutem/api-console
$ docker push shoutem/raml

Then ssh to the host machine where you will run your containers.

We use the jwilder/nginx-proxy, an automated nginx proxy for Docker containers, to forward traffic to the running containers based on requested subdomain. Run the proxy if its not already running:

$ docker run -d -p 80:80 -v /apps/htpasswd:/etc/nginx/htpasswd -v /var/run/docker.sock:/tmp/docker.sock --name shoutem_secure_proxy jwilder/nginx-proxy

Pull the new image from the docker hub and run it, passing in host and port env variables which the proxy will read.

$ docker pull shoutem/api-console
$ docker run -d -e VIRTUAL_HOST=api.labs.shoutem.com -e VIRTUAL_PORT=9000 --name shoutem_api_console shoutem/api-console

Simmilary if you wish to run the RAML container:

$ docker pull shoutem/raml
$ docker run -d -e VIRTUAL_HOST=raml.labs.shoutem.com -e VIRTUAL_PORT=8000 --name shoutem_raml shoutem/raml

References

Docker Pull Command
Owner
shoutem
Source Repository

Comments (0)