Skip to content

Instantly share code, notes, and snippets.

@leopoldodonnell
Created February 27, 2018 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leopoldodonnell/f9211f7b52fa91682dee297c5fa24494 to your computer and use it in GitHub Desktop.
Save leopoldodonnell/f9211f7b52fa91682dee297c5fa24494 to your computer and use it in GitHub Desktop.
Go Dockerfile with SNYK
# 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