monitoring task with slack bot alerting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2KB

  1. FROM --platform=$BUILDPLATFORM golang:1.16.0-alpine3.13 AS builder
  2. # ex. amd64
  3. ARG TARGETARCH
  4. # ex. linux/amd64
  5. ARG BUILDPLATFORM
  6. RUN apk update && \
  7. apk add --no-cache git ca-certificates tzdata gcc libc-dev && \
  8. update-ca-certificates
  9. ENV USER=appuser
  10. ENV UID=10001
  11. ENV GID=10001
  12. WORKDIR /data
  13. RUN addgroup \
  14. --gid "${GID}" \
  15. "${USER}" && \
  16. adduser \
  17. --disabled-password \
  18. --gecos "" \
  19. --home "/nonexistent" \
  20. --shell "/sbin/nologin" \
  21. --no-create-home \
  22. --uid "${UID}" \
  23. -G "${USER}" \
  24. "${USER}"
  25. COPY go.mod .
  26. COPY go.sum .
  27. RUN go mod download && \
  28. go mod verify
  29. COPY . .
  30. RUN export GOARCH=$TARGETARCH; \
  31. export GOOS=$(echo $BUILDPLATFORM | cut -d'/' -f1); \
  32. export GOBUILDFLAGS="-a -tags netgo -installsuffix netgo"; \
  33. export LDFLAGS="-w -s -d"; \
  34. export CGO_ENABLED=0; \
  35. go build -o bin/bot-$GOOS-$GOARCH cmd/main.go
  36. FROM alpine:3.12.4
  37. USER appuser:appuser
  38. COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
  39. COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
  40. COPY --from=builder /etc/passwd /etc/passwd
  41. COPY --from=builder /etc/group /etc/group
  42. COPY --from=builder --chown=appuser:appuser /data/bin/* /go/bin/bot
  43. WORKDIR /go
  44. ENTRYPOINT ["/go/bin/bot"]