Skip to content

Commit

Permalink
Remove excess binaries in bot image
Browse files Browse the repository at this point in the history
  • Loading branch information
motoki317 committed Apr 28, 2024
1 parent 9f54838 commit c87132b
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,10 @@ ENV GOARCH=$TARGETARCH
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
go build -o /dev-ops-bot -ldflags="-s -w -X github.com/traPtitech/DevOpsBot/pkg/utils.version=$VERSION" .

FROM --platform=$BUILDPLATFORM golang:1-alpine AS installer

ENV CGO_ENABLED 0
ARG TARGETOS
ARG TARGETARCH
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH

RUN apk add --no-cache wget

RUN wget https:/mikefarah/yq/releases/latest/download/yq_"$TARGETOS"_"$TARGETARCH" -O /yq && \
chmod +x /yq

RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
go install sigs.k8s.io/kustomize/kustomize/v5@latest
# keep output directory the same between platforms; workaround for https:/golang/go/issues/57485
RUN cp /go/bin/kustomize /kustomize || cp /go/bin/"$GOOS"_"$GOARCH"/kustomize /kustomize

FROM alpine:3

WORKDIR /work

# Install commands for deploy scripts
RUN apk add --no-cache git openssh curl npm
RUN mkdir -p /root/.ssh && ssh-keyscan github.com >> /root/.ssh/known_hosts

COPY --from=installer /yq /usr/local/bin/
COPY --from=installer /kustomize /usr/local/bin/

COPY --from=builder /dev-ops-bot ./

ENTRYPOINT ["/work/dev-ops-bot"]

0 comments on commit c87132b

Please sign in to comment.