Commit 4c8d779f authored by Tulio Ruiz's avatar Tulio Ruiz
Browse files

Merge branch 'master-add_ci-truiz' into 'master'

[ADD] Add first version of the ci files.

See merge request !16
parents 26f8ab37 0df11429
Pipeline #149389 passed with stage
in 13 seconds
image: quay.io/vauxoo/dockerv:latest
before_script:
- echo ${DOCKER_PASSWORD} | docker login --username ${DOCKER_USER} --password-stdin
build_10:
stage: build
tags:
- build
variables:
PSQL_VERSION: '10'
script:
- python3 ./build.py --folder ./postgresql${PSQL_VERSION}-stable --docker-image vauxoo/docker-postgresql
build_10_ci:
stage: build
tags:
- build
variables:
PSQL_VERSION: '10'
PSQL_TYPE: 'ci'
script:
- python3 ./build.py --folder ./postgresql${PSQL_VERSION}-ci --docker-image vauxoo/docker-postgresql
# coding: utf-8
"""Check if any file has changed and then build this Dockerfile"""
import os
import sys
import subprocess
import argparse
def gen_image_name(base_image):
image_name = base_image + ':'
if os.environ.get('CI_COMMIT_REF_NAME', '') == 'master':
image_name += os.environ.get('PSQL_VERSION')
else:
return image_name + os.environ.get('CI_COMMIT_SHORT_SHA', 'dev')
if os.environ.get('PSQL_TYPE', '') != '':
image_name += '-' + os.environ.get('PSQL_TYPE')
return image_name
def _print_cmd(cmd):
print(" ".join(cmd))
class DockerOdooImages(object):
"""Class to build if has changed any file"""
def __init__(self, folder, docker_image):
"""Init method
folder : Folder to containt the Dockerfile
docker_image : Docker image to build
"""
self._folder = folder
self._relpath = os.path.relpath(self._folder)
self._docker_file_path = os.path.join(self._folder, 'Dockerfile')
self._docker_image = docker_image
self._path = os.getcwd()
def check_path(self):
"""Check if Docker file is present and the format"""
if (not os.path.isdir(self._folder) or
not os.path.isfile(self._docker_file_path)):
raise Exception('No Dockerfile', 'The folder %s not containt'
' Dockerfile' % self._folder, ' or not exist')
return True
def build(self):
"""Build changed image"""
cmd = ['git', 'remote', '-v']
_print_cmd(cmd)
print(subprocess.check_output(cmd))
cmd = ['git', 'branch', '-a']
_print_cmd(cmd)
print(subprocess.check_output(cmd))
can_be_build = self.check_path()
cmd = ['git', 'diff', 'HEAD^', 'HEAD', '--name-only',
'--relative=%s' % self._relpath]
_print_cmd(cmd)
diffs = subprocess.check_output(cmd)
if isinstance(diffs, str):
differences = [diff for diff in diffs.split('\n') if diff != '']
if not differences:
can_be_build = False
if can_be_build:
is_travis = os.environ.get("TRAVIS", "false")
cmd = ["docker", "build",
"--build-arg", "IS_TRAVIS=%s" % is_travis,
"-t", gen_image_name(self._docker_image), self._folder]
_print_cmd(cmd)
res_build = subprocess.call(cmd)
if res_build != 0:
return res_build
return self.push()
return 0
def push(self):
cmd = ["docker", "push", gen_image_name(self._docker_image)]
_print_cmd(cmd)
return subprocess.call(cmd)
if __name__ == "__main__":
argument_parser = argparse.ArgumentParser()
argument_parser.add_argument('-f', '--folder', help='Folder to containt'
'the Dockerfile', dest='folder',
required=True)
argument_parser.add_argument('-di', '--docker-image', help='Docker image'
'to build', dest='docker_image',
required=True)
arguments = argument_parser.parse_args()
docker_odoo_images = DockerOdooImages(arguments.folder,
arguments.docker_image)
sys.exit(docker_odoo_images.build())
......@@ -194,7 +194,7 @@ synchronous_commit = on # synchronization level;
# fsync
# fsync_writethrough
# open_sync
full_page_writes = on # recover from partial page writes
full_page_writes = off # recover from partial page writes
#wal_compression = off # enable compression of full-page writes
#wal_log_hints = off # also do full page writes of non-critical updates
# (change requires restart)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment