-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from buchdag/fix-dockerfile
Have the Dockerfile build from the actual surrounding sources rather than downloading a hardcoded version
- Loading branch information
Showing
1 changed file
with
17 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
# Build docker-gen from scratch | ||
FROM golang:1.14-alpine as dockergen | ||
RUN apk add --no-cache git | ||
FROM golang:1.16-alpine as go-builder | ||
|
||
# Download the sources for the given version | ||
ENV VERSION 0.7.5 | ||
ADD https://github.com/jwilder/docker-gen/archive/${VERSION}.tar.gz sources.tar.gz | ||
ARG VERSION=master | ||
|
||
# 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 | ||
WORKDIR /build | ||
|
||
# Install the dependencies and make the docker-gen executable | ||
WORKDIR /go/src/github.com/jwilder/docker-gen | ||
RUN CGO_ENABLED=0 go build -ldflags "-X main.buildVersion=${VERSION}" ./cmd/docker-gen | ||
# Install the dependencies | ||
COPY . . | ||
RUN go mod download -json | ||
|
||
FROM alpine:latest | ||
LABEL maintainer="Jason Wilder <mail@jasonwilder.com>" | ||
# Build the docker-gen executable | ||
RUN CGO_ENABLED=0 go build -ldflags "-X main.buildVersion=${VERSION}" -o docker-gen ./cmd/docker-gen | ||
|
||
FROM alpine:3.13 | ||
|
||
RUN apk -U add openssl | ||
LABEL maintainer="Jason Wilder <mail@jasonwilder.com>" | ||
|
||
ENV VERSION 0.7.5 | ||
COPY --from=dockergen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/docker-gen | ||
ENV DOCKER_HOST unix:///tmp/docker.sock | ||
|
||
# Install packages required by the image | ||
RUN apk add --no-cache --virtual .bin-deps openssl | ||
|
||
# Install docker-gen from build stage | ||
COPY --from=go-builder /build/docker-gen /usr/local/bin/docker-gen | ||
|
||
ENTRYPOINT ["/usr/local/bin/docker-gen"] | ||
ENTRYPOINT ["/usr/local/bin/docker-gen"] |