build go binary in docker
This commit is contained in:
parent
3c6cdbcec5
commit
746e878ffc
@ -1,10 +1,4 @@
|
|||||||
pipeline:
|
pipeline:
|
||||||
build:
|
|
||||||
image: golang:1.17
|
|
||||||
commands:
|
|
||||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
|
||||||
- go build -v -a -tags netgo ./cmd/docker-buildx
|
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
repo: foo/bar
|
repo: foo/bar
|
||||||
|
21
Dockerfile
21
Dockerfile
@ -1,11 +1,11 @@
|
|||||||
FROM docker:20.10-dind@sha256:d20f0866ee1aca6b0eb7bc8bdb0d0c938721c7f79219b1d3bc1aa58666928586
|
FROM golang:1.17-alpine as build
|
||||||
|
|
||||||
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
COPY . /src
|
||||||
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
WORKDIR /src
|
||||||
LABEL org.opencontainers.image.title="drone-docker-buildx"
|
|
||||||
LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-docker-buildx"
|
RUN go build -v -a -tags netgo ./cmd/docker-buildx -o docker-buildx
|
||||||
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-docker-buildx"
|
|
||||||
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-docker-buildx"
|
FROM docker:20.10-dind
|
||||||
|
|
||||||
ARG BUILDX_VERSION
|
ARG BUILDX_VERSION
|
||||||
|
|
||||||
@ -14,7 +14,8 @@ ENV BUILDX_VERSION="${BUILDX_VERSION:-v0.6.3}"
|
|||||||
|
|
||||||
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
|
|
||||||
RUN apk --update add --virtual .build-deps curl && \
|
RUN \
|
||||||
|
apk --update add --virtual .build-deps curl && \
|
||||||
mkdir -p /usr/lib/docker/cli-plugins/ && \
|
mkdir -p /usr/lib/docker/cli-plugins/ && \
|
||||||
curl -SsL -o /usr/lib/docker/cli-plugins/docker-buildx "https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION##v}/buildx-v${BUILDX_VERSION##v}.linux-amd64" && \
|
curl -SsL -o /usr/lib/docker/cli-plugins/docker-buildx "https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION##v}/buildx-v${BUILDX_VERSION##v}.linux-amd64" && \
|
||||||
chmod 755 /usr/lib/docker/cli-plugins/docker-buildx && \
|
chmod 755 /usr/lib/docker/cli-plugins/docker-buildx && \
|
||||||
@ -22,6 +23,6 @@ RUN apk --update add --virtual .build-deps curl && \
|
|||||||
rm -rf /var/cache/apk/* && \
|
rm -rf /var/cache/apk/* && \
|
||||||
rm -rf /tmp/*
|
rm -rf /tmp/*
|
||||||
|
|
||||||
ADD release/amd64/drone-docker-buildx /bin/
|
COPY --from=build /src/docker-buildx /bin/docker-buildx
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"]
|
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "docker-buildx"]
|
||||||
|
Loading…
Reference in New Issue
Block a user