Giter VIP home page Giter VIP logo

containerize's Introduction

Containerize (create-container-image)

Create, tag, and optionally publish a container for a GIT repository.

The container tag has the format:

  • <name>:<version>
  • image created from Dockerfile without extension has also tag "latest"

The container name is generated based on the following precedence:

  1. The GIT <organization>/<repository> of the 'origin' remote.
  2. The top level GIT directory
  3. The current directory

The container version is generated based on the following precedence:

  1. Drone tag
  2. Drone branch
  3. GIT branch
  4. The string unknown

Requires

  1. A .git directory in CWD or parent path
  2. One or more Dockerfiles in the project at the current working directory.
    1. File names match: Dockerfile and Dockerfile.*
    2. Dockerfiles SHOULD contain:
    ARG TAG
    ARG GIT_DESCRIBE
    ARG GIT_SHA
    ARG BUILD_DATE
    ARG SRC_REPO
    LABEL TAG=$TAG \
      GIT_DESCRIBE=$GIT_DESCRIBE \
      GIT_SHA=$GIT_SHA \
      BUILD_DATE=$BUILD_DATE \
      SRC_REPO=$SRC_REPO
    
  3. Docker installed on the localhost.
  4. [Optional] Tags will prefer a git repository but can work without it.

Registries

  1. Containerize will attempt to publish to the registries listed in a registry file, see Registry File Precedence
  2. Containerize will attempt to create repositories for some versions of Dockerhub (e.g. HPE's version), and AWS ECR
    1. The Namespace for HPE's Dockerhub is required to exist prior to running this utility

Registry File Precedence

  1. The -f <file> command line option
  2. A user registry file: <project_dir>/.dev/registry.json
    1. Be sure to add .dev/ to the project .gitignore file.
  3. A project registry file: <project_dir>/registry.json
  4. A program registry file in the docker image for containerize

Registry File Format

Follow this example showing an unsecure private registry, a secure private registry, a secure aws ec2 registry: registry.json`

Usage

Options

  • containerize.sh : Will build a container image
  • containerize.sh --publish: Will build and publish a container image
  • containerize.sh -q|--quiet : Will only print the tag <name>:<version>

CLI/bash

  1. Get the containerize image:
    1. Build it from source: ./containerize.sh
    2. Pull from registry: docker pull containerize:latest
  2. cd <project_dir>
  3. docker run --init --rm --workdir="$PWD" -v $HOME/.docker:/root/.docker -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD":"$PWD" -e HTTP_PROXY -e HTTPS_PROXY -e NO_PROXY -e http_proxy -e https_proxy -e no_proxy containerize

Drone

clone:
  tags: true
build:
  create-container:
    image: picasso/containerize:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    commands:
      - containerize.sh --publish

Issues and Troubleshooting

  1. Docker login not working:
    1. Identification: WARNING: Error loading config file: .docker/config.json: open .docker/config.json: permission denied
    2. Cause: If docker login has not previously been run then the $HOME/.docker/config.json file will not exist. Executing this tool will create it but may create it with root ownership.
    3. Solution: sudo rm -f $HOME/.docker/config.json and then run docker login again.

containerize's People

Contributors

michaelscheetz-hpe avatar dependabot-preview[bot] avatar kylebyerly-hp avatar cluarkhpe avatar jeffg-hpe avatar desbonnm avatar saradpatel 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.