0
0
mirror of https://github.com/thegeeklab/wp-docker-buildx.git synced 2024-11-09 17:20:39 +00:00

disable starting the daemon on windows

This commit is contained in:
Brad Rydzewski 2019-08-14 12:51:43 -07:00
parent 98722a6680
commit 3336758708
5 changed files with 42 additions and 19 deletions

View File

@ -59,7 +59,7 @@ steps:
commands: commands:
# TODO use the new DRONE_SEMVER_SHORT environment variables to # TODO use the new DRONE_SEMVER_SHORT environment variables to
# publish docker images for tag events. # publish docker images for tag events.
- go build -o release/windows/amd64/drone-docker.exe - go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker
- docker login -u $env:USERNAME -p $env:PASSWORD - docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/docker/Dockerfile.windows.1809 -t plugins/docker:windows-1809-amd64 . - docker build -f docker/docker/Dockerfile.windows.1809 -t plugins/docker:windows-1809-amd64 .
- docker push plugins/docker:windows-1809-amd64 - docker push plugins/docker:windows-1809-amd64
@ -97,7 +97,7 @@ steps:
commands: commands:
# TODO use the new DRONE_SEMVER_SHORT environment variables to # TODO use the new DRONE_SEMVER_SHORT environment variables to
# publish docker images for tag events. # publish docker images for tag events.
- go build -o release/windows/amd64/drone-docker.exe - go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker
- docker login -u $env:USERNAME -p $env:PASSWORD - docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/docker/Dockerfile.windows.1903 -t plugins/docker:windows-1903-amd64 . - docker build -f docker/docker/Dockerfile.windows.1903 -t plugins/docker:windows-1903-amd64 .
- docker push plugins/docker:windows-1903-amd64 - docker push plugins/docker:windows-1903-amd64

26
daemon.go Normal file
View File

@ -0,0 +1,26 @@
// +build !windows
package docker
import (
"io/ioutil"
"os"
)
const dockerExe = "/usr/local/bin/docker"
const dockerdExe = "/usr/local/bin/dockerd"
func (p Plugin) startDaemon() {
cmd := commandDaemon(p.Daemon)
if p.Daemon.Debug {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
} else {
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
}
go func() {
trace(cmd)
cmd.Run()
}()
}

10
daemon_win.go Normal file
View File

@ -0,0 +1,10 @@
// +build windows
package docker
const dockerExe = "C:\\bin\\docker.exe"
const dockerdExe = ""
func (p Plugin) startDaemon() {
// this is a no-op on windows
}

View File

@ -2,7 +2,6 @@ package docker
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
@ -69,18 +68,7 @@ type (
func (p Plugin) Exec() error { func (p Plugin) Exec() error {
// start the Docker daemon server // start the Docker daemon server
if !p.Daemon.Disabled { if !p.Daemon.Disabled {
cmd := commandDaemon(p.Daemon) p.startDaemon()
if p.Daemon.Debug {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
} else {
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
}
go func() {
trace(cmd)
cmd.Run()
}()
} }
// poll the docker daemon until it is started. This ensures the daemon is // poll the docker daemon until it is started. This ensures the daemon is
@ -154,9 +142,6 @@ func (p Plugin) Exec() error {
return nil return nil
} }
const dockerExe = "/usr/local/bin/docker"
const dockerdExe = "/usr/local/bin/dockerd"
// helper function to create the docker login command. // helper function to create the docker login command.
func commandLogin(login Login) *exec.Cmd { func commandLogin(login Login) *exec.Cmd {
if login.Email != "" { if login.Email != "" {

View File

@ -13,7 +13,8 @@ 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 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 RUN /innoextract.exe dockertoolbox.exe
FROM mcr.microsoft.com/windows/servercore:1903 FROM mcr.microsoft.com/windows/nanoserver:1903
USER ContainerAdministrator
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" ` LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Docker" ` org.label-schema.name="Drone Docker" `
@ -21,6 +22,7 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.schema-version="1.0" org.label-schema.schema-version="1.0"
RUN mkdir C:\bin 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 COPY --from=download /app/docker.exe C:/bin/docker.exe
ADD release/windows/amd64/drone-docker.exe C:/bin/drone-docker.exe ADD release/windows/amd64/drone-docker.exe C:/bin/drone-docker.exe
ENTRYPOINT [ "C:\\bin\\drone-docker.exe" ] ENTRYPOINT [ "C:\\bin\\drone-docker.exe" ]