forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.apispec.debian
69 lines (57 loc) · 2.52 KB
/
Dockerfile.apispec.debian
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# This image is here mainly to be used as a container agent for the Azure DevOps pipeline
# it does not define an ENTRYPOINT as this is a requirement described here:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/container-phases?view=azure-devops#linux-based-containers
#
FROM golang:1.16-buster as build_env
# Create a group and user
RUN groupadd checkmarx && useradd -g checkmarx -M -s /bin/bash checkmarx
USER checkmarx
# Copy the source from the current directory to the Working Directory inside the container
WORKDIR /app
ENV GOPRIVATE=github.com/Checkmarx/*
ARG VERSION="development"
ARG COMMIT="NOCOMMIT"
ARG SENTRY_DSN=""
ARG DESCRIPTIONS_URL=""
ARG APISCANNER="true"
#Copy go mod and sum files
COPY --chown=checkmarx:checkmarx go.mod .
COPY --chown=checkmarx:checkmarx go.sum .
# Get dependancies - will also be cached if we won't change mod/sum
RUN go mod download -x
# COPY the source code as the last step
COPY . .
USER root
# Build the Go app
RUN apt-get install -y ca-certificates
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "-s -w -X github.com/Checkmarx/kics/internal/constants.Version=${VERSION} -X github.com/Checkmarx/kics/internal/constants.SCMCommit=${COMMIT} -X github.com/Checkmarx/kics/internal/constants.SentryDSN=${SENTRY_DSN} -X github.com/Checkmarx/kics/internal/constants.BaseURL=${DESCRIPTIONS_URL} -X github.com/Checkmarx/kics/internal/constants.APIScanner=${APISCANNER}" \
-a -installsuffix cgo \
-o bin/kics cmd/console/main.go
USER Checkmarx
# Healthcheck the container
HEALTHCHECK CMD wget -q --method=HEAD localhost/system-status.txt
#
# This image can be used as a container agent for the Azure DevOps pipeline
# be sure to use /app/bin/kics as a path to the binary
#
# runtime image
FROM debian:buster-slim
RUN groupadd checkmarx && useradd -g checkmarx -M -s /bin/bash checkmarx
ENV PATH /app/bin:/usr/bin/git:$PATH
# Install Git
RUN apt-get update -yq
RUN apt-get install git -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build_env /app/bin/kics /app/bin/kics
COPY --from=build_env /app/assets/libraries/common /app/bin/assets/libraries/common
COPY --from=build_env /app/assets/libraries/openapi /app/bin/assets/libraries/openapi
COPY --from=build_env /app/assets/queries/openAPI /app/bin/assets/queries/openAPI
COPY --from=build_env /app/assets/queries/common /app/bin/assets/queries/common
WORKDIR /app/bin
ENV PATH $PATH:/app/bin
# Healthcheck the container
HEALTHCHECK CMD wget -q --method=HEAD localhost/system-status.txt
ENTRYPOINT ["/app/bin/kics"]