forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.apispec
67 lines (56 loc) · 3.14 KB
/
Dockerfile.apispec
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
FROM golang:1.18.0-alpine as build_env
# Create a group and user
RUN addgroup -S Checkmarx && adduser -S Checkmarx -G 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 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
#runtime image
FROM alpine:3.15.3
RUN addgroup -S Checkmarx && adduser -S Checkmarx -G Checkmarx
# 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
# Install Git
RUN apk add --no-cache \
git=2.34.1-r0
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
# Healthcheck the container
HEALTHCHECK CMD wget -q --method=HEAD localhost/system-status.txt
ENV PATH $PATH:/app/bin
# Command to run the executable
ENTRYPOINT ["/app/bin/kics"]