A docker image that allows to quickly create a microservice with the boiler-plate
Just create an api.yml file to use for the swagger definition and a python
package to mount to
/app/api/orm that includes the database model(s) and
api methods defined in the api.yml file.
This image is designed to be used with a postgres database backend. The default
link name is
postgres, but can be overriden with environment variables.
build/api/config.py for the environment variable options.
Base Image: python:alpine (3.6.0)
Additional Packages: make
See the example app for how to setup the package.
There are two flavors of images, onbuild is typically the easiest, but requires
certain naming conventions in your package dir. The swagger file should be
in the base directory (where you have your Dockerfile) using the name
api.yml , which will be copied to
/app/config/api.yml onbuild and
you should have a python package named orm which will be copied to
/app/api/orm onbuild. The onbuild also accepts some
If you are not using the onbuild variant then, you should copy your swagger file
/app/config/api.yml as well as your package to
/app/api/orm. You can
then include the APP_PORT as an environment variable in your Dockerfile.
You should also call the
/app/install.sh with an optional
(same as APP_NAME) and an optional
--version (same as APP_VERSION)
to call the python setup.py properly.
NOTE: You can call the
/app/install.sh without any options to use the
default values shown in the onbuild-args section. Or just call
pip install /app in your Dockerfile.
On either image to override the default uwsgi.yml you can copy a yaml
configuration file to
/app/config/uwsgi.yml. The default uwsgi.yml listens
on a TCP socket the envrionment variable APP_PORT. Which is best if used
behind an api-gateway such as nginx. However for testing it can often
be nice to listen for http requests, which is when you should add your own
The following options can be used when building your dockerfile with the
--build-arg APP_NAME=example syntax.
- APP_NAME: A custom name for the python setup.py script (defaults to api)
- APP_VERSION: A custom version for the python setup.py script (defaults to 0.0.1)
- APP_PORT: A custom port to use for the uwsgi socket. (defaults to 8080)