From 4e72cb461e248f156261183db746617f62b431e9 Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Sat, 21 Jun 2025 15:50:25 +0700 Subject: [PATCH] perf(controller): switch back to backed in dependecies Running nix develop every time is a little slow, may revisit later. --- controller/Dockerfile | 7 +++++++ controller/activities/oci.go | 3 +-- controller/activities/terragrunt.go | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/controller/Dockerfile b/controller/Dockerfile index 432445b..d03aa9a 100644 --- a/controller/Dockerfile +++ b/controller/Dockerfile @@ -14,6 +14,13 @@ FROM docker.io/nixos/nix RUN echo "experimental-features = flakes nix-command" >> /etc/nix/nix.conf +# TODO use native nix develop, currently it's a bit slow +RUN nix-env --install --quiet --attr \ + nixpkgs.kubernetes-helm \ + nixpkgs.opentofu \ + nixpkgs.oras \ + nixpkgs.terragrunt + COPY --from=builder /bin/worker /bin/worker CMD ["/bin/worker"] diff --git a/controller/activities/oci.go b/controller/activities/oci.go index f52c5f1..a00ebcc 100644 --- a/controller/activities/oci.go +++ b/controller/activities/oci.go @@ -25,7 +25,7 @@ type PushResult struct { func PushManifests(ctx context.Context, path string, image string) (*PushResult, error) { logger := activity.GetLogger(ctx) - cmd := exec.CommandContext(ctx, "nix", "develop", "--command", "oras", "push", "--format=json", "--plain-http", image, ".") + cmd := exec.CommandContext(ctx, "oras", "push", "--format=json", "--plain-http", image, ".") cmd.Dir = path var stdout, stderr bytes.Buffer @@ -58,7 +58,6 @@ func PushRenderedHelm(ctx context.Context, appsPath, namespace, app, cluster, re cmd := exec.CommandContext( ctx, - "nix", "develop", "--command", "helm", "template", "--namespace", namespace, app, "oci://ghcr.io/bjw-s-labs/helm/app-template:4.1.1", "--values", path.Join(namespace, app, cluster+".yaml"), "--output-dir", tmpDir, ) cmd.Dir = appsPath diff --git a/controller/activities/terragrunt.go b/controller/activities/terragrunt.go index df4ca1c..4d1e427 100644 --- a/controller/activities/terragrunt.go +++ b/controller/activities/terragrunt.go @@ -13,7 +13,7 @@ import ( ) func TerragruntGraph(ctx context.Context, path string) (*Graph, error) { - cmd := exec.CommandContext(ctx, "nix", "develop", "--command", "terragrunt", "dag", "graph") + cmd := exec.CommandContext(ctx, "terragrunt", "dag", "graph") cmd.Dir = path output, err := cmd.Output() if err != nil { @@ -38,7 +38,7 @@ func TerragruntApply(ctx context.Context, repoUrl string, revision string, modul fullPath := filepath.Join(repoPath, "infra", stack, modulePath) - cmd := exec.CommandContext(ctx, "nix", "develop", "--command", "terragrunt", "apply", "--backend-bootstrap", "--auto-approve") + cmd := exec.CommandContext(ctx, "terragrunt", "apply", "--backend-bootstrap", "--auto-approve") cmd.Dir = fullPath // Create pipes to capture output and send heartbeats -- 2.51.2