-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d7f162
commit d59b9be
Showing
1 changed file
with
10 additions
and
20 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,43 +1,33 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM golang:1.21.5-alpine AS builder | ||
|
||
RUN apk add --update --no-cache gcc g++ git ca-certificates build-base | ||
|
||
# Copy code | ||
COPY . /build | ||
WORKDIR /build | ||
|
||
ARG VERSION | ||
ARG BUILD_TIMESTAMP | ||
ARG COMMIT_HASH | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
WORKDIR /build | ||
|
||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=bind,source=.,target=/build,ro \ | ||
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 \ | ||
go build \ | ||
-ldflags="-s -w \ | ||
-X 'github.com/openclarity/yara-rule-server/pkg/version.Version=${VERSION}' \ | ||
-X 'github.com/openclarity/yara-rule-server/pkg/version.CommitHash=${COMMIT_HASH}' \ | ||
-X 'github.com/openclarity/yara-rule-server/pkg/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \ | ||
-o bin/yara-rule-server main.go | ||
|
||
|
||
-o /bin/yara-rule-server main.go | ||
|
||
FROM alpine:3.19 | ||
|
||
RUN apk upgrade | ||
RUN apk add util-linux | ||
RUN apk add yara | ||
RUN mkdir /etc/yara-rule-server | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /build/bin/yara-rule-server ./yara-rule-server | ||
COPY config.example.yaml /etc/yara-rule-server/config.yaml | ||
RUN apk --no-cache add util-linux yara ca-certificates | ||
|
||
WORKDIR /opt | ||
COPY --from=builder --chmod=755 /bin/yara-rule-server /bin/yara-rule-server | ||
COPY --link --chmod=644 config.example.yaml /etc/yara-rule-server/config.yaml | ||
|
||
ENTRYPOINT ["/app/yara-rule-server"] | ||
ENTRYPOINT ["/bin/yara-rule-server"] |