From f17cad1bbe0d4a84308a37fb4a5e64211ada7e8a Mon Sep 17 00:00:00 2001 From: "Alex Lau(AvengerMoJo)" Date: Wed, 20 Dec 2023 07:13:33 +0000 Subject: [PATCH] Update the docker image rebuild flag for config file and example gitea/act_runner#390 (#391) this is a PR for the issue gitea/act_runner#390 It adding configuration for dockerfile container image to rebuild base on the configuration flag force_rebuild in config.yaml Reviewed-on: https://gitea.com/gitea/act_runner/pulls/391 Reviewed-by: Jason Song Co-authored-by: Alex Lau(AvengerMoJo) Co-committed-by: Alex Lau(AvengerMoJo) --- internal/app/run/runner.go | 2 +- internal/pkg/config/config.example.yaml | 2 ++ internal/pkg/config/config.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index 7be1dba..37d68e2 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -184,7 +184,7 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. ReuseContainers: false, ForcePull: r.cfg.Container.ForcePull, - ForceRebuild: false, + ForceRebuild: r.cfg.Container.ForceRebuild, LogOutput: true, JSONLogger: false, Env: r.envs, diff --git a/internal/pkg/config/config.example.yaml b/internal/pkg/config/config.example.yaml index df4f6cc..00b5fd1 100644 --- a/internal/pkg/config/config.example.yaml +++ b/internal/pkg/config/config.example.yaml @@ -82,6 +82,8 @@ container: docker_host: "" # Pull docker image(s) even if already present force_pull: false + # Rebuild docker image(s) even if already present + force_rebuild: false host: # The parent directory of a job's working directory. diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index 084de27..8a5cade 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -51,6 +51,7 @@ type Container struct { ValidVolumes []string `yaml:"valid_volumes"` // ValidVolumes specifies the volumes (including bind mounts) can be mounted to containers. DockerHost string `yaml:"docker_host"` // DockerHost specifies the Docker host. It overrides the value specified in environment variable DOCKER_HOST. ForcePull bool `yaml:"force_pull"` // Pull docker image(s) even if already present + ForceRebuild bool `yaml:"force_rebuild"` // Rebuild docker image(s) even if already present } // Host represents the configuration for the host.