|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +importsubprocess |
| 4 | + |
| 5 | +DOCKER_ID='pathman' |
| 6 | +pg_versions= ['9.5','9.6','10'] |
| 7 | + |
| 8 | +image_types= { |
| 9 | +'clang_check_code': { |
| 10 | +'CHECK_CODE':'clang', |
| 11 | +}, |
| 12 | +'cppcheck': { |
| 13 | +'CHECK_CODE':'cppcheck', |
| 14 | +}, |
| 15 | +'pathman_tests': { |
| 16 | +'CHECK_CODE':'false', |
| 17 | +} |
| 18 | +} |
| 19 | + |
| 20 | +stopline='###STOP' |
| 21 | + |
| 22 | +password=input("Enter password for `docker login`: ") |
| 23 | +subprocess.check_output([ |
| 24 | +'docker', |
| 25 | +'login', |
| 26 | +'-u',DOCKER_ID, |
| 27 | +'-p',password]) |
| 28 | + |
| 29 | +forpg_versioninpg_versions: |
| 30 | +pgname='pg%s'%pg_version.replace('.','') |
| 31 | +forkey,variablesinimage_types.items(): |
| 32 | +image_name='%s/%s_%s'% (DOCKER_ID,pgname,key) |
| 33 | +withopen('Dockerfile','w')asout: |
| 34 | +withopen('Dockerfile.tmpl','r')asf: |
| 35 | +forlineinf: |
| 36 | +ifline.startswith(stopline): |
| 37 | +break |
| 38 | + |
| 39 | +line=line |
| 40 | +line=line.replace('${PG_VERSION}',pg_version) |
| 41 | +forkey,valueinvariables.items(): |
| 42 | +varname='${%s}'%key |
| 43 | +line=line.replace(varname,value) |
| 44 | + |
| 45 | +out.write(line) |
| 46 | + |
| 47 | +args= [ |
| 48 | +'docker', |
| 49 | +'build', |
| 50 | +'-t',image_name, |
| 51 | +'.' |
| 52 | +] |
| 53 | +subprocess.check_output(args,stderr=subprocess.STDOUT) |
| 54 | +print("build ok:",image_name) |
| 55 | +subprocess.check_output(['docker','push',image_name], |
| 56 | +stderr=subprocess.STDOUT) |
| 57 | +print("upload ok:",image_name) |
| 58 | +exit() |