forked from Ivasoft/drone-docker
Compare commits
4 Commits
master
...
chicken-eg
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0a0d2791f | ||
|
|
0ea1ad3bd9 | ||
|
|
dcc34d8341 | ||
|
|
5adfaf4742 |
50
.drone.jsonnet
Normal file
50
.drone.jsonnet
Normal file
@@ -0,0 +1,50 @@
|
||||
local pipeline = import 'pipeline.libsonnet';
|
||||
|
||||
[
|
||||
pipeline.test('linux', 'amd64'),
|
||||
|
||||
pipeline.build('docker', 'linux', 'amd64'),
|
||||
pipeline.build('docker', 'linux', 'arm64'),
|
||||
pipeline.build('docker', 'linux', 'arm'),
|
||||
pipeline.notifications('docker', depends_on=[
|
||||
'linux-amd64',
|
||||
'linux-arm64',
|
||||
'linux-arm',
|
||||
]),
|
||||
|
||||
pipeline.build('gcr', 'linux', 'amd64'),
|
||||
pipeline.build('gcr', 'linux', 'arm64'),
|
||||
pipeline.build('gcr', 'linux', 'arm'),
|
||||
pipeline.notifications('gcr', depends_on=[
|
||||
'linux-amd64',
|
||||
'linux-arm64',
|
||||
'linux-arm',
|
||||
]),
|
||||
|
||||
pipeline.build('acr', 'linux', 'amd64'),
|
||||
pipeline.build('acr', 'linux', 'arm64'),
|
||||
pipeline.build('acr', 'linux', 'arm'),
|
||||
pipeline.notifications('acr', depends_on=[
|
||||
'linux-amd64',
|
||||
'linux-arm64',
|
||||
'linux-arm',
|
||||
]),
|
||||
|
||||
pipeline.build('ecr', 'linux', 'amd64'),
|
||||
pipeline.build('ecr', 'linux', 'arm64'),
|
||||
pipeline.build('ecr', 'linux', 'arm'),
|
||||
pipeline.notifications('ecr', depends_on=[
|
||||
'linux-amd64',
|
||||
'linux-arm64',
|
||||
'linux-arm',
|
||||
]),
|
||||
|
||||
pipeline.build('heroku', 'linux', 'amd64'),
|
||||
pipeline.build('heroku', 'linux', 'arm64'),
|
||||
pipeline.build('heroku', 'linux', 'arm'),
|
||||
pipeline.notifications('heroku', depends_on=[
|
||||
'linux-amd64',
|
||||
'linux-arm64',
|
||||
'linux-arm',
|
||||
]),
|
||||
]
|
||||
150
.drone.yml
150
.drone.yml
@@ -1,47 +1,115 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: default
|
||||
type: vm
|
||||
name: testing
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
steps:
|
||||
- name: build-push
|
||||
image: golang:1.17
|
||||
commands:
|
||||
- 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker'
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- tag
|
||||
- name: vet
|
||||
image: golang:1.17.3
|
||||
commands:
|
||||
- go vet ./...
|
||||
environment:
|
||||
GO111MODULE: on
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: build-tag
|
||||
image: golang:1.17
|
||||
commands:
|
||||
- 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker'
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
- name: test
|
||||
image: golang:1.17.3
|
||||
commands:
|
||||
- go test -cover ./...
|
||||
environment:
|
||||
GO111MODULE: on
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: executable
|
||||
image: golang:1.17
|
||||
commands:
|
||||
- ./release/linux/amd64/drone-docker --help
|
||||
volumes:
|
||||
- name: gopath
|
||||
temp: {}
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker
|
||||
settings:
|
||||
registry: https://git.ivasoft.cz
|
||||
dockerfile: docker/docker/Dockerfile.linux.amd64
|
||||
username:
|
||||
from_secret: repo_user
|
||||
password:
|
||||
from_secret: repo_pass
|
||||
repo: git.ivasoft.cz/sw/drone-docker
|
||||
tags:
|
||||
- latest
|
||||
- ${DRONE_TAG:-latest}
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/tags/**"
|
||||
- "refs/pull/**"
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: windows-ltsc2022-docker
|
||||
|
||||
platform:
|
||||
os: windows
|
||||
|
||||
pool:
|
||||
use: windows-2022
|
||||
|
||||
steps:
|
||||
- name: executable
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker
|
||||
|
||||
- name: build_latest
|
||||
environment:
|
||||
VERSION: ltsc2022
|
||||
REGISTRY: docker
|
||||
USERNAME:
|
||||
from_secret: docker_username
|
||||
PASSWORD:
|
||||
from_secret: docker_password
|
||||
commands:
|
||||
- powershell.exe scripts/windows/latest.ps1
|
||||
when:
|
||||
event: [ push ]
|
||||
|
||||
- name: build_tag
|
||||
image: golang:1.18
|
||||
environment:
|
||||
VERSION: ltsc2022
|
||||
REGISTRY: docker
|
||||
USERNAME:
|
||||
from_secret: docker_username
|
||||
PASSWORD:
|
||||
from_secret: docker_password
|
||||
commands:
|
||||
- powershell.exe scripts/windows/tag.ps1
|
||||
when:
|
||||
event: [ tag ]
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: manifest-docker
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
steps:
|
||||
- name: manifest
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: true
|
||||
ignore_missing: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
spec: docker/docker/manifest.tmpl
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
depends_on:
|
||||
- windows-ltsc2022-docker
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,3 @@
|
||||
release
|
||||
coverage.out
|
||||
vendor
|
||||
.vscode/
|
||||
Dockerfile
|
||||
|
||||
16
CHANGELOG.md
16
CHANGELOG.md
@@ -1,17 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [v20.14.0](https://github.com/drone-plugins/drone-docker/tree/v20.14.0) (2022-11-17)
|
||||
|
||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.13.0...v20.14.0)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- Add support for docker --platform flag [\#376](https://github.com/drone-plugins/drone-docker/pull/376) ([tphoney](https://github.com/tphoney))
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- Use full path to docker when creating card [\#373](https://github.com/drone-plugins/drone-docker/pull/373) ([donny-dont](https://github.com/donny-dont))
|
||||
|
||||
## [v20.13.0](https://github.com/drone-plugins/drone-docker/tree/v20.13.0) (2022-06-08)
|
||||
|
||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.12.0...v20.13.0)
|
||||
@@ -20,10 +8,6 @@
|
||||
|
||||
- update docker linux amd64/arm64 to 20.10.14 [\#365](https://github.com/drone-plugins/drone-docker/pull/365) ([tphoney](https://github.com/tphoney))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- v20.13.0 prep [\#367](https://github.com/drone-plugins/drone-docker/pull/367) ([tphoney](https://github.com/tphoney))
|
||||
|
||||
## [v20.12.0](https://github.com/drone-plugins/drone-docker/tree/v20.12.0) (2022-05-16)
|
||||
|
||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.11.0...v20.12.0)
|
||||
|
||||
@@ -269,27 +269,6 @@ func main() {
|
||||
Usage: "card path location to write to",
|
||||
EnvVar: "DRONE_CARD_PATH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "platform",
|
||||
Usage: "platform value to pass to docker",
|
||||
EnvVar: "PLUGIN_PLATFORM",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "ssh-agent-key",
|
||||
Usage: "ssh agent key to use",
|
||||
EnvVar: "PLUGIN_SSH_AGENT_KEY",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "is-plugin",
|
||||
Usage: "build a plugin instead of a regular image",
|
||||
EnvVar: "PLUGIN_IS_PLUGIN",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "plugin-config",
|
||||
Usage: "path to the plugin config.json. Defaults to config.json",
|
||||
Value: "config.json",
|
||||
EnvVar: "PLUGIN_PLUGIN_CONFIG",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
@@ -310,33 +289,29 @@ func run(c *cli.Context) error {
|
||||
},
|
||||
CardPath: c.String("drone-card-path"),
|
||||
Build: docker.Build{
|
||||
Remote: c.String("remote.url"),
|
||||
Name: c.String("commit.sha"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
Args: c.StringSlice("args"),
|
||||
ArgsEnv: c.StringSlice("args-from-env"),
|
||||
Target: c.String("target"),
|
||||
Squash: c.Bool("squash"),
|
||||
Pull: c.BoolT("pull-image"),
|
||||
CacheFrom: c.StringSlice("cache-from"),
|
||||
Compress: c.Bool("compress"),
|
||||
Repo: c.String("repo"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
LabelSchema: c.StringSlice("label-schema"),
|
||||
AutoLabel: c.BoolT("auto-label"),
|
||||
Link: c.String("link"),
|
||||
NoCache: c.Bool("no-cache"),
|
||||
Secret: c.String("secret"),
|
||||
SecretEnvs: c.StringSlice("secrets-from-env"),
|
||||
SecretFiles: c.StringSlice("secrets-from-file"),
|
||||
AddHost: c.StringSlice("add-host"),
|
||||
Quiet: c.Bool("quiet"),
|
||||
Platform: c.String("platform"),
|
||||
SSHAgentKey: c.String("ssh-agent-key"),
|
||||
IsPlugin: c.Bool("is-plugin"),
|
||||
PluginConfig: c.String("plugin-config"),
|
||||
Remote: c.String("remote.url"),
|
||||
Name: c.String("commit.sha"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
Args: c.StringSlice("args"),
|
||||
ArgsEnv: c.StringSlice("args-from-env"),
|
||||
Target: c.String("target"),
|
||||
Squash: c.Bool("squash"),
|
||||
Pull: c.BoolT("pull-image"),
|
||||
CacheFrom: c.StringSlice("cache-from"),
|
||||
Compress: c.Bool("compress"),
|
||||
Repo: c.String("repo"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
LabelSchema: c.StringSlice("label-schema"),
|
||||
AutoLabel: c.BoolT("auto-label"),
|
||||
Link: c.String("link"),
|
||||
NoCache: c.Bool("no-cache"),
|
||||
Secret: c.String("secret"),
|
||||
SecretEnvs: c.StringSlice("secrets-from-env"),
|
||||
SecretFiles: c.StringSlice("secrets-from-file"),
|
||||
AddHost: c.StringSlice("add-host"),
|
||||
Quiet: c.Bool("quiet"),
|
||||
},
|
||||
Daemon: docker.Daemon{
|
||||
Registry: c.String("docker.registry"),
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package docker
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -18,8 +17,8 @@ func (p Plugin) startDaemon() {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
} else {
|
||||
cmd.Stdout = io.Discard
|
||||
cmd.Stderr = io.Discard
|
||||
cmd.Stdout = ioutil.Discard
|
||||
cmd.Stderr = ioutil.Discard
|
||||
}
|
||||
go func() {
|
||||
trace(cmd)
|
||||
|
||||
117
docker.go
117
docker.go
@@ -2,6 +2,7 @@ package docker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -39,34 +40,29 @@ type (
|
||||
|
||||
// Build defines Docker build parameters.
|
||||
Build struct {
|
||||
Remote string // Git remote URL
|
||||
Name string // Docker build using default named tag
|
||||
Dockerfile string // Docker build Dockerfile
|
||||
Context string // Docker build context
|
||||
Tags []string // Docker build tags
|
||||
Args []string // Docker build args
|
||||
ArgsEnv []string // Docker build args from env
|
||||
Target string // Docker build target
|
||||
Squash bool // Docker build squash
|
||||
Pull bool // Docker build pull
|
||||
CacheFrom []string // Docker build cache-from
|
||||
Compress bool // Docker build compress
|
||||
Repo string // Docker build repository
|
||||
LabelSchema []string // label-schema Label map
|
||||
AutoLabel bool // auto-label bool
|
||||
Labels []string // Label map
|
||||
Link string // Git repo link
|
||||
NoCache bool // Docker build no-cache
|
||||
Secret string // secret keypair
|
||||
SecretEnvs []string // Docker build secrets with env var as source
|
||||
SecretFiles []string // Docker build secrets with file as source
|
||||
AddHost []string // Docker build add-host
|
||||
Quiet bool // Docker build quiet
|
||||
Platform string // Docker build platform
|
||||
SSHAgentKey string // Docker build ssh agent key
|
||||
SSHKeyPath string // Docker build ssh key path
|
||||
IsPlugin bool // Build docker plugin instead of plain image
|
||||
PluginConfig string // Plugin config file path, defaults to config.json
|
||||
Remote string // Git remote URL
|
||||
Name string // Docker build using default named tag
|
||||
Dockerfile string // Docker build Dockerfile
|
||||
Context string // Docker build context
|
||||
Tags []string // Docker build tags
|
||||
Args []string // Docker build args
|
||||
ArgsEnv []string // Docker build args from env
|
||||
Target string // Docker build target
|
||||
Squash bool // Docker build squash
|
||||
Pull bool // Docker build pull
|
||||
CacheFrom []string // Docker build cache-from
|
||||
Compress bool // Docker build compress
|
||||
Repo string // Docker build repository
|
||||
LabelSchema []string // label-schema Label map
|
||||
AutoLabel bool // auto-label bool
|
||||
Labels []string // Label map
|
||||
Link string // Git repo link
|
||||
NoCache bool // Docker build no-cache
|
||||
Secret string // secret keypair
|
||||
SecretEnvs []string // Docker build secrets with env var as source
|
||||
SecretFiles []string // Docker build secrets with file as source
|
||||
AddHost []string // Docker build add-host
|
||||
Quiet bool // Docker build quiet
|
||||
}
|
||||
|
||||
// Plugin defines the Docker plugin parameters.
|
||||
@@ -109,7 +105,6 @@ type (
|
||||
|
||||
// Exec executes the plugin step
|
||||
func (p Plugin) Exec() error {
|
||||
|
||||
// start the Docker daemon server
|
||||
if !p.Daemon.Disabled {
|
||||
p.startDaemon()
|
||||
@@ -148,7 +143,7 @@ func (p Plugin) Exec() error {
|
||||
os.MkdirAll(dockerHome, 0600)
|
||||
|
||||
path := filepath.Join(dockerHome, "config.json")
|
||||
err := os.WriteFile(path, []byte(p.Login.Config), 0600)
|
||||
err := ioutil.WriteFile(path, []byte(p.Login.Config), 0600)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error writing config.json: %s", err)
|
||||
}
|
||||
@@ -183,41 +178,14 @@ func (p Plugin) Exec() error {
|
||||
cmds = append(cmds, commandPull(img))
|
||||
}
|
||||
|
||||
// setup for using ssh agent (https://docs.docker.com/develop/develop-images/build_enhancements/#using-ssh-to-access-private-data-in-builds)
|
||||
if p.Build.SSHAgentKey != "" {
|
||||
var sshErr error
|
||||
p.Build.SSHKeyPath, sshErr = writeSSHPrivateKey(p.Build.SSHAgentKey)
|
||||
if sshErr != nil {
|
||||
return sshErr
|
||||
}
|
||||
}
|
||||
|
||||
cmds = append(cmds, commandBuild(p.Build)) // docker build
|
||||
|
||||
if p.Build.IsPlugin {
|
||||
cmds = append(cmds, exec.Command("mkdir", "-p", "plugin/rootfs"))
|
||||
cmds = append(cmds, exec.Command(dockerExe, "create", "--name", "tmp", p.Build.Name))
|
||||
cmds = append(cmds, exec.Command(dockerExe, "export", "-o", "tmp.tar", "tmp"))
|
||||
cmds = append(cmds, exec.Command(dockerExe, "rm", "tmp"))
|
||||
cmds = append(cmds, exec.Command(dockerExe, "image", "rm", p.Build.Name))
|
||||
cmds = append(cmds, exec.Command("tar", "x", "-C", "plugin/rootfs", "-f", "tmp.tar"))
|
||||
cmds = append(cmds, exec.Command("cp", p.Build.PluginConfig, "plugin/config.json"))
|
||||
}
|
||||
|
||||
for _, tag := range p.Build.Tags {
|
||||
if !p.Build.IsPlugin {
|
||||
cmds = append(cmds, commandTag(p.Build, tag)) // docker tag
|
||||
} else {
|
||||
cmds = append(cmds, exec.Command(dockerExe, "plugin", "create", p.Build.Repo+":"+tag, "plugin"))
|
||||
}
|
||||
cmds = append(cmds, commandTag(p.Build, tag)) // docker tag
|
||||
|
||||
if !p.Dryrun {
|
||||
cmds = append(cmds, commandPush(p.Build, tag)) // docker push
|
||||
}
|
||||
|
||||
if p.Build.IsPlugin {
|
||||
cmds = append(cmds, exec.Command(dockerExe, "plugin", "rm", p.Build.Repo+":"+tag))
|
||||
}
|
||||
}
|
||||
|
||||
// execute all commands in batch mode.
|
||||
@@ -356,12 +324,6 @@ func commandBuild(build Build) *exec.Cmd {
|
||||
if build.Quiet {
|
||||
args = append(args, "--quiet")
|
||||
}
|
||||
if build.Platform != "" {
|
||||
args = append(args, "--platform", build.Platform)
|
||||
}
|
||||
if build.SSHKeyPath != "" {
|
||||
args = append(args, "--ssh", build.SSHKeyPath)
|
||||
}
|
||||
|
||||
if build.AutoLabel {
|
||||
labelSchema := []string{
|
||||
@@ -387,8 +349,8 @@ func commandBuild(build Build) *exec.Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
// we need to enable buildkit, for secret support and ssh agent support
|
||||
if build.Secret != "" || len(build.SecretEnvs) > 0 || len(build.SecretFiles) > 0 || build.SSHAgentKey != "" {
|
||||
// we need to enable buildkit, for secret support
|
||||
if build.Secret != "" || len(build.SecretEnvs) > 0 || len(build.SecretFiles) > 0 {
|
||||
os.Setenv("DOCKER_BUILDKIT", "1")
|
||||
}
|
||||
return exec.Command(dockerExe, args...)
|
||||
@@ -479,11 +441,7 @@ func commandTag(build Build, tag string) *exec.Cmd {
|
||||
// helper function to create the docker push command.
|
||||
func commandPush(build Build, tag string) *exec.Cmd {
|
||||
target := fmt.Sprintf("%s:%s", build.Repo, tag)
|
||||
if build.IsPlugin {
|
||||
return exec.Command(dockerExe, "plugin", "push", target)
|
||||
} else {
|
||||
return exec.Command(dockerExe, "push", target)
|
||||
}
|
||||
return exec.Command(dockerExe, "push", target)
|
||||
}
|
||||
|
||||
// helper function to create the docker daemon command.
|
||||
@@ -545,23 +503,6 @@ func commandRmi(tag string) *exec.Cmd {
|
||||
return exec.Command(dockerExe, "rmi", tag)
|
||||
}
|
||||
|
||||
func writeSSHPrivateKey(key string) (path string, err error) {
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to determine home directory: %s", err)
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Join(home, ".ssh"), 0700); err != nil {
|
||||
return "", fmt.Errorf("unable to create .ssh directory: %s", err)
|
||||
}
|
||||
pathToKey := filepath.Join(home, ".ssh", "id_rsa")
|
||||
if err := os.WriteFile(pathToKey, []byte(key), 0400); err != nil {
|
||||
return "", fmt.Errorf("unable to write ssh key %s: %s", pathToKey, err)
|
||||
}
|
||||
path = fmt.Sprintf("default=%s", pathToKey)
|
||||
|
||||
return path, nil
|
||||
}
|
||||
|
||||
// trace writes each command to stdout with the command wrapped in an xml
|
||||
// tag so that it can be extracted and displayed in the logs.
|
||||
func trace(cmd *exec.Cmd) {
|
||||
|
||||
4
docker/acr/Dockerfile.linux.arm
Normal file
4
docker/acr/Dockerfile.linux.arm
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM plugins/docker:linux-arm
|
||||
|
||||
ADD release/linux/arm/drone-acr /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-acr"]
|
||||
@@ -1,5 +1,5 @@
|
||||
# escape=`
|
||||
FROM plugins/docker:windows-ltsc2022-amd64
|
||||
FROM plugins/docker:windows-1803-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone ACR" `
|
||||
10
docker/acr/Dockerfile.windows.amd64.1909
Normal file
10
docker/acr/Dockerfile.windows.amd64.1909
Normal file
@@ -0,0 +1,10 @@
|
||||
# escape=`
|
||||
FROM plugins/docker:windows-1909-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone ACR" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-acr.exe C:/bin/drone-acr.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-acr.exe" ]
|
||||
@@ -17,6 +17,18 @@ manifests:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
-
|
||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
variant: v7
|
||||
-
|
||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1803
|
||||
-
|
||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||
platform:
|
||||
@@ -24,8 +36,14 @@ manifests:
|
||||
os: windows
|
||||
version: 1809
|
||||
-
|
||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
|
||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: ltsc2022
|
||||
version: 1903
|
||||
-
|
||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1909
|
||||
|
||||
15
docker/docker/Dockerfile.linux.arm
Normal file
15
docker/docker/Dockerfile.linux.arm
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM arm32v6/docker:19.03.8-dind
|
||||
|
||||
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
||||
|
||||
RUN apk --update add --virtual .build-deps curl && \
|
||||
mkdir -p /etc/docker/ && \
|
||||
curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/19.03/profiles/seccomp/default.json && \
|
||||
sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \
|
||||
chmod 600 /etc/docker/default.json && \
|
||||
apk del .build-deps && \
|
||||
rm -rf /var/cache/apk/* && \
|
||||
rm -rf /tmp/*
|
||||
|
||||
ADD release/linux/arm/drone-docker /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]
|
||||
26
docker/docker/Dockerfile.windows.amd64.1803
Normal file
26
docker/docker/Dockerfile.windows.amd64.1803
Normal file
@@ -0,0 +1,26 @@
|
||||
# escape=`
|
||||
FROM mcr.microsoft.com/windows/servercore:1803 as download
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
ENV DOCKER_VERSION 18.09.1
|
||||
|
||||
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.6-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
|
||||
Expand-Archive innoextract.zip -DestinationPath C:\ ; `
|
||||
Remove-Item -Path innoextract.zip
|
||||
|
||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||
Invoke-WebRequest $('https://github.com/docker/toolbox/releases/download/v{0}/DockerToolbox-{0}.exe' -f $env:DOCKER_VERSION) -OutFile 'dockertoolbox.exe' -UseBasicParsing
|
||||
RUN /innoextract.exe dockertoolbox.exe
|
||||
|
||||
FROM plugins/base:windows-1803
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Docker" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
COPY --from=download /windows/system32/netapi32.dll /windows/system32/netapi32.dll
|
||||
COPY --from=download /app/docker.exe C:/bin/docker.exe
|
||||
ADD release/windows/amd64/drone-docker.exe C:/bin/drone-docker.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-docker.exe" ]
|
||||
@@ -1,10 +1,9 @@
|
||||
# escape=`
|
||||
# using 1809-KB5021237-amd64 as base image, 1809-KB5022286-amd64 does not work
|
||||
FROM mcr.microsoft.com/windows/servercore:1809-KB5021237 as download
|
||||
FROM mcr.microsoft.com/windows/servercore:1809 as download
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
ENV DOCKER_VERSION 19.03.1
|
||||
ENV DOCKER_VERSION 18.09.1
|
||||
|
||||
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.6-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
|
||||
Expand-Archive innoextract.zip -DestinationPath C:\ ; `
|
||||
@@ -14,8 +13,7 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl
|
||||
Invoke-WebRequest $('https://github.com/docker/toolbox/releases/download/v{0}/DockerToolbox-{0}.exe' -f $env:DOCKER_VERSION) -OutFile 'dockertoolbox.exe' -UseBasicParsing
|
||||
RUN /innoextract.exe dockertoolbox.exe
|
||||
|
||||
FROM mcr.microsoft.com/windows/nanoserver:1809-KB5021237-amd64
|
||||
|
||||
FROM mcr.microsoft.com/windows/nanoserver:1809
|
||||
USER ContainerAdministrator
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
@@ -23,7 +21,6 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
RUN mkdir C:\bin
|
||||
COPY --from=download /windows/system32/netapi32.dll /windows/system32/netapi32.dll
|
||||
COPY --from=download /app/docker.exe C:/bin/docker.exe
|
||||
ADD release/windows/amd64/drone-docker.exe C:/bin/drone-docker.exe
|
||||
|
||||
28
docker/docker/Dockerfile.windows.amd64.1903
Normal file
28
docker/docker/Dockerfile.windows.amd64.1903
Normal file
@@ -0,0 +1,28 @@
|
||||
# escape=`
|
||||
FROM mcr.microsoft.com/windows/servercore:1903 as download
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
ENV DOCKER_VERSION 19.03.1
|
||||
|
||||
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.7-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
|
||||
Expand-Archive innoextract.zip -DestinationPath C:\ ; `
|
||||
Remove-Item -Path innoextract.zip
|
||||
|
||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||
Invoke-WebRequest $('https://github.com/docker/toolbox/releases/download/v{0}/DockerToolbox-{0}.exe' -f $env:DOCKER_VERSION) -OutFile 'dockertoolbox.exe' -UseBasicParsing
|
||||
RUN /innoextract.exe dockertoolbox.exe
|
||||
|
||||
FROM mcr.microsoft.com/windows/nanoserver:1903
|
||||
USER ContainerAdministrator
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Docker" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
RUN mkdir C:\bin
|
||||
COPY --from=download /windows/system32/netapi32.dll /windows/system32/netapi32.dll
|
||||
COPY --from=download /app/docker.exe C:/bin/docker.exe
|
||||
ADD release/windows/amd64/drone-docker.exe C:/bin/drone-docker.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-docker.exe" ]
|
||||
28
docker/docker/Dockerfile.windows.amd64.1909
Normal file
28
docker/docker/Dockerfile.windows.amd64.1909
Normal file
@@ -0,0 +1,28 @@
|
||||
# escape=`
|
||||
FROM mcr.microsoft.com/windows/servercore:1909 as download
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
ENV DOCKER_VERSION 19.03.1
|
||||
|
||||
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.7-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
|
||||
Expand-Archive innoextract.zip -DestinationPath C:\ ; `
|
||||
Remove-Item -Path innoextract.zip
|
||||
|
||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||
Invoke-WebRequest $('https://github.com/docker/toolbox/releases/download/v{0}/DockerToolbox-{0}.exe' -f $env:DOCKER_VERSION) -OutFile 'dockertoolbox.exe' -UseBasicParsing
|
||||
RUN /innoextract.exe dockertoolbox.exe
|
||||
|
||||
FROM mcr.microsoft.com/windows/nanoserver:1909
|
||||
USER ContainerAdministrator
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Docker" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
RUN mkdir C:\bin
|
||||
COPY --from=download /windows/system32/netapi32.dll /windows/system32/netapi32.dll
|
||||
COPY --from=download /app/docker.exe C:/bin/docker.exe
|
||||
ADD release/windows/amd64/drone-docker.exe C:/bin/drone-docker.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-docker.exe" ]
|
||||
@@ -17,6 +17,18 @@ manifests:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
-
|
||||
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
variant: v7
|
||||
-
|
||||
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1803
|
||||
-
|
||||
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||
platform:
|
||||
@@ -24,8 +36,14 @@ manifests:
|
||||
os: windows
|
||||
version: 1809
|
||||
-
|
||||
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
|
||||
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: ltsc2022
|
||||
version: 1903
|
||||
-
|
||||
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1909
|
||||
|
||||
4
docker/ecr/Dockerfile.linux.arm
Normal file
4
docker/ecr/Dockerfile.linux.arm
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM plugins/docker:linux-arm
|
||||
|
||||
ADD release/linux/arm/drone-ecr /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-ecr"]
|
||||
@@ -1,5 +1,5 @@
|
||||
# escape=`
|
||||
FROM plugins/docker:windows-ltsc2022-amd64
|
||||
FROM plugins/docker:windows-1803-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone ECR" `
|
||||
10
docker/ecr/Dockerfile.windows.amd64.1909
Normal file
10
docker/ecr/Dockerfile.windows.amd64.1909
Normal file
@@ -0,0 +1,10 @@
|
||||
# escape=`
|
||||
FROM plugins/docker:windows-1909-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone ECR" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-ecr.exe C:/bin/drone-ecr.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-ecr.exe" ]
|
||||
@@ -17,6 +17,18 @@ manifests:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
-
|
||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
variant: v7
|
||||
-
|
||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1803
|
||||
-
|
||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||
platform:
|
||||
@@ -24,8 +36,14 @@ manifests:
|
||||
os: windows
|
||||
version: 1809
|
||||
-
|
||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
|
||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: ltsc2022
|
||||
version: 1903
|
||||
-
|
||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1909
|
||||
|
||||
4
docker/gcr/Dockerfile.linux.arm
Normal file
4
docker/gcr/Dockerfile.linux.arm
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM plugins/docker:linux-arm
|
||||
|
||||
ADD release/linux/arm/drone-gcr /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-gcr"]
|
||||
@@ -1,5 +1,5 @@
|
||||
# escape=`
|
||||
FROM plugins/docker:windows-ltsc2022-amd64
|
||||
FROM plugins/docker:windows-1803-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone GCR" `
|
||||
10
docker/gcr/Dockerfile.windows.amd64.1909
Normal file
10
docker/gcr/Dockerfile.windows.amd64.1909
Normal file
@@ -0,0 +1,10 @@
|
||||
# escape=`
|
||||
FROM plugins/docker:windows-1909-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone GCR" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-gcr.exe C:/bin/drone-gcr.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-gcr.exe" ]
|
||||
@@ -17,6 +17,18 @@ manifests:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
-
|
||||
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
variant: v7
|
||||
-
|
||||
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1803
|
||||
-
|
||||
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||
platform:
|
||||
@@ -24,8 +36,8 @@ manifests:
|
||||
os: windows
|
||||
version: 1809
|
||||
-
|
||||
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
|
||||
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: ltsc2022
|
||||
version: 1909
|
||||
|
||||
4
docker/heroku/Dockerfile.linux.arm
Normal file
4
docker/heroku/Dockerfile.linux.arm
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM plugins/docker:linux-arm
|
||||
|
||||
ADD release/linux/arm/drone-heroku /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-heroku"]
|
||||
@@ -17,3 +17,9 @@ manifests:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
-
|
||||
image: plugins/heroku:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
variant: v7
|
||||
|
||||
@@ -114,47 +114,6 @@ func TestCommandBuild(t *testing.T) {
|
||||
".",
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "platform argument",
|
||||
build: Build{
|
||||
Name: "plugins/drone-docker:latest",
|
||||
Dockerfile: "Dockerfile",
|
||||
Context: ".",
|
||||
Platform: "test/platform",
|
||||
},
|
||||
want: exec.Command(
|
||||
dockerExe,
|
||||
"build",
|
||||
"--rm=true",
|
||||
"-f",
|
||||
"Dockerfile",
|
||||
"-t",
|
||||
"plugins/drone-docker:latest",
|
||||
".",
|
||||
"--platform",
|
||||
"test/platform",
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "ssh agent",
|
||||
build: Build{
|
||||
Name: "plugins/drone-docker:latest",
|
||||
Dockerfile: "Dockerfile",
|
||||
Context: ".",
|
||||
SSHKeyPath: "id_rsa=/root/.ssh/id_rsa",
|
||||
},
|
||||
want: exec.Command(
|
||||
dockerExe,
|
||||
"build",
|
||||
"--rm=true",
|
||||
"-f",
|
||||
"Dockerfile",
|
||||
"-t",
|
||||
"plugins/drone-docker:latest",
|
||||
".",
|
||||
"--ssh id_rsa=/root/.ssh/id_rsa",
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
|
||||
206
pipeline.libsonnet
Normal file
206
pipeline.libsonnet
Normal file
@@ -0,0 +1,206 @@
|
||||
local windows_pipe = '\\\\\\\\.\\\\pipe\\\\docker_engine';
|
||||
local windows_pipe_volume = 'docker_pipe';
|
||||
local test_pipeline_name = 'testing';
|
||||
|
||||
local windows(os) = os == 'windows';
|
||||
|
||||
local golang_image(os, version) =
|
||||
'golang:' + '1.13' + if windows(os) then '-windowsservercore-' + version else '';
|
||||
|
||||
{
|
||||
test(os='linux', arch='amd64', version='')::
|
||||
local is_windows = windows(os);
|
||||
local golang = golang_image(os, version);
|
||||
local volumes = if is_windows then [{name: 'gopath', path: 'C:\\\\gopath'}] else [{name: 'gopath', path: '/go',}];
|
||||
{
|
||||
kind: 'pipeline',
|
||||
name: test_pipeline_name,
|
||||
platform: {
|
||||
os: os,
|
||||
arch: arch,
|
||||
version: if std.length(version) > 0 then version,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'vet',
|
||||
image: golang,
|
||||
pull: 'always',
|
||||
environment: {
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'go vet ./...',
|
||||
],
|
||||
volumes: volumes,
|
||||
},
|
||||
{
|
||||
name: 'test',
|
||||
image: golang,
|
||||
pull: 'always',
|
||||
environment: {
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'go test -cover ./...',
|
||||
],
|
||||
volumes: volumes,
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
ref: [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
'refs/pull/**',
|
||||
],
|
||||
},
|
||||
volumes: [{name: 'gopath', temp: {}}]
|
||||
},
|
||||
|
||||
build(name, os='linux', arch='amd64', version='')::
|
||||
local is_windows = windows(os);
|
||||
local tag = if is_windows then os + '-' + version else os + '-' + arch;
|
||||
local file_suffix = std.strReplace(tag, '-', '.');
|
||||
local volumes = if is_windows then [{ name: windows_pipe_volume, path: windows_pipe }] else [];
|
||||
local golang = golang_image(os, version);
|
||||
local plugin_repo = 'plugins/' + name;
|
||||
local extension = if is_windows then '.exe' else '';
|
||||
local depends_on = if name == 'docker' then [test_pipeline_name] else [tag + '-docker'];
|
||||
{
|
||||
kind: 'pipeline',
|
||||
name: tag + '-' + name,
|
||||
platform: {
|
||||
os: os,
|
||||
arch: arch,
|
||||
version: if std.length(version) > 0 then version,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'build-push',
|
||||
image: golang,
|
||||
pull: 'always',
|
||||
environment: {
|
||||
CGO_ENABLED: '0',
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/' + os + '/' + arch + '/drone-' + name + extension + ' ./cmd/drone-' + name,
|
||||
],
|
||||
when: {
|
||||
event: {
|
||||
exclude: ['tag'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'build-tag',
|
||||
image: golang,
|
||||
pull: 'always',
|
||||
environment: {
|
||||
CGO_ENABLED: '0',
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/' + os + '/' + arch + '/drone-' + name + extension + ' ./cmd/drone-' + name,
|
||||
],
|
||||
when: {
|
||||
event: ['tag'],
|
||||
},
|
||||
},
|
||||
if name == "docker" then {
|
||||
name: 'executable',
|
||||
image: golang,
|
||||
pull: 'always',
|
||||
commands: [
|
||||
'./release/' + os + '/' + arch + '/drone-' + name + extension + ' --help',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'dryrun',
|
||||
image: 'plugins/docker:' + tag,
|
||||
pull: 'always',
|
||||
settings: {
|
||||
dry_run: true,
|
||||
tags: tag,
|
||||
dockerfile: 'docker/'+ name +'/Dockerfile.' + file_suffix,
|
||||
daemon_off: if is_windows then 'true' else 'false',
|
||||
repo: plugin_repo,
|
||||
username: { from_secret: 'docker_username' },
|
||||
password: { from_secret: 'docker_password' },
|
||||
},
|
||||
volumes: if std.length(volumes) > 0 then volumes,
|
||||
when: {
|
||||
event: ['pull_request'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'publish',
|
||||
image: 'plugins/docker:' + tag,
|
||||
pull: 'always',
|
||||
settings: {
|
||||
auto_tag: true,
|
||||
auto_tag_suffix: tag,
|
||||
daemon_off: if is_windows then 'true' else 'false',
|
||||
dockerfile: 'docker/' + name + '/Dockerfile.' + file_suffix,
|
||||
repo: plugin_repo,
|
||||
username: { from_secret: 'docker_username' },
|
||||
password: { from_secret: 'docker_password' },
|
||||
},
|
||||
volumes: if std.length(volumes) > 0 then volumes,
|
||||
when: {
|
||||
event: {
|
||||
exclude: ['pull_request'],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
ref: [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
'refs/pull/**',
|
||||
],
|
||||
},
|
||||
depends_on: depends_on,
|
||||
volumes: if is_windows then [{ name: windows_pipe_volume, host: { path: windows_pipe } }],
|
||||
},
|
||||
|
||||
notifications(name, os='linux', arch='amd64', version='', depends_on=[])::
|
||||
{
|
||||
kind: 'pipeline',
|
||||
name: 'notifications-' + name,
|
||||
platform: {
|
||||
os: os,
|
||||
arch: arch,
|
||||
version: if std.length(version) > 0 then version,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'manifest',
|
||||
image: 'plugins/manifest',
|
||||
pull: 'always',
|
||||
settings: {
|
||||
username: { from_secret: 'docker_username' },
|
||||
password: { from_secret: 'docker_password' },
|
||||
spec: 'docker/' + name + '/manifest.tmpl',
|
||||
ignore_missing: true,
|
||||
auto_tag: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'microbadger',
|
||||
image: 'plugins/webhook',
|
||||
pull: 'always',
|
||||
settings: {
|
||||
urls: { from_secret: 'microbadger_' + name },
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: [x + '-' + name for x in depends_on],
|
||||
trigger: {
|
||||
ref: [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -20,8 +20,8 @@ echo $env:VERSION
|
||||
echo $env:REGISTRY
|
||||
|
||||
# build the binary
|
||||
Write-Host "+ 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}
|
||||
#Write-Host "+ 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
|
||||
docker login -u ${env:USERNAME} -p ${env:PASSWORD}
|
||||
|
||||
Reference in New Issue
Block a user