Skip to content

Commit aa1675f

Browse files
committed
fix: don't hardcode docker-gen tag in dockerfile
The Dockerfile now builds from the actual surrounding sources
1 parent e877b8f commit aa1675f

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

Dockerfile

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
# Build docker-gen from scratch
2-
FROM golang:1.14-alpine as dockergen
3-
RUN apk add --no-cache git
2+
FROM golang:1.16-alpine as go-builder
43

5-
# Download the sources for the given version
6-
ENV VERSION 0.7.5
7-
ADD https://github.com/jwilder/docker-gen/archive/${VERSION}.tar.gz sources.tar.gz
4+
ARG VERSION=master
85

9-
# Move the sources into the right directory
10-
RUN tar -xzf sources.tar.gz && \
11-
mkdir -p /go/src/github.com/jwilder/ && \
12-
mv docker-gen-* /go/src/github.com/jwilder/docker-gen
6+
WORKDIR /build
137

14-
# Install the dependencies and make the docker-gen executable
15-
WORKDIR /go/src/github.com/jwilder/docker-gen
16-
RUN CGO_ENABLED=0 go build -ldflags "-X main.buildVersion=${VERSION}" ./cmd/docker-gen
8+
# Install the dependencies
9+
COPY . .
10+
RUN go mod download -json
1711

18-
FROM alpine:latest
19-
LABEL maintainer="Jason Wilder <[email protected]>"
12+
# Build the docker-gen executable
13+
RUN CGO_ENABLED=0 go build -ldflags "-X main.buildVersion=${VERSION}" -o docker-gen ./cmd/docker-gen
14+
15+
FROM alpine:3.13
2016

21-
RUN apk -U add openssl
17+
LABEL maintainer="Jason Wilder <[email protected]>"
2218

23-
ENV VERSION 0.7.5
24-
COPY --from=dockergen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/docker-gen
2519
ENV DOCKER_HOST unix:///tmp/docker.sock
2620

21+
# Install packages required by the image
22+
RUN apk add --no-cache --virtual .bin-deps openssl
23+
24+
# Install docker-gen from build stage
25+
COPY --from=go-builder /build/docker-gen /usr/local/bin/docker-gen
2726

28-
ENTRYPOINT ["/usr/local/bin/docker-gen"]
27+
ENTRYPOINT ["/usr/local/bin/docker-gen"]

0 commit comments

Comments
 (0)