diff --git a/Taskfile.yml b/Taskfile.yml index bb9d45d..e46b040 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -18,13 +18,14 @@ tasks: - "go build -o out/{{OS}}/ ." preconditions: - sh: "which go" + msg: Go is not installed. Install Go or build with Docker using the "docker" task build:docker: aliases: - docker cmds: - task: build:docker:dockercli - - "docker build -t listen-build -f docker/build.Dockerfile --build-arg GOOS='{{OS}}' ." + - "docker build -t listen-build -f docker/build.Dockerfile --build-arg GOOS='{{OS}}' --build-arg GOARCH='{{ARCH}}' ." - "mkdir -p out/{{OS}}" - "docker create --name listen-build-tmp listen-build" - cmd: "docker cp listen-build-tmp:{{.DOCKER_EXE}}.exe out/{{OS}}/" @@ -46,3 +47,11 @@ tasks: - cmd: '"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine' platforms: - windows + + clean: + cmds: + - rm -rf out/ + - cmd: docker image rm listen-build + ignore_error: true + - cmd: docker rm listen-build-tmp + ignore_error: true diff --git a/docker/build.Dockerfile b/docker/build.Dockerfile index 57ed192..3de0073 100644 --- a/docker/build.Dockerfile +++ b/docker/build.Dockerfile @@ -2,7 +2,6 @@ # listen is currently not intended to run in a Docker container ARG IMAGE="1-alpine" -ARG GOOS="linux" FROM golang:${IMAGE} AS build @@ -10,6 +9,10 @@ WORKDIR /usr/src/listen COPY . . RUN apk upgrade --no-cache -RUN go build -o out/$GOOS/ . +ARG GOOS="linux" +RUN go env -w GOOS=${GOOS} +ARG GOARCH="amd64" +RUN go env -w GOARCH=${GOARCH} +RUN go build -o out/$(go env GOOS)/ . CMD ["tail", "-f", "/dev/null"]