From 8121a6a4823c6695a623cdcef8b32aaee21e1096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Oscarsson?= Date: Sun, 24 Sep 2017 11:51:22 +0200 Subject: [PATCH] Change Dockerfile to multi stage build --- Dockerfile | 30 +++++++++--------------------- Dockerfile.multi | 14 -------------- 2 files changed, 9 insertions(+), 35 deletions(-) delete mode 100644 Dockerfile.multi diff --git a/Dockerfile b/Dockerfile index 8b1bdc6..98c218c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,14 @@ -FROM frolvlad/alpine-glibc:alpine-3.5 - -ARG PROMETHEUS_SQL_VERSION=1.2.0 -ARG PKG_FILE=prometheus-sql-linux-amd64.tar.gz -ARG PKG_URL=https://github.com/chop-dbhi/prometheus-sql/releases/download/$PROMETHEUS_SQL_VERSION/$PKG_FILE - -RUN apk update -RUN apk add curl - -# Workaround to publish Github release before curl fetches it. -RUN sleep 60 - -RUN mkdir -p /opt/prometheus-sql/bin \ - && curl --retry 5 --retry-delay 15 --retry-max-time 120 -SL $PKG_URL \ - | tar -xzC /opt/prometheus-sql/bin \ - && ln -s /opt/prometheus-sql/bin/linux-amd64/prometheus-sql /usr/local/bin/ - -RUN apk del curl -RUN rm /var/cache/apk/* +# Requires Docker v17.06 or later +FROM golang:1.8.3 as builder +RUN mkdir -p /go/src/app +WORKDIR /go/src/app +COPY . /go/src/app +RUN go-wrapper download +RUN go-wrapper install +FROM frolvlad/alpine-glibc:alpine-3.5 +COPY --from=builder /go/bin/app /usr/local/bin/prometheus-sql EXPOSE 8080 - ENTRYPOINT ["/usr/local/bin/prometheus-sql", "-host", "0.0.0.0"] - # Default command assumes the SQL agent is linked. CMD ["-service", "http://sqlagent:5000"] \ No newline at end of file diff --git a/Dockerfile.multi b/Dockerfile.multi deleted file mode 100644 index 98c218c..0000000 --- a/Dockerfile.multi +++ /dev/null @@ -1,14 +0,0 @@ -# Requires Docker v17.06 or later -FROM golang:1.8.3 as builder -RUN mkdir -p /go/src/app -WORKDIR /go/src/app -COPY . /go/src/app -RUN go-wrapper download -RUN go-wrapper install - -FROM frolvlad/alpine-glibc:alpine-3.5 -COPY --from=builder /go/bin/app /usr/local/bin/prometheus-sql -EXPOSE 8080 -ENTRYPOINT ["/usr/local/bin/prometheus-sql", "-host", "0.0.0.0"] -# Default command assumes the SQL agent is linked. -CMD ["-service", "http://sqlagent:5000"] \ No newline at end of file