mirror of
https://github.com/drone-plugins/drone-docker.git
synced 2026-06-26 16:03:24 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e311310166 |
+1
-17
@@ -1,27 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [v20.10.9.1](https://github.com/drone-plugins/drone-docker/tree/v20.10.9.1) (2022-01-13)
|
## [v20.10.9](https://github.com/drone-plugins/drone-docker/tree/v20.10.9) (2021-11-02)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.10.9...v20.10.9.1)
|
|
||||||
|
|
||||||
**Implemented enhancements:**
|
|
||||||
|
|
||||||
- Serialize windows 1809 pipelines [\#348](https://github.com/drone-plugins/drone-docker/pull/348) ([shubham149](https://github.com/shubham149))
|
|
||||||
- Support for windows images for tags [\#346](https://github.com/drone-plugins/drone-docker/pull/346) ([shubham149](https://github.com/shubham149))
|
|
||||||
|
|
||||||
**Fixed bugs:**
|
|
||||||
|
|
||||||
- Fix ECR & GCR docker publish on windows [\#352](https://github.com/drone-plugins/drone-docker/pull/352) ([shubham149](https://github.com/shubham149))
|
|
||||||
- Fix windows docker builds [\#351](https://github.com/drone-plugins/drone-docker/pull/351) ([shubham149](https://github.com/shubham149))
|
|
||||||
- Fix powershell script to publish windows images [\#350](https://github.com/drone-plugins/drone-docker/pull/350) ([shubham149](https://github.com/shubham149))
|
|
||||||
|
|
||||||
## [v20.10.9](https://github.com/drone-plugins/drone-docker/tree/v20.10.9) (2021-11-03)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.9...v20.10.9)
|
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.9...v20.10.9)
|
||||||
|
|
||||||
**Merged pull requests:**
|
**Merged pull requests:**
|
||||||
|
|
||||||
- bump to version 20.10.9: [\#342](https://github.com/drone-plugins/drone-docker/pull/342) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
|
||||||
- Upgrade Docker dind to 20.10.9 for 64bit platforms [\#334](https://github.com/drone-plugins/drone-docker/pull/334) ([gzm0](https://github.com/gzm0))
|
- Upgrade Docker dind to 20.10.9 for 64bit platforms [\#334](https://github.com/drone-plugins/drone-docker/pull/334) ([gzm0](https://github.com/gzm0))
|
||||||
|
|
||||||
## [v19.03.9](https://github.com/drone-plugins/drone-docker/tree/v19.03.9) (2021-10-13)
|
## [v19.03.9](https://github.com/drone-plugins/drone-docker/tree/v19.03.9) (2021-10-13)
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package docker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p Plugin) writeCard() error {
|
||||||
|
cmd := exec.Command("docker", "inspect", p.Build.Name)
|
||||||
|
data, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
out := map[string]interface{}{} // replace with docker inspect struct
|
||||||
|
if err := json.Unmarshal(data, &out); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
card := map[string]interface{}{} // replace with card struct, populate with docker inspect output
|
||||||
|
|
||||||
|
writeCard( /*p.CardPath*/ "", &card)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeCard(path string, card interface{}) {
|
||||||
|
data, _ := json.Marshal(card)
|
||||||
|
switch {
|
||||||
|
case path == "/dev/stdout":
|
||||||
|
writeCardTo(os.Stdout, data)
|
||||||
|
case path == "/dev/stderr":
|
||||||
|
writeCardTo(os.Stderr, data)
|
||||||
|
case path != "":
|
||||||
|
ioutil.WriteFile(path, data, 0644)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeCardTo(out io.Writer, data []byte) {
|
||||||
|
encoded := base64.StdEncoding.EncodeToString(data)
|
||||||
|
io.WriteString(out, "\u001B]1338;")
|
||||||
|
io.WriteString(out, encoded)
|
||||||
|
io.WriteString(out, "\u001B]0m")
|
||||||
|
io.WriteString(out, "\n")
|
||||||
|
}
|
||||||
@@ -7,9 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
docker "github.com/drone-plugins/drone-docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -43,12 +40,12 @@ func main() {
|
|||||||
os.Setenv("DOCKER_PASSWORD", password)
|
os.Setenv("DOCKER_PASSWORD", password)
|
||||||
|
|
||||||
// invoke the base docker plugin binary
|
// invoke the base docker plugin binary
|
||||||
cmd := exec.Command(docker.GetDroneDockerExecCmd())
|
cmd := exec.Command("drone-docker")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-29
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@@ -268,26 +267,26 @@ func run(c *cli.Context) error {
|
|||||||
Config: c.String("docker.config"),
|
Config: c.String("docker.config"),
|
||||||
},
|
},
|
||||||
Build: docker.Build{
|
Build: docker.Build{
|
||||||
Remote: c.String("remote.url"),
|
Remote: c.String("remote.url"),
|
||||||
Name: c.String("commit.sha"),
|
Name: c.String("commit.sha"),
|
||||||
Dockerfile: c.String("dockerfile"),
|
Dockerfile: c.String("dockerfile"),
|
||||||
Context: c.String("context"),
|
Context: c.String("context"),
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
Args: c.StringSlice("args"),
|
Args: c.StringSlice("args"),
|
||||||
ArgsEnv: c.StringSlice("args-from-env"),
|
ArgsEnv: c.StringSlice("args-from-env"),
|
||||||
Target: c.String("target"),
|
Target: c.String("target"),
|
||||||
Squash: c.Bool("squash"),
|
Squash: c.Bool("squash"),
|
||||||
Pull: c.BoolT("pull-image"),
|
Pull: c.BoolT("pull-image"),
|
||||||
CacheFrom: c.StringSlice("cache-from"),
|
CacheFrom: c.StringSlice("cache-from"),
|
||||||
Compress: c.Bool("compress"),
|
Compress: c.Bool("compress"),
|
||||||
Repo: c.String("repo"),
|
Repo: c.String("repo"),
|
||||||
Labels: c.StringSlice("custom-labels"),
|
Labels: c.StringSlice("custom-labels"),
|
||||||
LabelSchema: c.StringSlice("label-schema"),
|
LabelSchema: c.StringSlice("label-schema"),
|
||||||
AutoLabel: c.BoolT("auto-label"),
|
AutoLabel: c.BoolT("auto-label"),
|
||||||
Link: c.String("link"),
|
Link: c.String("link"),
|
||||||
NoCache: c.Bool("no-cache"),
|
NoCache: c.Bool("no-cache"),
|
||||||
AddHost: c.StringSlice("add-host"),
|
AddHost: c.StringSlice("add-host"),
|
||||||
Quiet: c.Bool("quiet"),
|
Quiet: c.Bool("quiet"),
|
||||||
},
|
},
|
||||||
Daemon: docker.Daemon{
|
Daemon: docker.Daemon{
|
||||||
Registry: c.String("docker.registry"),
|
Registry: c.String("docker.registry"),
|
||||||
@@ -328,11 +327,3 @@ func run(c *cli.Context) error {
|
|||||||
|
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetExecCmd() string {
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
return "C:/bin/drone-docker.exe"
|
|
||||||
}
|
|
||||||
|
|
||||||
return "drone-docker"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,15 +11,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
|
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/ecr"
|
"github.com/aws/aws-sdk-go/service/ecr"
|
||||||
|
|
||||||
docker "github.com/drone-plugins/drone-docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultRegion = "us-east-1"
|
const defaultRegion = "us-east-1"
|
||||||
@@ -113,11 +110,11 @@ func main() {
|
|||||||
os.Setenv("DOCKER_PASSWORD", password)
|
os.Setenv("DOCKER_PASSWORD", password)
|
||||||
|
|
||||||
// invoke the base docker plugin binary
|
// invoke the base docker plugin binary
|
||||||
cmd := exec.Command(docker.GetDroneDockerExecCmd())
|
cmd := exec.Command("drone-docker")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err = cmd.Run(); err != nil {
|
if err = cmd.Run(); err != nil {
|
||||||
logrus.Fatal(err)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
docker "github.com/drone-plugins/drone-docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// gcr default username
|
// gcr default username
|
||||||
@@ -57,12 +54,12 @@ func main() {
|
|||||||
os.Setenv("DOCKER_PASSWORD", password)
|
os.Setenv("DOCKER_PASSWORD", password)
|
||||||
|
|
||||||
// invoke the base docker plugin binary
|
// invoke the base docker plugin binary
|
||||||
cmd := exec.Command(docker.GetDroneDockerExecCmd())
|
cmd := exec.Command("drone-docker")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -157,11 +156,6 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Cleanup {
|
|
||||||
cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi
|
|
||||||
cmds = append(cmds, commandPrune()) // docker system prune -f
|
|
||||||
}
|
|
||||||
|
|
||||||
// execute all commands in batch mode.
|
// execute all commands in batch mode.
|
||||||
for _, cmd := range cmds {
|
for _, cmd := range cmds {
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
@@ -180,6 +174,26 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// output the adaptive card
|
||||||
|
if err := p.writeCard(); err != nil {
|
||||||
|
fmt.Printf("Could not create adaptive card. %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute cleanup routines in batch mode
|
||||||
|
if p.Cleanup {
|
||||||
|
// clear the slice
|
||||||
|
cmds = nil
|
||||||
|
|
||||||
|
cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi
|
||||||
|
cmds = append(cmds, commandPrune()) // docker system prune -f
|
||||||
|
|
||||||
|
for _, cmd := range cmds {
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
trace(cmd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,11 +431,3 @@ func commandRmi(tag string) *exec.Cmd {
|
|||||||
func trace(cmd *exec.Cmd) {
|
func trace(cmd *exec.Cmd) {
|
||||||
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
|
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDroneDockerExecCmd() string {
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
return "C:/bin/drone-docker.exe"
|
|
||||||
}
|
|
||||||
|
|
||||||
return "drone-docker"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ echo $env:VERSION
|
|||||||
echo $env:REGISTRY
|
echo $env:REGISTRY
|
||||||
|
|
||||||
# build the binary
|
# build the binary
|
||||||
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}";
|
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe";
|
||||||
go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}
|
go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}
|
||||||
|
|
||||||
# build and publish the docker image
|
# build and publish the docker image
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ echo $env:GOARCH
|
|||||||
echo $env:VERSION
|
echo $env:VERSION
|
||||||
|
|
||||||
# build the binary
|
# build the binary
|
||||||
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}"
|
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe"
|
||||||
go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}
|
go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}
|
||||||
|
|
||||||
# authenticate with the docker registry
|
# authenticate with the docker registry
|
||||||
|
|||||||
Reference in New Issue
Block a user