Skip to content

Commit

Permalink
fix buildinfo again, upgrade image
Browse files Browse the repository at this point in the history
  • Loading branch information
peterschubert committed Apr 14, 2017
1 parent 77744c9 commit d549372
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
FROM alpine:3.4
FROM golang:1.7-alpine3.5

ADD *.go /content-rw-elasticsearch/
ENV PROJECT=content-rw-elasticsearch
COPY . /${PROJECT}-sources/

RUN apk add --update bash \
&& apk --update add git bzr go ca-certificates \
&& export GOPATH=/gopath \
&& REPO_PATH="github.com/Financial-Times/content-rw-elasticsearch" \
&& mkdir -p $GOPATH/src/${REPO_PATH} \
&& mv content-rw-elasticsearch/* $GOPATH/src/${REPO_PATH} \
&& rm -r content-rw-elasticsearch \
RUN apk --no-cache --virtual .build-dependencies add git \
&& ORG_PATH="github.com/Financial-Times" \
&& REPO_PATH="${ORG_PATH}/${PROJECT}" \
&& mkdir -p $GOPATH/src/${ORG_PATH} \
# Linking the project sources in the GOPATH folder
&& ln -s /${PROJECT}-sources $GOPATH/src/${REPO_PATH} \
&& cd $GOPATH/src/${REPO_PATH} \
&& BUILDINFO_PACKAGE="github.com/Financial-Times/service-status-go/buildinfo." \
&& VERSION="version=$(git describe --tag --always 2> /dev/null)" \
&& DATETIME="dateTime=$(date -u +%Y%m%d%H%M%S)" \
&& REPOSITORY="repository=$(git config --get remote.origin.url)" \
&& REVISION="revision=$(git rev-parse HEAD)" \
&& BUILDER="builder=$(go version)" \
&& LDFLAGS="-X '${BUILDINFO_PACKAGE}$VERSION' -X '${BUILDINFO_PACKAGE}$DATETIME' -X '${BUILDINFO_PACKAGE}$REPOSITORY' -X '${BUILDINFO_PACKAGE}$REVISION' -X '${BUILDINFO_PACKAGE}$BUILDER'" \
&& echo $LDFLAGS \
&& LDFLAGS="-X '"${BUILDINFO_PACKAGE}$VERSION"' -X '"${BUILDINFO_PACKAGE}$DATETIME"' -X '"${BUILDINFO_PACKAGE}$REPOSITORY"' -X '"${BUILDINFO_PACKAGE}$REVISION"' -X '"${BUILDINFO_PACKAGE}$BUILDER"'" \
&& echo "Build flags: $LDFLAGS" \
&& echo "Fetching dependencies..." \
&& go get -t ./... \
&& go build -ldflags="${LDFLAGS}" \
&& mv content-rw-elasticsearch /content-rw-elasticsearch \
&& apk del go git bzr \
&& go build -ldflags="${LDFLAGS}" \
&& apk del .build-dependencies \
&& rm -rf $GOPATH /var/cache/apk/*

CMD [ "/content-rw-elasticsearch" ]
WORKDIR /
# Using the expanded command, so that the shell will expand the $PROJECT env var. See https://docs.docker.com/engine/reference/builder/#cmd
CMD ["sh", "-c", "/${PROJECT}"]

0 comments on commit d549372

Please sign in to comment.