|
1 |
| -#!/usr/bin/envpython |
| 1 | +#!/usr/bin/envpython3 |
2 | 2 |
|
| 3 | +importos |
3 | 4 | importsubprocess
|
4 | 5 | importgetpass
|
| 6 | +importrequests |
| 7 | +importtempfile |
| 8 | + |
| 9 | +fromurllib.parseimporturljoin |
| 10 | +fromurllib.requestimporturlopen |
5 | 11 |
|
6 | 12 | DOCKER_ID='pathman'
|
7 |
| -pg_versions= ['9.5','9.6','10'] |
| 13 | +ALPINE_BASE_URL='https://raw.githubusercontent.com/docker-library/postgres/master/9.6/alpine/' |
| 14 | +ALPINE_ENTRYPOINT='docker-entrypoint.sh' |
| 15 | +ALPINE_PATCH=b''' |
| 16 | +diff --git a/Dockerfile b/Dockerfile |
| 17 | +index 9878023..ba215bc 100644 |
| 18 | +--- a/Dockerfile |
| 19 | ++++ b/Dockerfile |
| 20 | +@@ -80,6 +80,7 @@ RUN set -ex\\ |
| 21 | + # configure options taken from: |
| 22 | + # https://anonscm.debian.org/cgit/pkg-postgresql/postgresql.git/tree/debian/rules?h=9.5 |
| 23 | + && ./configure\\ |
| 24 | ++--enable-cassert\\ |
| 25 | + --build="$gnuArch"\\ |
| 26 | + # "/usr/src/postgresql/src/backend/access/common/tupconvert.c:105: undefined reference to `libintl_gettext'" |
| 27 | + #--enable-nls\\ |
| 28 | +''' |
| 29 | +CUSTOM_IMAGE_NAME="%s/postgres_stable"%DOCKER_ID |
| 30 | + |
| 31 | +defmake_alpine_image(image_name): |
| 32 | +dockerfile=urlopen(urljoin(ALPINE_BASE_URL,'Dockerfile')).read() |
| 33 | +entrypoint_sh=urlopen(urljoin(ALPINE_BASE_URL,ALPINE_ENTRYPOINT)).read() |
| 34 | + |
| 35 | +withtempfile.TemporaryDirectory()astmpdir: |
| 36 | +print("Creating build in %s"%tmpdir) |
| 37 | +withopen(os.path.join(tmpdir,'Dockerfile'),'w')asf: |
| 38 | +f.write(dockerfile.decode()) |
| 39 | + |
| 40 | +withopen(os.path.join(tmpdir,ALPINE_ENTRYPOINT),'w')asf: |
| 41 | +f.write(entrypoint_sh.decode()) |
| 42 | + |
| 43 | +withopen(os.path.join(tmpdir,'cassert.patch'),'w')asf: |
| 44 | +f.write(ALPINE_PATCH.decode()) |
| 45 | + |
| 46 | +subprocess.check_output(["git","apply","cassert.patch"],cwd=tmpdir) |
| 47 | +print("patch applied") |
| 48 | +subprocess.check_output(["docker","build",".",'-t',image_name],cwd=tmpdir) |
| 49 | +print("build ok: ",image_name) |
| 50 | +subprocess.check_output(['docker','push',image_name], |
| 51 | +stderr=subprocess.STDOUT) |
| 52 | +print("upload ok:",image_name) |
| 53 | + |
| 54 | +make_alpine_image(CUSTOM_IMAGE_NAME) |
| 55 | + |
| 56 | +pg_containers= [ |
| 57 | +('pg95','postgres:9.5-alpine'), |
| 58 | +('pg96','postgres:9.6-alpine'), |
| 59 | +('pg10','postgres:10-alpine'), |
| 60 | +('pg96_ca',CUSTOM_IMAGE_NAME), |
| 61 | +] |
8 | 62 |
|
9 | 63 | image_types= {
|
10 | 64 | 'clang_check_code': {
|
|
30 | 84 | travis_conf= []
|
31 | 85 | print("")
|
32 | 86 |
|
33 |
| -forpg_versioninpg_versions: |
34 |
| -pgname='pg%s'%pg_version.replace('.','') |
35 |
| -forkey,variablesinimage_types.items(): |
36 |
| -image_name='%s/%s_%s'% (DOCKER_ID,pgname,key) |
37 |
| -withopen('Dockerfile','w')asout: |
38 |
| -withopen('Dockerfile.tmpl','r')asf: |
39 |
| -forlineinf: |
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 |
| -travis_conf.append(travis_conf_line%image_name) |
| 87 | +if__name__=='__main__': |
| 88 | +forpgname,containerinpg_containers: |
| 89 | +forkey,variablesinimage_types.items(): |
| 90 | +image_name='%s/%s_%s'% (DOCKER_ID,pgname,key) |
| 91 | +withopen('Dockerfile','w')asout: |
| 92 | +withopen('Dockerfile.tmpl','r')asf: |
| 93 | +forlineinf: |
| 94 | +line=line.replace('${PG_IMAGE}',container) |
| 95 | +forkey,valueinvariables.items(): |
| 96 | +varname='${%s}'%key |
| 97 | +line=line.replace(varname,value) |
| 98 | + |
| 99 | +out.write(line) |
| 100 | + |
| 101 | +args= [ |
| 102 | +'docker', |
| 103 | +'build', |
| 104 | +'-t',image_name, |
| 105 | +'.' |
| 106 | +] |
| 107 | +subprocess.check_output(args,stderr=subprocess.STDOUT) |
| 108 | +print("build ok:",image_name) |
| 109 | +subprocess.check_output(['docker','push',image_name], |
| 110 | +stderr=subprocess.STDOUT) |
| 111 | +print("upload ok:",image_name) |
| 112 | +travis_conf.append(travis_conf_line%image_name) |
59 | 113 |
|
60 | 114 | print("\ntravis configuration")
|
61 | 115 | print('\n'.join(travis_conf))
|