Skip to content

Commit

Permalink
Use multi-staging dockerfile and scratch image
Browse files Browse the repository at this point in the history
  • Loading branch information
Miouge1 committed Mar 21, 2018
1 parent af9266a commit 5b7d492
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
- stage: push
install: skip
script:
- ./scripts/build.sh
- VERSION=$(git rev-parse --short HEAD)
- docker build --tag "negz/kuberos:latest" .
- docker build --tag "negz/kuberos:${VERSION}" .
- docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
- ./scripts/push.sh

Expand Down
27 changes: 23 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
FROM alpine:3.7
MAINTAINER Nic Cope <[email protected]>
FROM node:9.8-alpine as node
ADD frontend/ .
RUN npm install && npm run build

FROM golang:1.10-alpine as golang
RUN apk --no-cache add git
WORKDIR /go/src/github.com/negz/kuberos/
ENV CGO_ENABLED=0

ADD . .
COPY --from=node dist/ dist/frontend
COPY --from=node index.html dist/frontend/

RUN apk update && apk add ca-certificates
RUN go get -u github.com/Masterminds/glide && \
go get -u github.com/rakyll/statik && \
glide install

RUN cd statik && go generate && cd ..
RUN go build -o /kuberos ./cmd/kuberos

FROM alpine:3.7 as ca-certificates
MAINTAINER Nic Cope <[email protected]>

COPY "dist/kuberos" /
RUN apk --no-cache add ca-certificates
COPY --from=golang /kuberos /

0 comments on commit 5b7d492

Please sign in to comment.