-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[ASM-11561]- CI and Security: run docker as non root and import b…
…uild
- Loading branch information
1 parent
727726c
commit 1c03e39
Showing
5 changed files
with
76 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
FROM alpine:3.15.0 AS default | ||
ARG GO_VERSION | ||
FROM golang:${GO_VERSION}-alpine AS builder | ||
|
||
WORKDIR /src | ||
|
||
COPY . . | ||
|
||
ARG ARC="amd64" | ||
ARG LDFLAGS="" | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$ARC go build -ldflags "${LDFLAGS}" -a -installsuffix cgo -o akeyless-csi-provider . | ||
|
||
# Final stage | ||
FROM alpine:3.20.1 | ||
|
||
ARG PRODUCT_VERSION | ||
ARG PRODUCT_NAME=akeyless-csi-provider | ||
|
||
LABEL version=$PRODUCT_VERSION | ||
|
||
RUN addgroup -S nonroot && adduser -S nonroot -G nonroot | ||
|
||
COPY --from=builder --chown=nonroot:nonroot --chmod=755 /src/akeyless-csi-provider /app/akeyless-csi-provider | ||
|
||
USER nonroot | ||
|
||
COPY dist/akeyless-csi-provider /bin/ | ||
ENTRYPOINT [ "/bin/akeyless-csi-provider" ] | ||
ENTRYPOINT [ "/app/akeyless-csi-provider" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
GO_VERSION = $(shell go mod edit -json | jq -r .Go) | ||
DATE = $(shell date -u +%Y%m%d.%H%M%S) | ||
IMAGE_NAME = "docker.io/akeyless/akeyless-csi-provider" | ||
VERSION ?= 0.0.0 | ||
|
||
ifeq ($(VERSION), 0.0.0) | ||
TAG = "latest" | ||
else | ||
TAG = v$(VERSION) | ||
endif | ||
|
||
VERSION_FLAG = akeyless.io/akeyless-csi-provider/internal/version.Version=$(VERSION) | ||
DATE_FLAG = akeyless.io/akeyless-csi-provider/go/src/internal/version.BuildDate=$(DATE) | ||
LDFLAGS = "-w -s -X $(VERSION_FLAG) -X $(DATE_FLAG)" | ||
|
||
build: | ||
docker build --build-arg="GO_VERSION=$(GO_VERSION)" --build-arg=LDFLAGS=$(LDFLAGS) -t $(IMAGE_NAME):$(TAG) . | ||
|
||
push: | ||
ifeq ($(VERSION), 0.0.0) | ||
@echo can only push image if version is set | ||
exit 1 | ||
endif | ||
docker push $(IMAGE_NAME):$(TAG) | ||
|
||
all: build push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters