Containerisation¶
ASAB is designed for deployment into containers such as LXC/LXD or Docker. It allows to build e.g. microservices that provides REST interface or consume MQ messages while being deployed into a container for a sake of the infrastructure flexibility.
ASAB in a LXC/LXD container¶
- Prepare LXC/LXD container based on Alpine Linux
$ lxc launch images:alpine/3.8 asab
- Swich into a container
$ lxc exec asab -- /bin/ash
- Adjust a container
$ sed -i 's/^tty/# tty/g' /etc/inittab
- Prepare Python3 environment
$ apk update
$ apk upgrade
$ apk add --no-cache python3
$ python3 -m ensurepip
$ rm -r /usr/lib/python*/ensurepip
$ pip3 install --upgrade pip setuptools
- Deploy ASAB
$ pip3 install asab
- Deploy dependencies
$ pip3 install asab python-daemon
- (Optionally if you want to use
asab.web
module) install aiohttp dependecy
$ pip3 install aiohttp
- Use OpenRC to automatically start/stop ASAB application
$ vi /etc/init.d/asab-app
Adjust the example of OpenRC init file.
$ chmod a+x /etc/init.d/asab-app
$ rc-update add asab-app
Note: If you need to install python packages that require compilation using C compiler, you have to add following dependencies:
$ apk add --virtual .buildenv python3-dev
$ apk add --virtual .buildenv gcc
$ apk add --virtual .buildenv musl-dev
And removal of the build tools after pip install:
$ apk del .buildenv