All Projects → renskiy → Fabricio

renskiy / Fabricio

Licence: mit
Docker deploy automation tool

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Fabricio

Dockercheatsheet
🐋 Docker Cheat Sheet 🐋
Stars: ✭ 3,301 (+1220.4%)
Mutual labels:  docker-compose, swarm, docker-swarm
Docker Traefik Prometheus
A Docker Swarm Stack for monitoring Traefik with Promethues and Grafana
Stars: ✭ 215 (-14%)
Mutual labels:  docker-compose, swarm, docker-swarm
Swarmpit
Lightweight mobile-friendly Docker Swarm management UI
Stars: ✭ 2,255 (+802%)
Mutual labels:  docker-compose, swarm, docker-swarm
Django React Typescript
A boilerplate with Django on the backend, React on the frontend, and much more!
Stars: ✭ 142 (-43.2%)
Mutual labels:  django, docker-compose
Miniswarm
Docker Swarm cluster in one command
Stars: ✭ 130 (-48%)
Mutual labels:  swarm, docker-swarm
Djangoweb
基于Django的运维平台
Stars: ✭ 137 (-45.2%)
Mutual labels:  django, docker-compose
Labs
This is a collection of tutorials for learning how to use Docker with various tools. Contributions welcome.
Stars: ✭ 10,443 (+4077.2%)
Mutual labels:  docker-compose, swarm
Opendevops
CODO是一款为用户提供企业多混合云、一站式DevOps、自动化运维、完全开源的云管理平台、自动化运维平台
Stars: ✭ 2,990 (+1096%)
Mutual labels:  docker-compose, k8s
Django Celery Docker Example
Example Docker setup for a Django app behind an Nginx proxy with Celery workers
Stars: ✭ 149 (-40.4%)
Mutual labels:  django, docker-compose
Froggy Service
邱威傑市民服務網站
Stars: ✭ 155 (-38%)
Mutual labels:  django, k8s
Docker Django Webpack Skeleton
Django Skeleton W/ Docker Dev & Production W/ Webpack 2 W/ BabelJS W/ Sass W/ PostgreSQL
Stars: ✭ 191 (-23.6%)
Mutual labels:  django, docker-compose
Dockstation
DockStation is developer-centric application to managing projects based on Docker. Instead of lots of CLI commands you can monitor, configure, and manage services and containers using just a GUI.
Stars: ✭ 1,744 (+597.6%)
Mutual labels:  docker-compose, docker-swarm
Docker Nginx Postgres Django Example
Example using Docker, Django, multiple Postgres databases, NginX, Gunicorn, pipenv, GitLab CI and tox.
Stars: ✭ 110 (-56%)
Mutual labels:  django, docker-compose
Docker Continuous Deployment
continuous deployment of a microservices application with Docker
Stars: ✭ 141 (-43.6%)
Mutual labels:  docker-compose, docker-swarm
Docker Compose Ui
web interface for Docker Compose
Stars: ✭ 1,454 (+481.6%)
Mutual labels:  docker-compose, docker-swarm
Skywalking Docker
【Deprecated】🎉 Deploy Skywalking in Docker container.
Stars: ✭ 154 (-38.4%)
Mutual labels:  docker-compose, k8s
Swarmstack
A Docker swarm-based starting point for operating highly-available containerized applications.
Stars: ✭ 181 (-27.6%)
Mutual labels:  swarm, docker-swarm
Kubernetes Kargo Logging Monitoring
Deploy kubernetes cluster with kargo
Stars: ✭ 202 (-19.2%)
Mutual labels:  deploy, k8s
Django Project Template
Thorgate's Django project template - Django, React, Sass, optional Docker and more
Stars: ✭ 91 (-63.6%)
Mutual labels:  django, docker-compose
Fusionauth Containers
Container definitions for docker, kubernetes, helm, and whatever containers come next!
Stars: ✭ 101 (-59.6%)
Mutual labels:  docker-compose, k8s

======== Fabricio

Fabricio is a Docker_ deploy automation tool used along with the Fabric_.

.. _Fabric: http://www.fabfile.org .. _Docker: https://www.docker.com

