forked from Tecnativa/doodba
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build on Travis and push from there to Docker Hub
- Updated `.travis.yml` file. - Use pre-commit as a linter stage now. - Transform some build scripts to plumbum, to make them more maintainable.
- Loading branch information
Showing
7 changed files
with
89 additions
and
47 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 |
---|---|---|
@@ -1,28 +1,36 @@ | ||
#!/bin/bash | ||
set -ex | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
from plumbum import FG, local | ||
|
||
# Get Odoo version | ||
version="$DOCKER_TAG" | ||
if [ "$version" == latest ]; then | ||
version=12.0 | ||
fi | ||
REPO = local.env["DOCKER_REPO"] | ||
VERSION = local.env["DOCKER_TAG"] | ||
ROOT = local.path(__file__).up(2) | ||
COMMIT = local.env.get("GIT_SHA1", local.env.get("TRAVIS_COMMIT", "")) | ||
|
||
if [ -z "$IMAGE_NAME" ]; then | ||
IMAGE_NAME="$DOCKER_REPO:$DOCKER_TAG" | ||
fi | ||
# Shortcuts | ||
build = local["time"]["docker", "image", "build"] | ||
date = local["date"]["--rfc-3339", "ns"] | ||
tag = local["docker"]["image", "tag"] | ||
|
||
# See http://label-schema.org/rc1/#build-time-labels | ||
for target in base onbuild; do | ||
suffix='' | ||
if [ "$target" == onbuild ]; then | ||
suffix="-$target" | ||
fi | ||
time docker image build \ | ||
--build-arg VCS_REF="$GIT_SHA1" \ | ||
--build-arg BUILD_DATE="$(date --rfc-3339 ns)" \ | ||
--build-arg ODOO_VERSION="$version" \ | ||
--file "$version.Dockerfile" \ | ||
--tag "$IMAGE_NAME$suffix" \ | ||
--target $target \ | ||
. | ||
done | ||
# Build base and onbuild images | ||
for target, suffix in (("base", ""), ("onbuild", "-onbuild")): | ||
image_name = "%s:%s%s" % (REPO, VERSION, suffix) | ||
build[ | ||
"--build-arg", | ||
"VCS_REF=%s" % COMMIT, | ||
"--build-arg", | ||
"BUILD_DATE=%s" % date().strip(), | ||
"--build-arg", | ||
"ODOO_VERSION=%s" % VERSION, | ||
"--tag", | ||
image_name, | ||
"--target", | ||
target, | ||
"--file", | ||
"%s.Dockerfile" % VERSION, | ||
ROOT, | ||
] & FG | ||
|
||
# Tag "latest" image if applicable | ||
if VERSION == local.env.get("LATEST_RELEASE"): | ||
tag[image_name, "%s:latest%s" % (REPO, suffix)] & FG |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
#!/bin/bash | ||
set -ex | ||
pip install -r "$(dirname $0)/../requirements-ci.txt" |
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
from plumbum import FG, local | ||
from plumbum.cmd import docker # noqa pylint: disable=import-error | ||
|
||
REPO = local.env["DOCKER_REPO"] | ||
VERSION = local.env["DOCKER_TAG"] | ||
|
||
# Log all locally available images; will help to pin images | ||
docker["image", "ls", "--digests", REPO] & FG | ||
|
||
# Login in Docker Hub | ||
docker( | ||
"login", | ||
"--username", | ||
local.env["DOCKER_HUB_USERNAME"], | ||
"--password", | ||
local.env["DOCKER_HUB_TOKEN"], | ||
) | ||
|
||
# Push built images | ||
for suffix in ("", "-onbuild"): | ||
docker["image", "push", "%s:%s%s" % (REPO, VERSION, suffix)] & FG | ||
if VERSION == local.env.get("LATEST_RELEASE"): | ||
docker["image", "push", "%s:latest%s" % (REPO, suffix)] & FG |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
docker-compose | ||
plumbum | ||
pre-commit |