-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Configure docker hub to have separate builds per tag. - Configure build hook to ignore automatic multi tag builds. - Remove post_push hook.
- Loading branch information
Showing
3 changed files
with
19 additions
and
70 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,50 +1,17 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function | ||
import json | ||
import logging | ||
import os | ||
from datetime import datetime | ||
from glob import iglob | ||
#!/bin/bash | ||
set -ex | ||
|
||
import docker | ||
if [ "$DOCKER_TAG" == latest ]; then | ||
dockerfile=11.0.Dockerfile | ||
else | ||
dockerfile="$DOCKER_TAG.Dockerfile" | ||
fi | ||
|
||
CLIENT = docker.client.from_env() | ||
DEFAULT_VERSION = "11.0" | ||
DOCKER_REPO = os.environ.get("DOCKER_REPO", "tecnativa/odoo-base") | ||
GIT_SHA1 = os.environ.get("GIT_SHA1", "") | ||
ODOO_VERSIONS = frozenset(os.environ.get( | ||
"ODOO_VERSIONS", "8.0 9.0 10.0 11.0").split()) | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
# Build version-specific images | ||
for dockerfile in iglob("*.Dockerfile"): | ||
version = dockerfile.replace(".Dockerfile", "") | ||
if version not in ODOO_VERSIONS: | ||
continue | ||
logging.info("Building image for version %s", version) | ||
# Low-level api for building images and streaming output | ||
response = CLIENT.api.build( | ||
path=".", | ||
dockerfile=dockerfile, | ||
tag=u"{}:{}".format(DOCKER_REPO, version), | ||
buildargs={ | ||
"BUILD_DATE": datetime.utcnow().isoformat(), | ||
"ODOO_VERSION": version, | ||
"VCS_REF": GIT_SHA1, | ||
} | ||
) | ||
status = None | ||
for line in response: | ||
line = json.loads(line) | ||
if line.get("status") not in {status, None}: | ||
status = line["status"] | ||
print(status) | ||
if line.get("stream"): | ||
print(line["stream"], end="") | ||
|
||
# Tag default version | ||
if DEFAULT_VERSION in ODOO_VERSIONS: | ||
logging.info("Tagging latest") | ||
image = CLIENT.images.get(u"{}:{}".format(DOCKER_REPO, DEFAULT_VERSION)) | ||
image.tag(DOCKER_REPO, "latest") | ||
# See http://label-schema.org/rc1/#build-time-labels | ||
time docker image build \ | ||
--build-arg VCS_REF="$GIT_SHA1" \ | ||
--build-arg BUILD_DATE="$(date --rfc-3339 ns)" \ | ||
--build-arg ODOO_VERSION="$DOCKER_TAG" \ | ||
--file "$dockerfile" \ | ||
--tag "$IMAGE_NAME" \ | ||
. |
This file was deleted.
Oops, something went wrong.