.. image:: https://travis-ci.org/renskiy/fabricio.svg?branch=master :target: https://travis-ci.org/renskiy/fabricio .. image:: https://coveralls.io/repos/github/renskiy/fabricio/badge.svg?branch=master :target: https://coveralls.io/github/renskiy/fabricio?branch=master

Features

  • build Docker images
  • create containers and services from images with provided tags
  • unlimited infrastructures
  • Fabric's parallel execution mode compatibility
  • rollback containers or services to previous version
  • public and private Docker registries support
  • deploy over SSH tunnel (e.g. access to image registry, proxy, etc.)
  • migrations apply and rollback
  • data backup and restore
  • Docker services (Swarm mode)
  • Docker stacks (Docker Compose 3.0+)
  • Kubernetes configurations

See changelog_ for detailed info.

.. _changelog: https://github.com/renskiy/fabricio/blob/master/changelog.rst

Basic example

The most basic :code:fabfile.py you can use with the Fabricio may look something like this:

.. code:: python

from fabricio import docker, tasks

app = tasks.DockerTasks(
    service=docker.Container(
        name='app',
        image='nginx:stable-alpine',
        options={
            'publish': '80:80',
        },
    ),
    hosts=['[email protected]'],
)

Type :code:fab --list in your terminal to see available Fabric commands:

::

Available commands:

    app.deploy  deploy service (prepare -> push -> backup -> pull -> migrate -> update)

Finally, to deploy such configuration you simply have to execute following bash command:

.. code:: bash

fab app.deploy

See also Fabricio examples and recipes_.

.. _examples and recipes: https://github.com/renskiy/fabricio/tree/master/examples/

Requirements

Local

  • Python 2.7, 3.4*, 3.5*, 3.6*, 3.7*, 3.8*
  • (optional) Docker 1.9+ for building Docker images

* Fabric3_ is used for compatibility with Python 3.x

.. _Fabric3: https://github.com/mathiasertl/fabric/

Remote

  • sshd
  • Docker 1.9+
  • Docker 1.12+ for using Docker services

Install

.. code:: bash

pip install fabricio

Note for macOS users

Just use latest version of Python instead of one installed by default. The easiest way to install fresh version of Python is using Homebrew_:

.. code:: bash

brew install python

.. _Homebrew: https://brew.sh

Contribute

All proposals and improvements are welcomed through a pull request_ or issue_. Just make sure all tests are running fine.

.. _pull request: https://github.com/renskiy/fabricio/pulls .. _issue: https://github.com/renskiy/fabricio/issues

Install test dependencies

.. code:: bash

pip install ".[test]"

Running tests

.. code:: bash

python -m unittest2 discover tests --verbose

Roles and infrastructures

You can define as many roles and infrastructures as you need. The following example shows 'production' and 'test' configurations for two-roles deploy configuration:

.. code:: python

from fabric import colors, api as fab
from fabricio import docker, tasks, infrastructure

@infrastructure
def testing():
    fab.env.roledefs.update(
        api=['[email protected]'],
        web=['[email protected]'],
    )

@infrastructure(color=colors.red)
def production():
    fab.env.roledefs.update(
        api=['[email protected]', '[email protected]'],
        web=['[email protected]'],
    )

web = tasks.DockerTasks(
    service=docker.Container(
        name='web',
        image='registry.example.com/web:latest',
        options={
            'publish': ['80:80', '443:443'],
            'volume': '/media:/media',
        },
    ),
    roles=['web'],
)

api = tasks.DockerTasks(
    service=docker.Container(
        name='api',
        image='registry.example.com/api:latest',
        options={
            'publish': '80:80',
        },
    ),
    roles=['api'],
)

Here is the list of available commands:

::

Available commands:

    production  select production infrastructure, 'production.confirm' skips confirmation dialog
    testing     select testing infrastructure, 'testing.confirm' skips confirmation dialog
    api.deploy  deploy service (prepare -> push -> backup -> pull -> migrate -> update)
    web.deploy  deploy service (prepare -> push -> backup -> pull -> migrate -> update)

'production' and 'testing' are available infrastructures here. To deploy to a particular infrastructure just provide it before any other Fabric command(s). For example:

.. code:: bash

fab testing api.deploy web.deploy

See Infrastructures and roles_ example for more details.

