Compare commits

...

4 Commits

Author SHA1 Message Date
Pyranota
e56fa3909e Remove --dir flag
EE repos are handled either manually or with --auto-substitute flag
2025-01-24 18:49:43 +03:00
Pyranota
44b623ca6d Update docker.nu 2025-01-24 18:46:04 +03:00
Pyranota
ca34f741bc Merge branch 'docker.nu' of github.com:windmill-labs/windmill into docker.nu 2025-01-24 17:42:07 +03:00
pyranota
cd6b35dfae DevEx: Implement docker.nu helper
------------------------------------
 Build and Test docker images locally
                run:
        docker/docker.nu --help
 ------------------------------------
2024-12-12 16:13:21 +01:00
2 changed files with 113 additions and 1 deletions

3
backend/.gitignore vendored
View File

@@ -5,4 +5,5 @@ oauth2.json
tracing.folded
heaptrack*
index/
windmill-api/openapi-*.*
windmill-api/openapi-*.*
.docker.nu/

111
docker/docker.nu Executable file
View File

@@ -0,0 +1,111 @@
#! /usr/bin/env nu
# ------------------------------------ #
# Build and Test docker images locally #
# run: #
# docker/docker.nu --help #
# ------------------------------------ #
let branch = git branch --show-current;
# TODO: Use podman
let use_podman = false;
# Build and Test docker images
#
# For more info run:
# docker.nu up --help
# docker.nu build --help
#
# Should be invoked in repo root
def main [] {
./docker/docker.nu --help;
}
# Run and Build (if not yet) docker image
def "main up" [
custom_dockerfile?: path # Any dockerfile that depends on root Dockerfile
--features(-f): string = "deno_core" # Features that will be passed to base Dockerfile to compile windmill
--yes(-y) # Say yes for every confirmation (TODO)
] {
let ident = get_ident $custom_dockerfile -f $features;
if not (sudo docker images | into string | str contains $ident) {
print $"($ident) is not found, building..."
main build $custom_dockerfile -f $features
} else {
print $"($ident) was found"
}
print $"Running: ($ident)"
sudo WM_IMAGE=($ident) docker compose up --pull never
}
# Build docker image
def "main build" [
custom_dockerfile?: path # Any dockerfile that depends on root Dockerfile
--features(-f): string = "deno_core" # Features that will be passed to base Dockerfile to compile windmill
--mock(-m) # Ignore building base image
--yes(-y) # Say yes for every confirmation (TODO)
--podman(-p) # Use podman (TODO)
] {
if not $mock {
build_base -f $features
}
if $custom_dockerfile != null {
let ident = get_ident $custom_dockerfile -f $features;
let tmpfile = patch $custom_dockerfile -f $features;
print $"Building image by path ($custom_dockerfile) with ident: ($ident)"
sudo docker build -f $tmpfile -t $ident ./
}
}
def build_base [
--features(-f): string
] {
if not ($features | str contains "deno_core") {
print "Warning! deno_core feature not enabled"
print "Compilation may fail"
}
if ($features | str contains "enterprise") {
print "Building in EE mode"
print "Is windmill ee private repo mounted? [Y/n]";
let inp = input listen --types [key]
if ($inp.code != "y") {
# print "You can use --auto-substitute(-s) to automatically mount ee private repo (TODO)"
print "Aborted"
return;
}
}
let ident = get_ident -f $features;
print $"Building base image with ident: ($ident)"
sudo docker build -t ($ident) . --build-arg features=($features)
}
# TODO
def clone_ee_private [] {
let rev = open backend/ee-repo-ref.txt
git clone --depth 1 git@github.com:windmill-labs/windmill-ee-private.git .docker.nu/private-ee-repo-rev-($rev)
# git checkout ddcfdfc18a9833a5fc4e62ad62a265ef1e06a0aa)
}
def get_ident [
custom_dockerfile?: path # Any dockerfile that depends on root Dockerfile
--features(-f): string = "deno_core" # Features that will be passed to base Dockerfile to compile windmill
] {
let feat_postfix = $features | split row ',' | each { |e| $e | str trim --left --right } | sort | str join "-";
if $custom_dockerfile != null {
let df_postfix = $"($custom_dockerfile)" | split row "Dockerfile" | get 1 | str downcase;
return ($branch | append $df_postfix | append $feat_postfix | str join "__");
} else {
return ($branch | append $feat_postfix | str join "-");
}
}
def patch [
file: path
--features(-f): string
] {
let tmpfile = $"(mktemp -d)/Dockerfile";
open $file | str replace 'ghcr.io/windmill-labs/windmill-ee:dev' (get_ident -f $features) | save $tmpfile;
return $tmpfile;
}