Skip to content

Commit

Permalink
Build Ubuntu RISCV64 Docker base images
Browse files Browse the repository at this point in the history
  • Loading branch information
mtelvers committed May 24, 2024
1 parent bb9de25 commit af2f43e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 10 deletions.
60 changes: 52 additions & 8 deletions builds.expected
Original file line number Diff line number Diff line change
Expand Up @@ -14887,11 +14887,22 @@ ubuntu-20.04/amd64
RUN rm -rf .opam/repo/default/.git
COPY --link [ "Dockerfile", "/Dockerfile.opam" ]

ubuntu focal
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 focal /base

FROM scratch
COPY --from=base [ "/base", "/" ]
CMD /bin/bash

ubuntu-20.04/riscv64
# syntax=docker/dockerfile:1

# Autogenerated by OCaml-Dockerfile scripts
FROM riscv64/ubuntu:focal
FROM ocurrent/opam-staging:ubuntu-20.04-riscv64
LABEL distro_style="apt"
RUN apt-get -y update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
Expand All @@ -14907,7 +14918,7 @@ ubuntu-20.04/riscv64
RUN cd /tmp/opam-sources && cp -P -R -p . ../opam-build-2.1 && cd ../opam-build-2.1 && git checkout 2.1 && ln -s ../opam/src_ext/archives src_ext/archives && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" ./configure --enable-cold-check --with-0install-solver && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" make lib-ext all && mkdir -p /usr/local/bin && cp /tmp/opam-build-2.1/opam /usr/local/bin/opam-2.1 && chmod a+x /usr/local/bin/opam-2.1 && rm -rf /tmp/opam-build-2.1
RUN cd /tmp/opam-sources && cp -P -R -p . ../opam-build-master && cd ../opam-build-master && git checkout master && ln -s ../opam/src_ext/archives src_ext/archives && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" ./configure --enable-cold-check --with-0install-solver --with-vendored-deps && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" make lib-ext all && mkdir -p /usr/local/bin && cp /tmp/opam-build-master/opam /usr/local/bin/opam-master && chmod a+x /usr/local/bin/opam-master && rm -rf /tmp/opam-build-master

FROM riscv64/ubuntu:focal
FROM ocurrent/opam-staging:ubuntu-20.04-riscv64
RUN ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime
COPY --from=0 [ "/usr/local/bin/bwrap", "/usr/bin/bwrap" ]
COPY <<-EOF /etc/apt/apt.conf.d/mirror-retry
Expand Down Expand Up @@ -16157,11 +16168,22 @@ ubuntu-22.04/amd64
RUN rm -rf .opam/repo/default/.git
COPY --link [ "Dockerfile", "/Dockerfile.opam" ]

ubuntu jammy
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 jammy /base

FROM scratch
COPY --from=base [ "/base", "/" ]
CMD /bin/bash

ubuntu-22.04/riscv64
# syntax=docker/dockerfile:1

# Autogenerated by OCaml-Dockerfile scripts
FROM riscv64/ubuntu:jammy
FROM ocurrent/opam-staging:ubuntu-22.04-riscv64
LABEL distro_style="apt"
RUN apt-get -y update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
Expand All @@ -16173,7 +16195,7 @@ ubuntu-22.04/riscv64
RUN cd /tmp/opam-sources && cp -P -R -p . ../opam-build-2.1 && cd ../opam-build-2.1 && git checkout 2.1 && ln -s ../opam/src_ext/archives src_ext/archives && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" ./configure --enable-cold-check --with-0install-solver && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" make lib-ext all && mkdir -p /usr/local/bin && cp /tmp/opam-build-2.1/opam /usr/local/bin/opam-2.1 && chmod a+x /usr/local/bin/opam-2.1 && rm -rf /tmp/opam-build-2.1
RUN cd /tmp/opam-sources && cp -P -R -p . ../opam-build-master && cd ../opam-build-master && git checkout master && ln -s ../opam/src_ext/archives src_ext/archives && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" ./configure --enable-cold-check --with-0install-solver --with-vendored-deps && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" make lib-ext all && mkdir -p /usr/local/bin && cp /tmp/opam-build-master/opam /usr/local/bin/opam-master && chmod a+x /usr/local/bin/opam-master && rm -rf /tmp/opam-build-master

FROM riscv64/ubuntu:jammy
FROM ocurrent/opam-staging:ubuntu-22.04-riscv64
RUN ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime
COPY <<-EOF /etc/apt/apt.conf.d/mirror-retry
Acquire::Retries "5";
Expand Down Expand Up @@ -17422,11 +17444,22 @@ ubuntu-23.04/amd64
RUN rm -rf .opam/repo/default/.git
COPY --link [ "Dockerfile", "/Dockerfile.opam" ]

ubuntu lunar
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 lunar /base

FROM scratch
COPY --from=base [ "/base", "/" ]
CMD /bin/bash

ubuntu-23.04/riscv64
# syntax=docker/dockerfile:1

