From 9a6a1a95c77120769fcd8b1d0ce8ab4f33acce36 Mon Sep 17 00:00:00 2001 From: Xabier Larrakoetxea Date: Wed, 27 Mar 2024 17:07:15 +0100 Subject: [PATCH] Fix dockerfile workdir Signed-off-by: Xabier Larrakoetxea --- cmd/kube-code-generator/main.go | 4 ++-- docker/prod/Dockerfile | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/kube-code-generator/main.go b/cmd/kube-code-generator/main.go index 8325ca9..18edea8 100644 --- a/cmd/kube-code-generator/main.go +++ b/cmd/kube-code-generator/main.go @@ -57,7 +57,7 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer) error { return fmt.Errorf("could not get go module: %w", err) } goCodeGenOutPkg := utilgomod.GetGoPackageFromDir(goModule, cmdCfg.GoCodeOutPath) - logger.Infof("Go generated code package inferred", "module", goCodeGenOutPkg) + logger.WithValues(log.Kv{"module": goCodeGenOutPkg}).Infof("Go generated code package inferred") if filepath.IsAbs(cmdCfg.APIsPath) { return fmt.Errorf("APIs path should be relative") @@ -104,7 +104,7 @@ func generateGoCode(ctx context.Context, cmdCfg CmdConfig, logger log.Logger, ge boilerplatePath = f.Name() } - logger.Infof("Generating Go clients code...") + logger.Infof("Generating Go code...") err = generate.NewClientGenerator(logger, cmdCfg.CodeGenPath, generate.StdBashExecutor). WithWatch(). WithBoilerplate(boilerplatePath). diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index da93b24..4d18580 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -42,16 +42,15 @@ RUN wget http://github.com/kubernetes/code-generator/archive/kubernetes-${CODEGE rm -rf ../controller-tools-${CONTROLLER_GEN_VERSION} -# Create user +# Create user and workdir. ARG uid=1000 ARG gid=1000 RUN addgroup --gid $gid app && \ adduser --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password --uid $uid --ingroup app app && \ chown app:app -R /go +RUN mkdir /app && chown app:app -R /app USER app - -RUN mkdir /app && chown app:app -R /app WORKDIR /app ENV KUBE_CODE_GENERATOR_CODEGEN_PATH=/tmp/k8s-code-generator