Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Ubuntu RISCV64 Docker base images #1

Closed
wants to merge 8 commits into from

Conversation

mtelvers
Copy link
Owner

@mtelvers mtelvers commented May 1, 2024

No description provided.

@mtelvers mtelvers force-pushed the build-riscv64-ubuntu-base branch from 79314b2 to af2f43e Compare May 24, 2024 22:19
Copy link

@shonfeder shonfeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just going through some WIP to see if anything was blocked, and thought a review here might help this one along :)

Comment on lines +26 to +27
let base ?arch distro =
let repo = if arch = None then Conf.public_repo else Conf.staging_repo in

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default argument can be shortened to

Suggested change
let base ?arch distro =
let repo = if arch = None then Conf.public_repo else Conf.staging_repo in
let base ?(arch=Conf.public_repo) distro =

Comment on lines +29 to +30
if distro = `Debian `Stable then "debian"
else Dockerfile_opam.Distro.tag_of_distro distro

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we just use Dockerfile_opam.Distro.tag_of_distro without the conditional? Or, if we need just the distro name, could we use Dockerfile_opam.Distro.base_distro_tag?

@@ -377,6 +408,7 @@ module Make (OCurrent : S.OCURRENT) = struct
let multiarch, pipelines = List.fold_left_map distro_pipeline Switch_map.empty distro_versions in
let pushes =
Switch_map.fold (fun switch images pushes ->
let distro_label = String.split_on_char '-' distro_label |> String.concat "-all-" in

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions here:

  1. Why add this new -all- infix element?
  2. It looks looks like windows labels can have multiple -s, which would lead to wrong logic here, iiuc. I'm basing this on looking at https://github.com/shonfeder/ocaml-dockerfile/blob/b86eda9800d25f62a632b90f13ef44d9775a76e8/src-opam/distro.ml#L712-L719

let build_distro_base ocluster arch distro =
let dist, release = Distro.base_distro_tag distro in
Current.component "%s %s" dist release |>
let> distro = Current.return distro in

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iiuc, this is a no-op, so can be removed

Suggested change
let> distro = Current.return distro in

Comment on lines +142 to +165
let build_distro_base ocluster arch distro =
let dist, release = Distro.base_distro_tag distro in
Current.component "%s %s" dist release |>
let> distro = Current.return distro in
let dockerfile =
let open Dockerfile in
`Contents (
string_of_t (
from "ubuntu:jammy-20220801 AS base" @@
workdir "/base" @@
run "apt update && apt install -y debootstrap" @@
run "ln -s gutsy /usr/share/debootstrap/scripts/noble" @@
run "debootstrap %s /base" release @@
from "scratch" @@
copy ~from:"base" ~src:["/base"] ~dst:"/" () @@
cmd "/bin/bash")) in
let options = { Cluster_api.Docker.Spec.defaults with
squash = squash distro;
buildkit = buildkit distro } in
let cache_hint = "ubuntu-" ^ release in
OCluster.Raw.build_and_push ocluster dockerfile
~src:[]
~cache_hint
~push_target:(Cluster_api.Docker.Image_id.of_string Tag.(base ~arch distro) |> or_die)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ubuntu is hard coded throughout this function and we only call it for a single distro and architecture, so I'm not sure it makes sense for it to try to be general in other places, i.e., by using the newly defined Tag.base function and appearing as abstraction over arch and distro. Maybe we only really need the distro version at this point?

@mtelvers mtelvers closed this Jun 26, 2024
@mtelvers mtelvers deleted the build-riscv64-ubuntu-base branch June 26, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants