Skip to content

Commit 9e8d0d4

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 75920a5 + 0dd3da2 commit 9e8d0d4

27 files changed

+443
-64
lines changed

.drone.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ steps:
7878
- refs/heads/master
7979
- refs/tags/*
8080

81+
- name: publish_ppc64le
82+
image: plugins/docker
83+
pull: if-not-exists
84+
settings:
85+
repo: drone/drone-runner-docker
86+
auto_tag: true
87+
auto_tag_suffix: linux-ppc64le
88+
dockerfile: docker/Dockerfile.linux.ppc64le
89+
username:
90+
from_secret: docker_username
91+
password:
92+
from_secret: docker_password
93+
when:
94+
ref:
95+
- refs/heads/master
96+
- refs/tags/*
97+
8198
volumes:
8299
- name: go
83100
temp: {}

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
22
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
33

4-
## Unreleased
4+
## 1.6.3
5+
### Fixed
6+
- use path prefix when evaluating restricted volume mounts. See [#ea74fa2](https://github.com/drone-runners/drone-runner-docker/commit/ea74fa2ba442eacb0812ad5983c305a16b6763bc).
7+
8+
## 1.6.2
9+
### Added
10+
- support for self-hosted tmate instances
11+
12+
## 1.6.1
13+
### Changed
14+
- restrict temporary volumes used with docker plugins
15+
- restrict environment variables used with docker plugins
16+
17+
## 1.6.0
18+
### Added
19+
- experimental support for remote debugging with tmate, disabled by default
20+
521
### Fixed
622
- exit code 78 not properly exiting early when pipeline has services (from runner-go)
723

command/command.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func Command() {
2525
app := kingpin.New("drone", "drone docker runner")
2626
registerCompile(app)
2727
registerExec(app)
28+
registerCopy(app)
2829
daemon.Register(app)
2930

3031
kingpin.Version(version)

command/compile.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type compileCommand struct {
3737
Labels map[string]string
3838
Secrets map[string]string
3939
Resources compiler.Resources
40+
Tmate compiler.Tmate
4041
Clone bool
4142
Config string
4243
}
@@ -101,6 +102,7 @@ func (c *compileCommand) run(*kingpin.ParseContext) error {
101102
Environ: provider.Static(c.Environ),
102103
Labels: c.Labels,
103104
Resources: c.Resources,
105+
Tmate: c.Tmate,
104106
Privileged: append(c.Privileged, compiler.Privileged...),
105107
Networks: c.Networks,
106108
Volumes: c.Volumes,
@@ -125,6 +127,7 @@ func (c *compileCommand) run(*kingpin.ParseContext) error {
125127
Repo: c.Repo,
126128
Stage: c.Stage,
127129
System: c.System,
130+
Secret: secret.StaticVars(c.Secrets),
128131
}
129132
spec := comp.Compile(nocontext, args)
130133

@@ -192,6 +195,28 @@ func registerCompile(app *kingpin.Application) {
192195
cmd.Flag("docker-config", "path to the docker config file").
193196
StringVar(&c.Config)
194197

198+
cmd.Flag("tmate-image", "tmate docker image").
199+
Default("drone/drone-runner-docker:1").
200+
StringVar(&c.Tmate.Image)
201+
202+
cmd.Flag("tmate-enabled", "tmate enabled").
203+
BoolVar(&c.Tmate.Enabled)
204+
205+
cmd.Flag("tmate-server-host", "tmate server host").
206+
StringVar(&c.Tmate.Server)
207+
208+
cmd.Flag("tmate-server-port", "tmate server port").
209+
StringVar(&c.Tmate.Port)
210+
211+
cmd.Flag("tmate-server-rsa-fingerprint", "tmate server rsa fingerprint").
212+
StringVar(&c.Tmate.RSA)
213+
214+
cmd.Flag("tmate-server-ed25519-fingerprint", "tmate server rsa fingerprint").
215+
StringVar(&c.Tmate.ED25519)
216+
217+
cmd.Flag("tmate-authorized-keys", "tmate authorized keys").
218+
StringVar(&c.Tmate.AuthorizedKeys)
219+
195220
// shared pipeline flags
196221
c.Flags = internal.ParseFlags(cmd)
197222
}

command/copy.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright 2019 Drone.IO Inc. All rights reserved.
2+
// Use of this source code is governed by the Polyform License
3+
// that can be found in the LICENSE file.
4+
5+
package command
6+
7+
import (
8+
"io"
9+
"os"
10+
11+
"gopkg.in/alecthomas/kingpin.v2"
12+
)
13+
14+
type copyCommand struct {
15+
source string
16+
target string
17+
}
18+
19+
func (c *copyCommand) run(*kingpin.ParseContext) error {
20+
return Copy(c.source, c.target)
21+
}
22+
23+
func Copy(src, dst string) error {
24+
in, err := os.Open(src)
25+
if err != nil {
26+
return err
27+
}
28+
defer in.Close()
29+
30+
out, err := os.Create(dst)
31+
if err != nil {
32+
return err
33+
}
34+
defer out.Close()
35+
36+
_, err = io.Copy(out, in)
37+
if err != nil {
38+
return err
39+
}
40+
41+
err = out.Sync()
42+
if err != nil {
43+
return err
44+
}
45+
46+
info, err := os.Stat(src)
47+
if err != nil {
48+
return err
49+
}
50+
51+
err = os.Chmod(dst, info.Mode())
52+
if err != nil {
53+
return err
54+
}
55+
56+
return out.Close()
57+
}
58+
59+
// Register registers the copy command.
60+
func registerCopy(app *kingpin.Application) {
61+
c := new(copyCommand)
62+
63+
cmd := app.Command("copy", "entrypoint copy").
64+
Hidden().
65+
Action(c.run)
66+
67+
cmd.Flag("source", "source binary path").
68+
Default("/bin/tmate").
69+
StringVar(&c.source)
70+
71+
cmd.Flag("target", "target binary path").
72+
Default("/usr/drone/bin/tmate").
73+
StringVar(&c.target)
74+
}

command/daemon/config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ type Config struct {
106106
Config string `envconfig:"DRONE_DOCKER_CONFIG"`
107107
Stream bool `envconfig:"DRONE_DOCKER_STREAM_PULL" default:"true"`
108108
}
109+
110+
Tmate struct {
111+
Enabled bool `envconfig:"DRONE_TMATE_ENABLED" default:"false"`
112+
Image string `envconfig:"DRONE_TMATE_IMAGE" default:"drone/drone-runner-docker:1"`
113+
Server string `envconfig:"DRONE_TMATE_HOST"`
114+
Port string `envconfig:"DRONE_TMATE_PORT"`
115+
RSA string `envconfig:"DRONE_TMATE_FINGERPRINT_RSA"`
116+
ED25519 string `envconfig:"DRONE_TMATE_FINGERPRINT_ED25519"`
117+
AuthorizedKeys string `envconfig:"DRONE_TMATE_AUTHORIZED_KEYS"`
118+
}
109119
}
110120

111121
// legacy environment variables. the key is the legacy

command/daemon/daemon.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
141141
CPUSet: config.Resources.CPUSet,
142142
ShmSize: config.Resources.ShmSize,
143143
},
144+
Tmate: compiler.Tmate{
145+
Image: config.Tmate.Image,
146+
Enabled: config.Tmate.Enabled,
147+
Server: config.Tmate.Server,
148+
Port: config.Tmate.Port,
149+
RSA: config.Tmate.RSA,
150+
ED25519: config.Tmate.ED25519,
151+
AuthorizedKeys: config.Tmate.AuthorizedKeys,
152+
},
144153
Environ: provider.Combine(
145154
provider.Static(config.Runner.Environ),
146155
provider.External(

command/exec.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type execCommand struct {
4949
Labels map[string]string
5050
Secrets map[string]string
5151
Resources compiler.Resources
52+
Tmate compiler.Tmate
5253
Clone bool
5354
Config string
5455
Pretty bool
@@ -120,6 +121,7 @@ func (c *execCommand) run(*kingpin.ParseContext) error {
120121
Environ: provider.Static(c.Environ),
121122
Labels: c.Labels,
122123
Resources: c.Resources,
124+
Tmate: c.Tmate,
123125
Privileged: append(c.Privileged, compiler.Privileged...),
124126
Networks: c.Networks,
125127
Volumes: c.Volumes,
@@ -327,6 +329,28 @@ func registerExec(app *kingpin.Application) {
327329
cmd.Flag("docker-config", "path to the docker config file").
328330
StringVar(&c.Config)
329331

332+
cmd.Flag("tmate-image", "tmate docker image").
333+
Default("drone/drone-runner-docker:1").
334+
StringVar(&c.Tmate.Image)
335+
336+
cmd.Flag("tmate-enabled", "tmate enabled").
337+
BoolVar(&c.Tmate.Enabled)
338+
339+
cmd.Flag("tmate-server-host", "tmate server host").
340+
StringVar(&c.Tmate.Server)
341+
342+
cmd.Flag("tmate-server-port", "tmate server port").
343+
StringVar(&c.Tmate.Port)
344+
345+
cmd.Flag("tmate-server-rsa-fingerprint", "tmate server rsa fingerprint").
346+
StringVar(&c.Tmate.RSA)
347+
348+
cmd.Flag("tmate-server-ed25519-fingerprint", "tmate server rsa fingerprint").
349+
StringVar(&c.Tmate.ED25519)
350+
351+
cmd.Flag("tmate-authorized-keys", "tmate authorized keys").
352+
StringVar(&c.Tmate.AuthorizedKeys)
353+
330354
cmd.Flag("debug", "enable debug logging").
331355
BoolVar(&c.Debug)
332356

command/internal/flags.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func ParseFlags(cmd *kingpin.CmdClause) *Flags {
5959
cmd.Flag("build-action", "build action").Default("").StringVar(&f.Build.Action)
6060
cmd.Flag("build-cron", "build cron trigger").Default("").StringVar(&f.Build.Cron)
6161
cmd.Flag("build-target", "build deploy target").Default("").StringVar(&f.Build.Deploy)
62+
cmd.Flag("build-debug", "build debug").Default("false").BoolVar(&f.Build.Debug)
6263
cmd.Flag("build-created", "build created").Default(now).Int64Var(&f.Build.Created)
6364
cmd.Flag("build-updated", "build updated").Default(now).Int64Var(&f.Build.Updated)
6465

docker/Dockerfile.linux.amd64

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
FROM alpine:3.6 as alpine
1+
FROM alpine:3 as alpine
22
RUN apk add -U --no-cache ca-certificates
33

4-
FROM alpine:3.6
4+
RUN wget https://github.com/tmate-io/tmate/releases/download/2.4.0/tmate-2.4.0-static-linux-amd64.tar.xz
5+
RUN tar -xf tmate-2.4.0-static-linux-amd64.tar.xz
6+
RUN mv tmate-2.4.0-static-linux-amd64/tmate /bin/
7+
RUN chmod +x /bin/tmate
8+
9+
FROM alpine:3
510
EXPOSE 3000
611

712
ENV GODEBUG netdns=go
813
ENV DRONE_PLATFORM_OS linux
914
ENV DRONE_PLATFORM_ARCH amd64
1015

1116
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
17+
COPY --from=alpine /bin/tmate /bin/
1218

1319
LABEL com.centurylinklabs.watchtower.stop-signal="SIGINT"
1420

0 commit comments

Comments
 (0)