# Autogenerated by OCaml-Dockerfile scripts
FROM riscv64/ubuntu:lunar
FROM ocurrent/opam-staging:ubuntu-23.04-riscv64
LABEL distro_style="apt"
RUN apt-get -y update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
Expand All @@ -17438,7 +17471,7 @@ ubuntu-23.04/riscv64
RUN cd /tmp/opam-sources && cp -P -R -p . ../opam-build-2.1 && cd ../opam-build-2.1 && git checkout 2.1 && ln -s ../opam/src_ext/archives src_ext/archives && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" ./configure --enable-cold-check --with-0install-solver && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" make lib-ext all && mkdir -p /usr/local/bin && cp /tmp/opam-build-2.1/opam /usr/local/bin/opam-2.1 && chmod a+x /usr/local/bin/opam-2.1 && rm -rf /tmp/opam-build-2.1
RUN cd /tmp/opam-sources && cp -P -R -p . ../opam-build-master && cd ../opam-build-master && git checkout master && ln -s ../opam/src_ext/archives src_ext/archives && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" ./configure --enable-cold-check --with-0install-solver --with-vendored-deps && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" make lib-ext all && mkdir -p /usr/local/bin && cp /tmp/opam-build-master/opam /usr/local/bin/opam-master && chmod a+x /usr/local/bin/opam-master && rm -rf /tmp/opam-build-master

FROM riscv64/ubuntu:lunar
FROM ocurrent/opam-staging:ubuntu-23.04-riscv64
RUN ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime
COPY <<-EOF /etc/apt/apt.conf.d/mirror-retry
Acquire::Retries "5";
Expand Down Expand Up @@ -19763,11 +19796,22 @@ ubuntu-24.04/amd64
RUN rm -rf .opam/repo/default/.git
COPY --link [ "Dockerfile", "/Dockerfile.opam" ]

ubuntu noble
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 noble /base

FROM scratch
COPY --from=base [ "/base", "/" ]
CMD /bin/bash

ubuntu-24.04/riscv64
# syntax=docker/dockerfile:1

# Autogenerated by OCaml-Dockerfile scripts
FROM riscv64/ubuntu:noble
FROM ocurrent/opam-staging:ubuntu-24.04-riscv64
LABEL distro_style="apt"
RUN apt-get -y update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
Expand All @@ -19779,7 +19823,7 @@ ubuntu-24.04/riscv64
RUN cd /tmp/opam-sources && cp -P -R -p . ../opam-build-2.1 && cd ../opam-build-2.1 && git checkout 2.1 && ln -s ../opam/src_ext/archives src_ext/archives && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" ./configure --enable-cold-check --with-0install-solver && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" make lib-ext all && mkdir -p /usr/local/bin && cp /tmp/opam-build-2.1/opam /usr/local/bin/opam-2.1 && chmod a+x /usr/local/bin/opam-2.1 && rm -rf /tmp/opam-build-2.1
RUN cd /tmp/opam-sources && cp -P -R -p . ../opam-build-master && cd ../opam-build-master && git checkout master && ln -s ../opam/src_ext/archives src_ext/archives && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" ./configure --enable-cold-check --with-0install-solver --with-vendored-deps && env PATH="/tmp/opam/bootstrap/ocaml/bin:$PATH" make lib-ext all && mkdir -p /usr/local/bin && cp /tmp/opam-build-master/opam /usr/local/bin/opam-master && chmod a+x /usr/local/bin/opam-master && rm -rf /tmp/opam-build-master

FROM riscv64/ubuntu:noble
FROM ocurrent/opam-staging:ubuntu-24.04-riscv64
RUN ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime
COPY <<-EOF /etc/apt/apt.conf.d/mirror-retry
Acquire::Retries "5";
Expand Down
2 changes: 1 addition & 1 deletion ocaml-dockerfile
33 changes: 32 additions & 1 deletion src/pipeline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,43 @@ module Make (OCurrent : S.OCURRENT) = struct
let buildkit distro =
Distro.os_family_of_distro distro <> `Windows

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)
~options
~pool:(Conf.pool_name (`Ubuntu `LTS) `Riscv64)

let install_opam ~arch ~ocluster ~distro ~repos ~push_target ~windows_version () =
let base = match distro, arch with
| `Ubuntu _, `Riscv64 -> build_distro_base ocluster arch distro
| _ -> Current.return "" in
let arch_name = Ocaml_version.string_of_arch arch in
let distro_tag, os_family = Distro.(tag_of_distro distro, os_family_of_distro distro) in
Current.component "%s@,%s" distro_tag arch_name |>
let> {Git_repositories.opam_repository_master; opam_repository_mingw_sunset; opam_overlays; opam_2_0; opam_2_1; opam_master} = repos
and> windows_version = windows_version in
and> windows_version = windows_version
and> _ = base in
let dockerfile =
let opam_hashes = {
Dockerfile_opam.opam_2_0_hash = Current_git.Commit_id.hash opam_2_0;
Expand Down
8 changes: 8 additions & 0 deletions src/tag.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ let v ?arch ?switch distro =
in
Fmt.str "%s:%s-%s%a" repo distro switch pp_arch arch

let base ?arch distro =
let repo = if arch = None then Conf.public_repo else Conf.staging_repo in
let distro =
if distro = `Debian `Stable then "debian"
else Dockerfile_opam.Distro.tag_of_distro distro
in
Fmt.str "%s:%s%a" repo distro pp_arch arch

let v_alias alias =
let alias =
if alias = `Debian `Stable then "debian"
Expand Down
3 changes: 3 additions & 0 deletions src/tag.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ val v : ?arch:Ocaml_version.arch -> ?switch:Ocaml_version.t -> Dockerfile_opam.D
with no switches. If [arch] is set then this is a staging image, which will later be combined
into a cross-platform image. *)

val base : ?arch:Ocaml_version.arch -> Dockerfile_opam.Distro.t -> string
(** [base ?arch distro] is the Docker tag to use for a base image for [distro] and [arch]. *)

val v_alias : Dockerfile_opam.Distro.t -> string
(** [v_alias distro] is a short tag for [distro], without the OCaml version. *)

Expand Down

0 comments on commit af2f43e

Please sign in to comment.