weather poller application deploy on kubernetes. and weather api with ssl
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.

60 lines
1.6KB

  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 make tzdata gcc libc-dev && \
  8. apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing cfssl && \
  9. update-ca-certificates
  10. ENV USER=appuser
  11. ENV UID=10001
  12. ENV GID=10001
  13. WORKDIR /data
  14. RUN addgroup \
  15. --gid "${GID}" \
  16. "${USER}" && \
  17. adduser \
  18. --disabled-password \
  19. --gecos "" \
  20. --home "/nonexistent" \
  21. --shell "/sbin/nologin" \
  22. --no-create-home \
  23. --uid "${UID}" \
  24. -G "${USER}" \
  25. "${USER}"
  26. COPY Makefile .
  27. COPY certs/ certs/
  28. RUN make gen-cert
  29. COPY go.mod .
  30. COPY go.sum .
  31. RUN make dependencies
  32. ARG WEATHER_VERSION
  33. COPY . .
  34. # RUN make build-$BINARYNAME GOARCH=$TARGETARCH GOOS=$(echo $BUILDPLATFORM | cut -d'/' -f1) LDFLAGS='-extldflags="-static"'
  35. RUN make build-weather \
  36. GOARCH=$TARGETARCH \
  37. GOOS=$(echo $BUILDPLATFORM | cut -d'/' -f1) \
  38. GOBUILDFLAGS=" -a -tags netgo,prod -installsuffix netgo" \
  39. LDFLAGS="-w -s -d -X go/weather/internal/version.Version=$WEATHER_VERSION"
  40. FROM alpine
  41. USER appuser:appuser
  42. COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
  43. COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
  44. COPY --from=builder /etc/passwd /etc/passwd
  45. COPY --from=builder /etc/group /etc/group
  46. COPY --from=builder --chown=appuser:appuser /data/bin/* /go/bin/weather
  47. COPY --from=builder --chown=appuser:appuser /data/certs/out/weather* /go/certs/out/
  48. WORKDIR /go
  49. ENTRYPOINT ["/go/bin/weather"]