Skip to content

Commit

Permalink
Add support for custom Docker registries
Browse files Browse the repository at this point in the history
Allows the entire process to run without needing to push to Docker hub
(which allows the process to run without needing any real secrets)
  • Loading branch information
dra27 committed Oct 24, 2020
1 parent edcedf4 commit dda3a41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/conf.ml
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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
)

Expand Down
11 changes: 8 additions & 3 deletions src/tag.ml
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand All @@ -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

0 comments on commit dda3a41

Please sign in to comment.