Skip to content

Commit

Permalink
add distroless dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosyya committed Aug 14, 2024
1 parent 6670921 commit 7a7bddc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:

- name: Build image
run: |
docker build -t "${IMAGE_NAME}:server-monitor" .
docker build . -f ./Dockerfile -t "${IMAGE_NAME}:server-monitor"
docker build . -f ./Dockerfile.distroless -t "${IMAGE_NAME}:server-monitor-distroless"
- name: Login to GHCR
uses: docker/login-action@v2
Expand All @@ -40,4 +41,6 @@ jobs:
echo IMAGE_NAME=$IMAGE_NAME
echo VERSION=$VERSION
docker tag ${IMAGE_NAME}:server-monitor $IMAGE_NAME:$VERSION-server-monitor
docker tag ${IMAGE_NAME}:server-monitor-distroless $IMAGE_NAME:$VERSION-server-monitor-distroless
docker push $IMAGE_NAME:$VERSION-server-monitor
docker push $IMAGE_NAME:$VERSION-server-monitor-distroless
26 changes: 26 additions & 0 deletions Dockerfile.distroless
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM golang:1.20-alpine AS builder

RUN apk add --no-cache make git bash protoc

ADD . /gnfd-qa-test-monitor

ENV CGO_ENABLED=1
ENV GO111MODULE=on
ENV EXT_LD_FLAGS=-static

# For Private REPO
ARG GH_TOKEN=""
RUN go env -w GOPRIVATE="github.com/bnb-chain/*"
RUN git config --global url."https://${GH_TOKEN}@github.com".insteadOf "https://github.com"

RUN apk add --no-cache gcc libstdc++-dev libc-dev

RUN cd /gnfd-qa-test-monitor \
&& go build -o build/monitor main.go

FROM gcr.io/distroless/base-debian11

USER nonroot:nonroot
WORKDIR /home/nonroot
COPY --from=builder --chown=nonroot:nonroot /gnfd-qa-test-monitor/build/monitor $WORKDIR
ENTRYPOINT ["./monitor"]

0 comments on commit 7a7bddc

Please sign in to comment.