.. _Infrastructures and roles: https://github.com/renskiy/fabricio/blob/master/examples/roles

Tags

Almost every Fabricio command takes optional argument 'tag' which means Docker image tag to use when deploying container or service. For instance, if you want to deploy specific version of your application you can do it as following:

.. code:: bash

fab app.deploy:release-42

By default, value for tag is taken from Container/Service Image.

Also it is possible to completely (and partially) replace registry/account/name/tag/digest of image to deploy:

.. code:: bash

fab app.deploy:registry.example.com/registry-account/app-image:release-42
fab app.deploy:[email protected]:36b0181554913b471ae33546a9c19cc80e97f44ce5e7234995e307f14da57268

Rollback

To return container or service to a previous state execute this command:

.. code:: bash

fab app.rollback

Idempotency

Fabricio always tries to skip unnecessary container/service update. However, update can be forced by adding force=yes parameter:

.. code:: bash

fab app.deploy:force=yes

Private Docker registry

It is often when production infrastructure has limited access to the Internet or your security policy does not allow using of public Docker image registries. In such case Fabricio offers ability to use private Docker registry which can be used also as an intermediate registry for the selected infrastructure. To use this option you have to have local Docker registry running within your LAN and also Docker client on your PC. If you have Docker installed you can run up Docker registry locally by executing following command:

.. code:: bash

docker run --name registry --publish 5000:5000 --detach registry:2

When your local Docker registry is up and run you can provide custom registry which will be used as an intermediate Docker registry accessed via reverse SSH tunnel:

.. code:: python

from fabricio import docker, tasks

app = tasks.DockerTasks(
    service=docker.Container(
        name='app',
        image='nginx:stable-alpine',
        options={
            'publish': '80:80',
        },
    ),
    registry='localhost:5000',
    ssh_tunnel='5000:5000',
    hosts=['[email protected]'],
)

See Hello World_ example for more details.

.. _Hello World: https://github.com/renskiy/fabricio/tree/master/examples/hello_world/#ssh-tunneling

Building Docker images

Using Fabricio you can also build Docker images from local sources and deploy them to your servers. This example shows how this can be set up:

.. code:: python

from fabricio import docker, tasks

app = tasks.ImageBuildDockerTasks(
    service=docker.Container(
        name='app',
        image='registry.example.com/registry-account/app-image:latest-release',
    ),
    hosts=['[email protected]'],
    build_path='.',
)

By executing command app.deploy Fabricio will try to build image using Dockerfile from the folder provided by build_path parameter. After that image will be pushed to the registry (registry.example.com in the example above). And deploy itself will start on the last step.

See Building Docker images_ example for more details.

.. _Building Docker images: https://github.com/renskiy/fabricio/blob/master/examples/build_image

Docker services

Fabricio can deploy Docker services:

.. code:: python

from fabricio import docker, tasks

service = tasks.DockerTasks(
    service=docker.Service(
        name='my-service',
        image='nginx:stable',
        options={
            'publish': '8080:80',
            'replicas': 3,
        },
    ),
    hosts=['[email protected]'],
)

See Docker services_ example for more details.

.. _Docker services: https://github.com/renskiy/fabricio/blob/master/examples/service/swarm/

Docker stacks

Docker stacks are also supported (available since Docker 1.13):

.. code:: python

from fabricio import docker, tasks

stack = tasks.DockerTasks(
    service=docker.Stack(
        name='my-docker-stack',
        options={
            'compose-file': 'my-docker-compose.yml',
        },
    ),
    hosts=['[email protected]'],
)

See Docker stacks_ example for more details.

.. _Docker stacks: https://github.com/renskiy/fabricio/blob/master/examples/service/stack/

Kubernetes configuration

Kubernetes configuration can be deployed using following settings:

.. code:: python

from fabricio import kubernetes, tasks

k8s = tasks.DockerTasks(
    service=kubernetes.Configuration(
        name='my-k8s-configuration',
        options={
            'filename': 'configuration.yml',
        },
    ),
    hosts=['[email protected]'],
)

See Kubernetes configuration_ example for more details.

.. _Kubernetes configuration: https://github.com/renskiy/fabricio/blob/master/examples/service/kubernetes/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].