mirror of
https://github.com/thegeeklab/wp-docker-buildx.git
synced 2024-11-21 13:50:39 +00:00
enable gcr and heroku plugins
This commit is contained in:
parent
7636c99bb6
commit
3e321f1904
22
.drone.sh
Normal file
22
.drone.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# compile the main binary
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/amd64/drone-docker github.com/drone-plugins/drone-docker/cmd/drone-docker
|
||||
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/arm64/drone-docker github.com/drone-plugins/drone-docker/cmd/drone-docker
|
||||
GOOS=linux GOARCH=arm CGO_ENABLED=0 GOARM=7 go build -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/arm/drone-docker github.com/drone-plugins/drone-docker/cmd/drone-docker
|
||||
|
||||
# build the heroku binary
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-docker-heroku github.com/drone-plugins/drone-docker/cmd/drone-docker-heroku
|
||||
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/arm64/drone-docker-heroku github.com/drone-plugins/drone-docker/cmd/drone-docker-heroku
|
||||
GOOS=linux GOARCH=arm CGO_ENABLED=0 GOARM=7 go build -a -tags netgo -o release/linux/arm/drone-docker-heroku github.com/drone-plugins/drone-docker/cmd/drone-docker-heroku
|
||||
|
||||
# build the gcr binary
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-docker-gcr github.com/drone-plugins/drone-docker/cmd/drone-docker-gcr
|
||||
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/arm64/drone-docker-gcr github.com/drone-plugins/drone-docker/cmd/drone-docker-gcr
|
||||
GOOS=linux GOARCH=arm CGO_ENABLED=0 GOARM=7 go build -a -tags netgo -o release/linux/arm/drone-docker-gcr github.com/drone-plugins/drone-docker/cmd/drone-docker-gcr
|
||||
|
||||
# build the ecr binary
|
||||
# todo
|
33
.drone.yml
33
.drone.yml
@ -3,21 +3,36 @@ workspace:
|
||||
path: src/github.com/drone-plugins/drone-docker
|
||||
|
||||
pipeline:
|
||||
test:
|
||||
image: golang:1.6
|
||||
environment:
|
||||
- CGO_ENABLED=0
|
||||
commands:
|
||||
# Disabled: main.go:99: cli.StringSlice composite literal uses unkeyed fields
|
||||
# - go vet
|
||||
- go test -cover -coverprofile=coverage.out
|
||||
- go build -ldflags "-s -w -X main.build=$DRONE_BUILD_NUMBER" -a -tags netgo
|
||||
build:
|
||||
image: golang:1.9
|
||||
commands: sh .drone.sh
|
||||
|
||||
publish:
|
||||
image: plugins/docker
|
||||
repo: plugins/docker
|
||||
tags: [ "latest", "17", "17.05" ]
|
||||
secrets: [ docker_username, docker_password ]
|
||||
dockerfile: docker/Dockerfile
|
||||
when:
|
||||
branch: master
|
||||
event: push
|
||||
|
||||
publish_heroku:
|
||||
image: plugins/docker
|
||||
repo: plugins/heroku
|
||||
tags: [ "latest", "17", "17.05" ]
|
||||
secrets: [ docker_username, docker_password ]
|
||||
dockerfile: docker/heroku/Dockerfile
|
||||
when:
|
||||
branch: master
|
||||
event: push
|
||||
|
||||
publish_gcr:
|
||||
image: plugins/docker
|
||||
repo: plugins/gcr
|
||||
tags: [ "latest", "17", "17.05" ]
|
||||
secrets: [ docker_username, docker_password ]
|
||||
dockerfile: docker/gcr/Dockerfile
|
||||
when:
|
||||
branch: master
|
||||
event: push
|
||||
|
29
.gitignore
vendored
29
.gitignore
vendored
@ -1,28 +1,3 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
.env
|
||||
|
||||
release
|
||||
coverage.out
|
||||
drone-docker
|
||||
tmp
|
||||
|
@ -1,4 +0,0 @@
|
||||
FROM docker:17.05.0-ce-dind
|
||||
|
||||
ADD drone-docker /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]
|
@ -1,4 +0,0 @@
|
||||
FROM ???
|
||||
|
||||
ADD drone-docker /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]
|
46
MAINTAINERS
46
MAINTAINERS
@ -1,46 +0,0 @@
|
||||
[people]
|
||||
[people.bradrydzewski]
|
||||
name = "Brad Rydzewski"
|
||||
email = "brad@drone.io"
|
||||
login = "bradrydzewski"
|
||||
[people.Bugagazavr]
|
||||
name = "Kirill"
|
||||
email = ""
|
||||
login = "Bugagazavr"
|
||||
[people.donny-dont]
|
||||
name = "Don Olmstead"
|
||||
email = "donny-dont@gmail.com"
|
||||
login = "donny-dont"
|
||||
[people.jackspirou]
|
||||
name = "Jack Spirou"
|
||||
email = ""
|
||||
login = "jackspirou"
|
||||
[people.msteinert]
|
||||
name = "Mike Steinert"
|
||||
email = ""
|
||||
login = "msteinert"
|
||||
[people.nlf]
|
||||
name = "Nathan LaFreniere"
|
||||
email = ""
|
||||
login = "nlf"
|
||||
[people.tboerger]
|
||||
name = "Thomas Boerger"
|
||||
email = "thomas@webhippie.de"
|
||||
login = "tboerger"
|
||||
[people.athieriot]
|
||||
name = "Aurélien Thieriot"
|
||||
email = "a.thieriot@gmail.com"
|
||||
login = "athieriot"
|
||||
|
||||
[org]
|
||||
[org.core]
|
||||
people = [
|
||||
"bradrydzewski",
|
||||
"Bugagazavr",
|
||||
"donny-dont",
|
||||
"jackspirou",
|
||||
"msteinert",
|
||||
"nlf",
|
||||
"tboerger",
|
||||
"athieriot"
|
||||
]
|
5
cmd/drone-docker-ecr/main.go
Normal file
5
cmd/drone-docker-ecr/main.go
Normal file
@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
50
cmd/drone-docker-gcr/main.go
Normal file
50
cmd/drone-docker-gcr/main.go
Normal file
@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
username = "_json_key"
|
||||
password = os.Getenv("GCR_TOKEN")
|
||||
registry = os.Getenv("PLUGIN_REGISTRY")
|
||||
repo = os.Getenv("PLUGIN_REPO")
|
||||
)
|
||||
|
||||
// decode the token if base64 encoded
|
||||
decoded, err := base64.StdEncoding.DecodeString(password)
|
||||
if err == nil {
|
||||
password = string(decoded)
|
||||
}
|
||||
|
||||
// default registry value
|
||||
if registry == "" {
|
||||
registry = "gcr.io"
|
||||
}
|
||||
|
||||
// must use the fully qualified repo name. If the
|
||||
// repo name does not have the registry prefix we
|
||||
// should prepend.
|
||||
if !strings.HasPrefix(repo, registry) {
|
||||
repo = path.Join(registry, repo)
|
||||
os.Setenv("PLUGIN_REPO", repo)
|
||||
}
|
||||
|
||||
os.Setenv("PLUGIN_REGISTRY", registry)
|
||||
os.Setenv("DOCKER_USERNAME", username)
|
||||
os.Setenv("DOCKER_PASSWORD", password)
|
||||
|
||||
// invoke the base docker plugin binary
|
||||
cmd := exec.Command("drone-docker")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
45
cmd/drone-docker-heroku/main.go
Normal file
45
cmd/drone-docker-heroku/main.go
Normal file
@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
registry = "registry.heroku.com"
|
||||
process = os.Getenv("PLUGIN_PROCESS_TYPE")
|
||||
app = os.Getenv("PLUGIN_APP")
|
||||
email = os.Getenv("PLUGIN_EMAIL")
|
||||
key = os.Getenv("PLUGIN_API_KEY")
|
||||
)
|
||||
|
||||
// if the heroku email is provided as a named secret
|
||||
// then we should use it.
|
||||
if os.Getenv("HEROKU_EMAIL") != "" {
|
||||
email = os.Getenv("HEROKU_EMAIL")
|
||||
}
|
||||
|
||||
// if the heroku api key is provided as a named secret
|
||||
// then we should use it.
|
||||
if os.Getenv("HEROKU_API_KEY") != "" {
|
||||
key = os.Getenv("HEROKU_API_KEY")
|
||||
}
|
||||
|
||||
os.Setenv("PLUGIN_REGISTRY", registry)
|
||||
os.Setenv("PLUGIN_REPO", path.Join(registry, app, process))
|
||||
|
||||
os.Setenv("DOCKER_PASSWORD", key)
|
||||
os.Setenv("DOCKER_USERNAME", email)
|
||||
os.Setenv("DOCKER_EMAIL", email)
|
||||
|
||||
// invoke the base docker plugin binary
|
||||
cmd := exec.Command("drone-docker")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone-plugins/drone-docker"
|
||||
)
|
||||
|
||||
var build = "0" // build number set at compile-time
|
||||
@ -152,7 +154,7 @@ func main() {
|
||||
cli.StringFlag{
|
||||
Name: "docker.registry",
|
||||
Usage: "docker registry",
|
||||
Value: defaultRegistry,
|
||||
Value: "https://index.docker.io/v1/",
|
||||
EnvVar: "PLUGIN_REGISTRY,DOCKER_REGISTRY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
@ -178,15 +180,15 @@ func main() {
|
||||
}
|
||||
|
||||
func run(c *cli.Context) error {
|
||||
plugin := Plugin{
|
||||
plugin := docker.Plugin{
|
||||
Dryrun: c.Bool("dry-run"),
|
||||
Login: Login{
|
||||
Login: docker.Login{
|
||||
Registry: c.String("docker.registry"),
|
||||
Username: c.String("docker.username"),
|
||||
Password: c.String("docker.password"),
|
||||
Email: c.String("docker.email"),
|
||||
},
|
||||
Build: Build{
|
||||
Build: docker.Build{
|
||||
Remote: c.String("remote.url"),
|
||||
Name: c.String("commit.sha"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
@ -199,7 +201,7 @@ func run(c *cli.Context) error {
|
||||
Repo: c.String("repo"),
|
||||
LabelSchema: c.StringSlice("label-schema"),
|
||||
},
|
||||
Daemon: Daemon{
|
||||
Daemon: docker.Daemon{
|
||||
Registry: c.String("docker.registry"),
|
||||
Mirror: c.String("daemon.mirror"),
|
||||
StorageDriver: c.String("daemon.storage-driver"),
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package docker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -9,11 +9,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// default docker registry
|
||||
defaultRegistry = "https://index.docker.io/v1/"
|
||||
)
|
||||
|
||||
type (
|
||||
// Daemon defines Docker daemon parameters.
|
||||
Daemon struct {
|
6
docker/Dockerfile
Normal file
6
docker/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
||||
# docker build --rm -f docker/Dockerfile -t plugins/docker .
|
||||
|
||||
FROM docker:17.05.0-ce-dind
|
||||
|
||||
ADD release/linux/amd64/drone-docker /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]
|
1
docker/Dockerfile.arm
Normal file
1
docker/Dockerfile.arm
Normal file
@ -0,0 +1 @@
|
||||
# see https://github.com/docker-library/docker/issues/67
|
1
docker/Dockerfile.arm64
Normal file
1
docker/Dockerfile.arm64
Normal file
@ -0,0 +1 @@
|
||||
# see https://github.com/docker-library/docker/issues/67
|
1
docker/ecr/Dockerfile
Normal file
1
docker/ecr/Dockerfile
Normal file
@ -0,0 +1 @@
|
||||
FROM plugins/docker:latest
|
1
docker/ecr/Dockerfile.arm
Normal file
1
docker/ecr/Dockerfile.arm
Normal file
@ -0,0 +1 @@
|
||||
FROM plugins/docker:linux-arm
|
1
docker/ecr/Dockerfile.arm64
Normal file
1
docker/ecr/Dockerfile.arm64
Normal file
@ -0,0 +1 @@
|
||||
FROM plugins/docker:linux-arm64
|
6
docker/gcr/Dockerfile
Normal file
6
docker/gcr/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
||||
# docker build --rm -f docker/gcr/Dockerfile -t plugins/gcr .
|
||||
|
||||
FROM plugins/docker:latest
|
||||
|
||||
ADD release/linux/amd64/drone-docker-gcr /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker-gcr"]
|
4
docker/gcr/Dockerfile.arm
Normal file
4
docker/gcr/Dockerfile.arm
Normal file
@ -0,0 +1,4 @@
|
||||
FROM plugins/docker:linux-arm
|
||||
|
||||
ADD release/linux/arm64/drone-docker-gcr /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker-gcr"]
|
4
docker/gcr/Dockerfile.arm64
Normal file
4
docker/gcr/Dockerfile.arm64
Normal file
@ -0,0 +1,4 @@
|
||||
FROM plugins/docker:linux-arm64
|
||||
|
||||
ADD release/linux/arm64/drone-docker-gcr /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker-gcr"]
|
6
docker/heroku/Dockerfile
Normal file
6
docker/heroku/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
||||
# docker build --rm -f docker/heroku/Dockerfile -t plugins/heroku .
|
||||
|
||||
FROM plugins/docker:latest
|
||||
|
||||
ADD release/linux/amd64/drone-docker-heroku /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker-heroku"]
|
4
docker/heroku/Dockerfile.arm
Normal file
4
docker/heroku/Dockerfile.arm
Normal file
@ -0,0 +1,4 @@
|
||||
FROM plugins/docker:linux-arm
|
||||
|
||||
ADD release/linux/arm/drone-docker-heroku /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker-heroku"]
|
4
docker/heroku/Dockerfile.arm64
Normal file
4
docker/heroku/Dockerfile.arm64
Normal file
@ -0,0 +1,4 @@
|
||||
FROM plugins/docker:linux-arm64
|
||||
|
||||
ADD release/linux/arm64/drone-docker-heroku /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker-heroku"]
|
Loading…
Reference in New Issue
Block a user