Giter Site home page Giter Site logo

carrier's Introduction

Carrier

CLI Tool for managing container based deployment system.

Inspired by https://blog.p1ass.com/posts/docker-context/

Usage

Precondition

  • Docker is installed in your local machine
  • Docker is installed in your remote machine
  • Remote docker context is created
    • You can create it by docker context create --default-stack-orchestrator=swarm --docker "host=ssh://${SSH_USERNAME}@${SSH_IP}:${SSH_PORT}" your-remote-docker-context
  • Docker registry is ready
  • Reverse proxy is running in your remote machine

Setup project

Initialize your project.

$ carrier init your-project-name --context your-remote-docker-context --registry your-docker-registry

carrier.json and docker-compose.yml will be created.

$ cat carrier.json                                                                                   
{
    "images": {
        "web": "."
    },
    "context": "your-remote-docker-context",
    "tag": "v1.0,0",
    "projectName": "your-project-name",
    "registry": "your-docker-registry",
    "environments": {},
    "port": "3000" # Your web container listens this port
}
$ cat docker-compose.yml                                                                             
version: '3'
services:
  web:
    image: your-docker-registry/your-project-name_web:${TAG}
    command: TODO
    ports:
      - "127.0.0.1:${PORT:?err}:3000"
    restart: always
    links:
      - postgres
    env_file: .env
    depends_on:
      - postgres
  postgres:
    image: postgres:12-alpine
    restart: always
    env_file: .env
    volumes:
      - your-project-name_pg_data:/var/lib/postgresql/data 

volumes:
  your-project-name_pg_data:
    external: true

Create Dockerfile for your-docker-registry/your-project-name_web image.

$ vim Dockerfile
$ cat Dockerfile # example
FROM golang:alpine

WORKDIR /go/src/app
COPY . .

RUN go get -d -v ./...
RUN go install -v ./...

Fill TODO in docker-commpose.yml.

$ vim docker-compose.yml
# diff:
-     command: TODO
+     command: /go/bin/some-web-server --port=3000

Build images and push them to registry.

# This builds and pushes `your-docker-registry/your-project-name_web:v0.1`
$ carrier release v0.1

Then, deploy service into your-remote-docker-context.

# Create the volume used in docker-compose.yml
$ docker --context your-remote-docker-context volume create --name=your-project-name_pg_data

# Equivalent to `docker-commpose --context your-remote-docker-context stop && docker-compose --context your-remote-docker-context up -d`
$ carrier deploy

# You can watch logs
$ carrier docker-compose -- logs -f

Update applications

If you want to update applications, you do release and deploy.

# Edit application
$ vim main.go

# Build docker image and push it.
$ carrier release v0.2

# Deploy new image
$ carrier deploy

carrier's People

Contributors

genya0407 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.