Skip to content

Instantly share code, notes, and snippets.

Created February 27, 2018 15:17
What would you like to do?
Go Dockerfile with SNYK
# A Dockerfile to build a go app with Snyk testing
FROM golang:alpine3.7 AS builder
# 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
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