Skip to content

Commit

Permalink
Fix Hub build
Browse files Browse the repository at this point in the history
- 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
yajo committed Oct 5, 2017
1 parent fe76c08 commit e88faa0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 70 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ env:
- DOCKER_TAG=latest
- IMAGE_NAME=$DOCKER_REPO:$DOCKER_TAG
matrix:
- ODOO_VERSIONS=8.0
- ODOO_VERSIONS=9.0
- ODOO_VERSIONS=10.0
- ODOO_VERSIONS=11.0
- DOCKER_TAG=8.0 ODOO_VERSIONS=8.0
- DOCKER_TAG=9.0 ODOO_VERSIONS=9.0
- DOCKER_TAG=10.0 ODOO_VERSIONS=10.0
- DOCKER_TAG=11.0 ODOO_VERSIONS=11.0

before_install:
- sudo apt-get update
Expand Down
63 changes: 15 additions & 48 deletions hooks/build
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" \
.
18 changes: 0 additions & 18 deletions hooks/post_push

This file was deleted.

0 comments on commit e88faa0

Please sign in to comment.