Skip to content

Commit

Permalink
add terrascan Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuf Kanchwala committed Jul 31, 2020
1 parent cadae23 commit 599a9aa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -8,7 +8,6 @@ __pycache__/

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
Expand Down Expand Up @@ -104,4 +103,4 @@ venv.bak/
#vscode
.vscode/

/updatedFiles
/updatedFiles
36 changes: 36 additions & 0 deletions build/Dockerfile
@@ -0,0 +1,36 @@
# -------- builder stage -------- #
FROM golang:alpine AS builder

ARG GOOS_VAL=linux
ARG GOARCH=amd64

WORKDIR $GOPATH/src/terrascan

# download go dependencies
COPY go.mod go.sum ./
RUN go mod download

# copy terrascan source
COPY . .

# build binary
RUN GOOS=${GOOS_VAL} GOARCH=${GOARCH_VAL} go build -v -ldflags "-w -s" -o /go/bin/terrascan ./cmd/terrascan


# -------- prod stage -------- #
FROM alpine:3.12.0

# create non root user
RUN addgroup --gid 101 terrascan && \
adduser -S --uid 101 --ingroup terrascan terrascan

# run as non root user
USER terrascan

# copy terrascan binary from build
COPY --from=builder /go/bin/terrascan /go/bin/terrascan

EXPOSE 9010

ENTRYPOINT ["/go/bin/terrascan", "--server"]
CMD ["--log-type", "json"]

0 comments on commit 599a9aa

Please sign in to comment.