From 611f1a135c93132c3dfca38fed497401f077854f Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sat, 24 Oct 2020 15:49:20 +0100 Subject: [PATCH] Add support for custom Docker registries Allows the entire process to run without needing to push to Docker hub (which allows the process to run without needing any real secrets) --- src/conf.ml | 7 ++++++- src/tag.ml | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/conf.ml b/src/conf.ml index 4cb6f68f..68c2bdfd 100644 --- a/src/conf.ml +++ b/src/conf.ml @@ -1,3 +1,7 @@ +(* Use None for the main Docker Registry. + Do NOT set this to Some "docker.io" *) +let registry = Some "localhost:5000" + (* For staging arch-specific builds before creating the manifest. *) let staging_repo = "ocurrent/opam-staging" @@ -21,7 +25,8 @@ let auth = close_in ch; Some ("ocurrent", password) ) else ( - Fmt.pr "Password file %S not found; images will not be pushed to hub@." password_path; + if registry = None then + Fmt.pr "Password file %S not found; images will not be pushed to hub@." password_path; None ) diff --git a/src/tag.ml b/src/tag.ml index 51c94512..3cc8665d 100644 --- a/src/tag.ml +++ b/src/tag.ml @@ -1,3 +1,8 @@ +let public_repo, staging_repo = + match Conf.registry with + | None -> Conf.public_repo, Conf.staging_repo + | Some registry -> registry ^ "/" ^ Conf.public_repo, registry ^ "/" ^ Conf.staging_repo + let pp_arch f = function | None -> () | Some arch -> Fmt.pf f "-%s" (Ocaml_version.string_of_arch arch) @@ -10,7 +15,7 @@ let tag_of_compiler switch = ) let v ?arch ?switch distro = - let repo = if arch = None then Conf.public_repo else Conf.staging_repo in + let repo = if arch = None then public_repo else staging_repo in let distro = Dockerfile_distro.tag_of_distro distro in let switch = match switch with @@ -24,7 +29,7 @@ let v_alias alias = if alias = `Debian `Stable then "debian" else Dockerfile_distro.tag_of_distro alias in - Fmt.strf "%s:%s" Conf.public_repo alias + Fmt.strf "%s:%s" public_repo alias let latest = - Fmt.strf "%s:latest" Conf.public_repo + Fmt.strf "%s:latest" public_repo