-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Add docker support and CI for OTB project
* Introduced `docker.nix` to build Docker images for OTB with Python support. * Updated the flake configuration to include `nix2container` and specify Docker image build. * Enhanced the README with Docker build instructions and added a CI workflow to validate builds on both `amd64` and `arm64` architectures. * Additional minor updates include modifications to the `.gitignore` and the creation of a Makefile for Docker image builds.
- Loading branch information
Showing
8 changed files
with
390 additions
and
43 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,33 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
machine: | ||
- host: amd64 | ||
platform: x86_64-linux | ||
- host: arm64 | ||
platform: aarch64-linux | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- if: matrix.machine.platform == 'aarch64-linux' | ||
uses: docker/setup-qemu-action@v3 | ||
- uses: DeterminateSystems/nix-installer-action@main | ||
with: | ||
extra-conf: | | ||
fallback = true | ||
http-connections = 128 | ||
max-substitution-jobs = 128 | ||
extra-platforms = aarch64-linux | ||
- name: Build system | ||
run: | | ||
nix build --system ${{ matrix.machine.platform }} . |
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,3 +1,4 @@ | ||
.idea/ | ||
.DS_Store | ||
.direnv | ||
/.venv/ |
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,5 @@ | ||
build_docker_x86_64: | ||
nix run .\#otb-docker-x86_64.copyToDockerDaemon | ||
|
||
#build_docker_arch64: | ||
# nix run .\#otb-docker-aarch64.copyToDockerDaemon |
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
nix2containerPkgs, | ||
python3, | ||
otb, | ||
img-name ? "otb", | ||
img-tag ? "latest", | ||
extra-packages ? [], | ||
extra-python-packages ? [], | ||
pkgs, | ||
... | ||
}: let | ||
py-env = ( | ||
python3.withPackages (pp: | ||
with pp; | ||
[numpy] | ||
++ extra-python-packages) | ||
); | ||
|
||
py-env-sitepackages = "${py-env}/${py-env.sitePackages}"; | ||
py-env-bin = "${py-env}/bin"; | ||
otbLibPath = with pkgs; pkgs.lib.makeLibraryPath [otb]; | ||
otbBinPath = with pkgs; pkgs.lib.makeBinPath otb.propagatedBuildInputs; | ||
in | ||
nix2containerPkgs.nix2container.buildImage rec { | ||
name = img-name; | ||
tag = img-tag; | ||
|
||
copyToRoot = pkgs.buildEnv { | ||
name = "root"; | ||
paths = with pkgs.dockerTools; | ||
with pkgs; | ||
[ | ||
# Base OS | ||
## GNU | ||
coreutils-full | ||
findutils | ||
bashInteractive | ||
gnugrep | ||
gnused | ||
which | ||
|
||
## Networking | ||
cacert | ||
caCertificates | ||
fakeNss | ||
shadowSetup | ||
iana-etc | ||
|
||
# Conveniences | ||
git | ||
neovim-unwrapped | ||
zsh | ||
|
||
# Library | ||
otb | ||
py-env | ||
] | ||
++ extra-packages; | ||
|
||
pathsToLink = ["/bin" "/etc" "/var" "/run" "/tmp" "/lib"]; | ||
postBuild = '' | ||
mkdir -p $out/tmp | ||
mkdir -p $out/etc | ||
cat <<HEREDOC > $out/etc/zshrc | ||
autoload -U compinit && compinit | ||
autoload -U promptinit && promptinit && prompt suse && setopt prompt_sp | ||
autoload -U colors && colors | ||
export PS1=$'%{\033[31m%}[nix-shell:%{\033[32m%}%~%{\033[31m%}]%{\033[0m%}$ '; | ||
HEREDOC | ||
''; | ||
}; | ||
|
||
config = { | ||
Cmd = ["/bin/env" "zsh"]; | ||
Env = [ | ||
"LANG=C.UTF-8" | ||
"LC_ALL=C.UTF-8" | ||
"LC_CTYPE=C.UTF-8" | ||
"EDITOR=nvim" | ||
"PYTHONPATH=${py-env-sitepackages}:${otbLibPath}/otb/python" | ||
"PATH=${py-env-bin}:${otbBinPath}:/bin" | ||
"TMPDIR=/tmp" | ||
]; | ||
}; | ||
} | ||
|
Oops, something went wrong.