Created
February 27, 2018 15:17
-
-
Save leopoldodonnell/f9211f7b52fa91682dee297c5fa24494 to your computer and use it in GitHub Desktop.
Go Dockerfile with SNYK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A Dockerfile to build a go app with Snyk testing | |
FROM golang:alpine3.7 AS builder | |
MAINTAINER 'Leo ODonnell' | |
# Build with your SNYK Token, but supply from command line | |
ARG SNYK_TOKEN=xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | |
# Pass in the name of the application to build | |
ARG APP=your-app | |
RUN apk --no-cache add git nodejs && \ | |
npm install -g snyk && \ | |
go get -u github.com/golang/dep/cmd/dep | |
WORKDIR /go/src/app | |
COPY . . | |
RUN dep init && dep ensure | |
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/bin/$APP . | |
# Add Tests Here | |
RUN snyk test | |
# Build the runtime container if all went well | |
# This shows a scratch container but it could be anything | |
FROM scratch | |
ARG APP=your-app | |
COPY --from=builder /src/bin/${APP} /${APP} | |
CMD ["/${APP}"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment