Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added separate docker fabric module to generalize docker build, publi…
…sh and run development task(s)
- Loading branch information
Showing
2 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Module: docker | ||
# Date: 24th May 2014 | ||
# Author: James Mills, j dot mills at griffith dot edu dot au | ||
|
||
|
||
"""Docker Tasks""" | ||
|
||
|
||
from fabric.api import local, task | ||
|
||
|
||
from .utils import msg, requires, tobool | ||
|
||
|
||
TAG = "prologic/circuits" | ||
|
||
|
||
@task(default=True) | ||
@requires("docker") | ||
def build(**options): | ||
"""Build Docker Image | ||
Options can be provided to customize the build. | ||
The following options are supported: | ||
- rebuild -> Whether to rebuild without a cache. | ||
- version -> Specific version to tag the image with (Default: latest) | ||
""" | ||
|
||
rebuild = tobool(options.get("rebuild", False)) | ||
version = options.get("version", "latest") | ||
|
||
tag = "{0:s}:{1:s}".format(TAG, version) | ||
args = ["docker", "build", "-t", tag, "."] | ||
|
||
if rebuild: | ||
args.insert(-1, "--no-cache") | ||
|
||
with msg("Building Image"): | ||
local(" ".join(args)) | ||
|
||
|
||
@task() | ||
@requires("docker") | ||
def publish(): | ||
"""Publish Docker Image""" | ||
|
||
args = ["docker", "push", TAG] | ||
|
||
with msg("Pushing Image"): | ||
local(" ".join(args)) | ||
|
||
|
||
@task() | ||
@requires("docker") | ||
def run(): | ||
"""Run Docker Container""" | ||
|
||
args = ["docker", "run", "-i", "-t", "--rm", TAG] | ||
|
||
local(" ".join(args)) |