forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.apispec.debian
79 lines (66 loc) · 3.67 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
70
71
72
73
74
75
76
77
78
79
#
# 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.17.7-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
RUN apt-get update -yq \
&& apt-get install git wget unzip zip -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Terraform and Terraform plugins
RUN wget https://releases.hashicorp.com/terraform/1.1.3/terraform_1.1.3_linux_amd64.zip
RUN unzip terraform_1.1.3_linux_amd64.zip && rm terraform_1.1.3_linux_amd64.zip
RUN mv terraform /usr/bin/terraform
RUN wget https://releases.hashicorp.com/terraform-provider-azurerm/2.95.0/terraform-provider-azurerm_2.95.0_linux_amd64.zip
RUN wget https://releases.hashicorp.com/terraform-provider-aws/3.72.0/terraform-provider-aws_3.72.0_linux_amd64.zip
RUN wget https://releases.hashicorp.com/terraform-provider-google/4.10.0/terraform-provider-google_4.10.0_linux_amd64.zip
RUN unzip terraform-provider-azurerm_2.95.0_linux_amd64.zip && rm terraform-provider-azurerm_2.95.0_linux_amd64.zip
RUN unzip terraform-provider-google_4.10.0_linux_amd64.zip && rm terraform-provider-google_4.10.0_linux_amd64.zip
RUN unzip terraform-provider-aws_3.72.0_linux_amd64.zip && rm terraform-provider-aws_3.72.0_linux_amd64.zip
RUN mkdir ~/.terraform.d && mkdir ~/.terraform.d/plugins && mkdir ~/.terraform.d/plugins/linux_amd64 && mv terraform-provider-aws_v3.72.0_x5 terraform-provider-google_v4.10.0_x5 terraform-provider-azurerm_v2.95.0_x5 ~/.terraform.d/plugins/linux_amd64
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