diff --git a/.circleci/config.yml b/.circleci/config.yml index da1da9ff91..e673ff689b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,11 +68,7 @@ jobs: steps: - checkout - setup_remote_docker - - run: curl -L -s https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 -o /go/bin/dep && chmod +x /go/bin/dep - - run: go get -u golang.org/x/tools/cmd/goimports - - run: dep ensure -vendor-only - - run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags "-s -X github.com/ory/oathkeeper/cmd.Version=`git describe --tags` -X github.com/ory/oathkeeper/cmd.BuildTime=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` -X github.com/ory/oathkeeper/cmd.GitHash=`git rev-parse HEAD`" -installsuffix cgo -o oathkeeper-docker-bin - - run: docker build -f Dockerfile -t oryd/oathkeeper:$CIRCLE_TAG . + - run: docker build --build-arg git_tag=$(git describe --tags) --build-arg git_commit=$(git rev-parse HEAD) -f Dockerfile -t oryd/oathkeeper:$CIRCLE_TAG . - run: docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD" - run: docker push oryd/oathkeeper:$CIRCLE_TAG diff --git a/Dockerfile b/Dockerfile index ee6be39886..cb56d60576 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,24 @@ -FROM alpine:3.6 +FROM golang:1.9-alpine -RUN apk add --update ca-certificates # Certificates for SSL +ARG git_tag +ARG git_commit -ADD oathkeeper-docker-bin /go/bin/oathkeeper -RUN chmod a=+x /go/bin/oathkeeper +RUN apk add --no-cache git build-base curl +RUN curl -L -s https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 -o $GOPATH/bin/dep +RUN chmod +x $GOPATH/bin/dep -ENTRYPOINT ["/go/bin/oathkeeper"] +WORKDIR /go/src/github.com/ory/oathkeeper + +ADD ./Gopkg.lock ./Gopkg.lock +ADD ./Gopkg.toml ./Gopkg.toml +RUN dep ensure -vendor-only + +ADD . . + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -X github.com/ory/oathkeeper/cmd.Version=$git_tag -X github.com/ory/oathkeeper/cmd.BuildTime=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` -X github.com/ory/oathkeeper/cmd.GitHash=$git_commit" -a -installsuffix cgo -o oathkeeper + +FROM scratch + +COPY --from=0 /go/src/github.com/ory/oathkeeper/oathkeeper /oathkeeper + +ENTRYPOINT ["/oathkeeper"]