Skip to content

Commit

Permalink
Merge pull request #327 from KWARC/build-from-scratch
Browse files Browse the repository at this point in the history
Enable multi-architecture docker image builds
  • Loading branch information
jwilder committed Apr 3, 2021
2 parents 664fe0c + 5c7011b commit faaa781
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# Build docker-gen from scratch
FROM golang:1.14-alpine as dockergen
RUN apk add --no-cache git

# Download the sources for the given version
ENV VERSION 0.7.4
ADD https://github.com/jwilder/docker-gen/archive/${VERSION}.tar.gz sources.tar.gz

# Move the sources into the right directory
RUN tar -xzf sources.tar.gz && \
mkdir -p /go/src/github.com/jwilder/ && \
mv docker-gen-* /go/src/github.com/jwilder/docker-gen

# Install the dependencies and make the docker-gen executable
WORKDIR /go/src/github.com/jwilder/docker-gen
RUN go get -v ./... && \
CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.buildVersion=${VERSION}" ./cmd/docker-gen

FROM alpine:latest
LABEL maintainer="Jason Wilder <mail@jasonwilder.com>"

RUN apk -U add openssl

ENV VERSION 0.7.3
ENV DOWNLOAD_URL https://github.com/jwilder/docker-gen/releases/download/$VERSION/docker-gen-alpine-linux-amd64-$VERSION.tar.gz
ENV VERSION 0.7.4
COPY --from=dockergen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/docker-gen
ENV DOCKER_HOST unix:///tmp/docker.sock

RUN wget -qO- $DOWNLOAD_URL | tar xvz -C /usr/local/bin

ENTRYPOINT ["/usr/local/bin/docker-gen"]

0 comments on commit faaa781

Please sign in to comment.