Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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)
dra27 committed Nov 12, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent cbe6a68 commit eb6f68b
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 = None

(* 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
)

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

0 comments on commit eb6f68b

Please sign in to comment.