-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support exporting Windows Dockerfiles
- Loading branch information
Showing
7 changed files
with
177 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
; This script builds OBuilder itself using a snapshot of the | ||
; ocaml/opam:windows-mingw-ocaml-4.14 base image. | ||
; | ||
; Run it from the top-level of the OBuilder source tree, e.g. | ||
; | ||
; root=../var | ||
; dune exec -- obuilder build --docker-backend="$root" -f example.windows.spec . | ||
; | ||
; The result can then be found in the Docker image "obuilder-ROOTID-image-HASH" | ||
; (where HASH is displayed at the end of the build). | ||
; The logs can be found in "$root/logs/HASH.log". | ||
; ROOTID is computed as follows: $(realpath "$(root)" | sha256sum | cut -b -7) | ||
|
||
((build dev | ||
((from ocaml/opam@sha256:63f5f8207ea61195988d9d49afcc4044bee3183645c58de6959f0864fabd9383) | ||
(workdir /src) | ||
(env OPAM_HASH "74176d75a60a6ec4d90d4178733b1e09f8becc6f") ; Fix the version of opam-repository-mingw we want | ||
(shell /cygwin64/bin/bash.exe --login -c) | ||
(run | ||
(network "nat") | ||
(shell | ||
"cd /home/opam/opam-repository \ | ||
&& (git cat-file -e $OPAM_HASH || git fetch origin opam2) \ | ||
&& git reset -q --hard $OPAM_HASH \ | ||
&& git --no-pager log --no-decorate -n1 --oneline \ | ||
&& rsync -ar --update --exclude='.git' ./ /cygdrive/c/opam/.opam/repo/default \ | ||
&& ocaml-env exec --64 -- opam update -u")) | ||
; opam update -u fails because of patch, so I'm overriding the repo with rsync | ||
(shell cmd /S /C) | ||
; Copy just the opam file first (helps caching) | ||
(copy (src obuilder-spec.opam obuilder.opam) (dst ./)) | ||
(run | ||
(network "nat") | ||
(cache (opam-archives (target /opam/.opam/download-cache))) | ||
(shell "ocaml-env exec --64 -- opam pin add -yn .")) | ||
; Install OS package dependencies | ||
(run | ||
(network "nat") | ||
(cache (opam-archives (target /opam/.opam/download-cache))) | ||
(shell "ocaml-env exec --64 -- opam depext -yu obuilder")) | ||
; Install OCaml dependencies | ||
(run | ||
(network "nat") | ||
(cache (opam-archives (target /opam/.opam/download-cache))) | ||
(shell "ocaml-env exec --64 -- opam install --deps-only -t obuilder-spec")) | ||
(run | ||
(network "nat") | ||
(cache (opam-archives (target /opam/.opam/download-cache))) | ||
(shell "ocaml-env exec --64 -- opam install --deps-only -t obuilder")) | ||
(copy ; Copy the rest of the source code | ||
(src .) | ||
(dst /src/) | ||
(exclude .git _build _opam duniverse)) | ||
(run (shell "ocaml-env exec --64 -- dune build @install")))) ; Build | ||
; Now generate a small runtime image with just the resulting binary: | ||
(from mcr.microsoft.com/windows/servercore:ltsc2022) | ||
(run (shell "mkdir C:\obuilder")) | ||
(copy (from (build dev)) | ||
(src /cygwin64/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libsqlite3-0.dll) | ||
(dst /obuilder/libsqlite3-0.dll)) | ||
(copy (from (build dev)) | ||
(src /src/_build/default/main.exe) | ||
(dst /obuilder/obuilder.exe)) | ||
(run (shell "/obuilder/obuilder.exe --help"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
val dockerfile_of_spec : buildkit:bool -> Spec.t -> string | ||
(** [dockerfile_of_spec x] produces a Dockerfile that aims to be equivalent to [x]. | ||
val dockerfile_of_spec : buildkit:bool -> os:[`Unix | `Windows] -> Spec.t -> string | ||
(** [dockerfile_of_spec ~buildkit ~os x] produces a Dockerfile | ||
that aims to be equivalent to [x]. | ||
However, note that: | ||
- In "(copy (excludes ...) ...)" the excludes part is ignored. You will need to ensure | ||
you have a suitable ".dockerignore" file. | ||
- The conversion is not robust against malicious input, as the escaping rules are unclear. | ||
@param buildkit If true, the extended BuildKit syntax is used to support caches. | ||
If false, caches are ignored. *) | ||
@param buildkit If true, the extended BuildKit syntax is used to | ||
support caches. If false, caches are ignored. BuildKit syntax | ||
isn't supported on Windows. | ||
@param os Use UNIX or Windows syntax and idiosyncrasies. *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters