diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8263de0..8cdf89d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. diff --git a/.github/workflows/docker-description.yml b/.github/workflows/docker-description.yml index 0a9126a..4d36d2b 100644 --- a/.github/workflows/docker-description.yml +++ b/.github/workflows/docker-description.yml @@ -12,7 +12,7 @@ jobs: docker-description: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Sync Docker Hub Description if: github.ref == 'refs/heads/main' && github.repository == 'kool-dev/kool' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ca525b5..a74d2f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,9 +17,9 @@ jobs: with: go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Caching - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/go/pkg key: ${{ runner.os }}-kool-${{ hashFiles('**/go.sum') }} diff --git a/commands/cloud_deploy.go b/commands/cloud_deploy.go index 753a76b..c35693d 100644 --- a/commands/cloud_deploy.go +++ b/commands/cloud_deploy.go @@ -24,7 +24,7 @@ type KoolCloudDeployFlags struct { Timeout uint // env: KOOL_API_TIMEOUT WwwRedirect bool // env: KOOL_DEPLOY_WWW_REDIRECT DeployDomainExtras []string // env: KOOL_DEPLOY_DOMAIN_EXTRAS - + Platform string // platform for docker build, e.g. linux/amd64 // Cluster string // env: KOOL_DEPLOY_CLUSTER } @@ -53,6 +53,7 @@ func NewDeployCommand(deploy *KoolDeploy) (cmd *cobra.Command) { cmd.Flags().StringArrayVarP(&deploy.flags.DeployDomainExtras, "domain-extra", "", []string{}, "List of extra domain aliases") cmd.Flags().BoolVarP(&deploy.flags.WwwRedirect, "www-redirect", "", false, "Redirect www to non-www domain") cmd.Flags().UintVarP(&deploy.flags.Timeout, "timeout", "", 0, "Timeout in minutes for waiting the deployment to finish") + cmd.Flags().StringVarP(&deploy.flags.Platform, "platform", "", "linux/amd64", "Platform for docker build (default: linux/amd64)") return } @@ -123,7 +124,7 @@ func (d *KoolDeploy) Execute(args []string) (err error) { if svc.Build != nil { d.Shell().Info(" > Build deploy image for service '", svcName, "'") - if err = cloud.BuildPushImageForDeploy(svcName, svc, deployCreated); err != nil { + if err = cloud.BuildPushImageForDeploy(svcName, svc, deployCreated, d.flags.Platform); err != nil { if reportErr := deployer.BuildError(deployCreated, err); reportErr != nil { d.Shell().Error(fmt.Errorf("error reporting build error: %v", reportErr)) } diff --git a/go.mod b/go.mod index 5fe3ef0..43288a7 100644 --- a/go.mod +++ b/go.mod @@ -36,6 +36,7 @@ require github.com/compose-spec/compose-go v1.13.0 require ( github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/fatih/color v1.15.0 // indirect github.com/google/go-github/v30 v30.1.0 // indirect github.com/google/go-querystring v1.1.0 // indirect @@ -49,6 +50,7 @@ require ( github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/rivo/uniseg v0.4.4 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/tcnksm/go-gitconfig v0.1.2 // indirect diff --git a/go.sum b/go.sum index 92b331a..8a8e268 100755 --- a/go.sum +++ b/go.sum @@ -62,6 +62,7 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/compose-spec/compose-go v1.13.0 h1:HHMc1XvnHJr9LUS7fPiiQeTSmGtEp+myn7jGnXgIoXE= github.com/compose-spec/compose-go v1.13.0/go.mod h1:uo+YhhqDpkW9MjZNzJgOLX3MlbK6zHaBo9n8LhGDwsg= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= @@ -221,6 +222,7 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= diff --git a/services/cloud/build.go b/services/cloud/build.go index 4ca62be..0e79f78 100644 --- a/services/cloud/build.go +++ b/services/cloud/build.go @@ -15,7 +15,7 @@ import ( yaml "gopkg.in/yaml.v2" ) -func BuildPushImageForDeploy(service string, config *DeployConfigService, deploy *api.DeployCreateResponse) (err error) { +func BuildPushImageForDeploy(service string, config *DeployConfigService, deploy *api.DeployCreateResponse, platform string) (err error) { if config.Build == nil { err = errors.New("service " + service + " has no build configuration") return @@ -33,7 +33,7 @@ func BuildPushImageForDeploy(service string, config *DeployConfigService, deploy var in = bytes.NewBuffer([]byte{}) sh.SetInStream(in) - dockerBuild := builder.NewCommand("docker", "build", "-t", image, "--platform", "linux/amd64") + dockerBuild := builder.NewCommand("docker", "build", "-t", image, "--platform", platform) if folder, isStr := (*config.Build).(string); isStr { // this should be a simple build with a context folder