2323 "buster" ,
2424]
2525
26- default_variant = "buster"
26+ default_debian_variant = "buster"
2727
28- def rustup_hash (arch ):
29- url = f"https://static.rust-lang.org/rustup/archive/{ rustup_version } /{ arch .rust } /rustup-init.sha256"
28+ alpine_versions = [
29+ "3.10" ,
30+ ]
31+
32+ default_alpine_version = "3.10"
33+
34+ def rustup_hash (arch , version = None ):
35+ if version is None :
36+ version = rustup_version
37+ url = f"https://static.rust-lang.org/rustup/archive/{ version } /{ arch } /rustup-init.sha256"
3038 with request .urlopen (url ) as f :
3139 return f .read ().decode ('utf-8' ).split ()[0 ]
3240
@@ -45,7 +53,7 @@ def update_debian():
4553 arch_case = 'dpkgArch="$(dpkg --print-architecture)"; \\ \n '
4654 arch_case += ' case "${dpkgArch##*-}" in \\ \n '
4755 for arch in debian_arches :
48- hash = rustup_hash (arch )
56+ hash = rustup_hash (arch . rust )
4957 arch_case += f" { arch .dpkg } ) rustArch='{ arch .rust } '; rustupSha256='{ hash } ' ;; \\ \n "
5058 arch_case += ' *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \\ \n '
5159 arch_case += ' esac'
@@ -68,6 +76,18 @@ def update_debian():
6876 .replace ("%%ARCH-CASE%%" , arch_case )
6977 write_file (f"{ rust_version } /{ variant } /slim/Dockerfile" , rendered )
7078
79+ def update_alpine ():
80+ template = read_file ("Dockerfile-alpine.template" )
81+ alpine_rustup_version = "1.19.0"
82+
83+ for version in alpine_versions :
84+ rendered = template \
85+ .replace ("%%RUST-VERSION%%" , rust_version ) \
86+ .replace ("%%RUSTUP-VERSION%%" , alpine_rustup_version ) \
87+ .replace ("%%TAG%%" , version ) \
88+ .replace ("%%RUSTUP-SHA256%%" , rustup_hash ("x86_64-unknown-linux-musl" , alpine_rustup_version ))
89+ write_file (f"{ rust_version } /alpine{ version } /Dockerfile" , rendered )
90+
7191def update_travis ():
7292 file = ".travis.yml"
7393 config = read_file (file )
@@ -77,6 +97,9 @@ def update_travis():
7797 versions += f" - VERSION={ rust_version } VARIANT={ variant } \n "
7898 versions += f" - VERSION={ rust_version } VARIANT={ variant } /slim\n "
7999
100+ for version in alpine_versions :
101+ versions += f" - VERSION={ rust_version } VARIANT=alpine{ version } \n "
102+
80103 marker = "#VERSIONS\n "
81104 split = config .split (marker )
82105 rendered = split [0 ] + marker + versions + marker + split [2 ]
@@ -120,7 +143,7 @@ def generate_stackbrew_library():
120143 for version_tag in version_tags ():
121144 tags .append (f"{ version_tag } -{ variant } " )
122145 tags .append (variant )
123- if variant == default_variant :
146+ if variant == default_debian_variant :
124147 for version_tag in version_tags ():
125148 tags .append (version_tag )
126149 tags .append ("latest" )
@@ -134,7 +157,7 @@ def generate_stackbrew_library():
134157 for version_tag in version_tags ():
135158 tags .append (f"{ version_tag } -slim-{ variant } " )
136159 tags .append (f"slim-{ variant } " )
137- if variant == default_variant :
160+ if variant == default_debian_variant :
138161 for version_tag in version_tags ():
139162 tags .append (f"{ version_tag } -slim" )
140163 tags .append ("slim" )
@@ -144,6 +167,21 @@ def generate_stackbrew_library():
144167 map (lambda a : a .bashbrew , debian_arches ),
145168 os .path .join (rust_version , variant , "slim" ))
146169
170+ for version in alpine_versions :
171+ tags = []
172+ for version_tag in version_tags ():
173+ tags .append (f"{ version_tag } -alpine{ version } " )
174+ tags .append (f"alpine{ version } " )
175+ if version == default_alpine_version :
176+ for version_tag in version_tags ():
177+ tags .append (f"{ version_tag } -alpine" )
178+ tags .append ("alpine" )
179+
180+ library += single_library (
181+ tags ,
182+ ["amd64" ],
183+ os .path .join (rust_version , f"alpine{ version } " ))
184+
147185 print (library )
148186
149187def usage ():
@@ -157,6 +195,7 @@ def usage():
157195 task = sys .argv [1 ]
158196 if task == "update" :
159197 update_debian ()
198+ update_alpine ()
160199 update_travis ()
161200 elif task == "generate-stackbrew-library" :
162201 generate_stackbrew_library ()
0 commit comments