Project

contained

0.0
The project is in a healthy, maintained state
Makes releasing docker based containers via SSH using swarm a breeze
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

 Project Readme

Contained

LICENSE RubyGems GitHub Yard CircleCI

Deploy using Docker Swarm via SSH across multiple and environments.

Installation

gem install contained

Commands

Init

The contained init command copies / pastes the following into your project:

contained init

config/deploy.yml

stack: example

environments:
  production:
    hosts:
      - 1.2.3.4
      - 5.6.7.8
  test:
    hosts:
      - 4.3.2.1
      - 8.7.6.5

config/deploy/compose.yml

config:
  services:
    caddy:
      image: demo/caddy
      ports:
        - "80:80"
      volumes:
        - caddy_data:/data
        - caddy_config:/config
      healthcheck:
        test: ["CMD", "curl", "-f", "http://localhost:80/up"]
        interval: 30s
        timeout: 10s
        retries: 3
    backend:
      build: demo/backend
      healthcheck:
        test: ["CMD", "curl", "-f", "http://localhost:3000/up"]
        interval: 30s
        timeout: 10s
        retries: 3
    frontend:
      build: demo/frontend
      healthcheck:
        test: ["CMD", "curl", "-f", "http://localhost:3000/up"]
        interval: 30s
        timeout: 10s
        retries: 3
  volumes:
    caddy_data:
    caddy_config:

Setup

The contained setup command connects to all the hosts within an environment via SSH and configures docker swarm using a stack defined in the config/deploy/compose.yml file.

contained setup --environment production

Examples

w/ Caddy

Dockerfile

# syntax = docker/dockerfile:1

ARG CADDY_VERSION=2.9.1

FROM docker.io/library/caddy:${CADDY_VERSION}-alpine

COPY Caddyfile /etc/caddy/Caddyfile

Caddyfile

demo.com {
  encode

  handle /up {
    respond "OK" 200 {
      close
    }
  }

  handle /backend/up {
    uri replace /backend/ /
    reverse_proxy backend:3000
  }

  handle /frontend/up {
    uri replace /frontend/ /
    reverse_proxy frontend:3000
  }

  handle /api/* {
    reverse_proxy backend:3000
  }

  handle /* {
    reverse_proxy frontend:3000
  }
}