Skip to content

Commit

Permalink
Merge pull request #31 from Financial-Times/fix/uppsf-666-update-base…
Browse files Browse the repository at this point in the history
…-image

Update CircleCI
Transition to multistage scratch build
Update to go modules
Update panicGuide url to Runbook
Update README
  • Loading branch information
ivan-p-nikolov committed Nov 20, 2019
2 parents 428198f + 0d50dbf commit f117e01
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 379 deletions.
20 changes: 12 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
working_directory: /go/src/github.com/Financial-Times/generic-rw-s3
docker:
- image: golang:1.10
- image: golang:1
environment:
GOPATH: /go
CIRCLE_TEST_REPORTS: /tmp/test-results
Expand All @@ -18,16 +18,20 @@ jobs:
- run:
name: External Dependancies
command: |
go get -u github.com/jstemmer/go-junit-report
go get -u github.com/mattn/goveralls
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
GO111MODULE=off go get -u github.com/jstemmer/go-junit-report
GO111MODULE=off go get -u github.com/mattn/goveralls
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.18.0
wget https://raw.githubusercontent.com/Financial-Times/upp-coding-standard/v1.0.0/golangci-config/.golangci.yml
- run:
name: Import libraries
command: dep ensure -v -vendor-only
name: Run linters
command: golangci-lint run --new-from-rev=master --config .golangci.yml
- run:
name: Go Build
command: go build -mod=readonly -v
- run:
name: Run Tests
command: |
go test ./... -race -cover -coverprofile=$CIRCLE_COVERAGE_REPORT/coverage.out | go-junit-report > $CIRCLE_TEST_REPORTS/golang/junit.xml
go test -mod=readonly -race -cover -coverprofile=$CIRCLE_COVERAGE_REPORT/coverage.out ./... | go-junit-report > $CIRCLE_TEST_REPORTS/golang/junit.xml
- run:
name: Upload Coverage
command: /go/bin/goveralls -coverprofile=$CIRCLE_COVERAGE_REPORT/coverage.out -service=circle-ci -repotoken=$COVERALLS_TOKEN
Expand All @@ -36,7 +40,7 @@ jobs:
dockerfile:
working_directory: /generic-rw-s3
docker:
- image: docker:18.03
- image: docker:18
steps:
- checkout
- setup_docker_engine
Expand Down
32 changes: 13 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
FROM golang:1.10-alpine
FROM golang:1

ENV PROJECT=generic-rw-s3
COPY . /${PROJECT}-sources/

RUN apk --no-cache --virtual .build-dependencies add git curl \
&& 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="${ORG_PATH}/${PROJECT}/vendor/${ORG_PATH}/service-status-go/buildinfo." \
&& VERSION="version=$(git describe --tag --always 2> /dev/null)" \
ENV ORG_PATH="github.com/Financial-Times"
ENV BUILDINFO_PACKAGE="${ORG_PATH}/service-status-go/buildinfo."

COPY . /${PROJECT}/
WORKDIR /${PROJECT}/

RUN 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 "Build flags: $LDFLAGS" \
&& echo "Fetching dependencies..." \
&& curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh \
&& $GOPATH/bin/dep ensure -vendor-only \
&& go build -ldflags="${LDFLAGS}" \
&& mv ${PROJECT} /${PROJECT} \
&& apk del .build-dependencies \
&& rm -rf $GOPATH /var/cache/apk/*
&& CGO_ENABLED=0 go build -mod=readonly -o /artefacts/${PROJECT} -ldflags="${LDFLAGS}"

FROM scratch
WORKDIR /
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=0 /artefacts/* /

CMD ["/generic-rw-s3"]
244 changes: 0 additions & 244 deletions Gopkg.lock

This file was deleted.

61 changes: 0 additions & 61 deletions Gopkg.toml

This file was deleted.

Loading

0 comments on commit f117e01

Please sign in to comment.