12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- ##### BUILDER #####
- FROM golang:1.13-alpine3.11 as builder
- ## Task: Install build deps
- # hadolint ignore=DL3018
- RUN set -eux; \
- apk add --no-progress --quiet --no-cache --upgrade --virtual .build-deps \
- gcc \
- git \
- musl-dev
- ## Task: copy source files
- COPY . /src
- WORKDIR /src
- ## Task: fetch project deps
- RUN go mod download
- ## Task: build project
- ENV GOOS="linux"
- ENV GOARCH="amd64"
- ENV CGO_ENABLED="0"
- RUN go build -ldflags="-s -w" -o schematic-service cmd/service.go
- ## Task: set permissions
- RUN chmod 0755 /src/schematic-service
- ## Task: runtime dependencies
- # hadolint ignore=DL3018
- RUN set -eux; \
- apk add --no-progress --quiet --no-cache --upgrade --virtual .run-deps \
- tzdata
- # hadolint ignore=DL3018,SC2183,DL4006
- RUN set -eu +x; \
- apk add --no-progress --quiet --no-cache --upgrade ncurses; \
- apk update --quiet; \
- printf '%30s\n' | tr ' ' -; \
- echo "RUNTIME DEPENDENCIES"; \
- PKGNAME=$(apk info --depends .run-deps \
- | sed '/^$/d;/depends/d' \
- | sort -u ); \
- printf '%s\n' "${PKGNAME}" \
- | while IFS= read -r pkg; do \
- apk info --quiet --description --no-network "${pkg}" \
- | sed -n '/description/p' \
- | sed -r "s/($(echo "${pkg}" | sed -r 's/\+/\\+/g'))-(.*)\s.*/\1=\2/"; \
- done \
- | tee -a /usr/share/rundeps; \
- printf '%30s\n' | tr ' ' -
- ##### TARGET #####
- FROM alpine:3.11
- ARG RELEASE
- ENV IMG_VERSION="${RELEASE}"
- COPY --from=builder /src/schematic-service /usr/local/bin/
- COPY --from=builder /src/configs/service.yaml /config/
- COPY --from=builder /usr/share/rundeps /usr/share/rundeps
- RUN set -eux; \
- xargs -a /usr/share/rundeps apk add --no-progress --quiet --no-cache --upgrade --virtual .run-deps
- ENTRYPOINT ["/usr/local/bin/schematic-service"]
- CMD ["--config","/config/service.yaml"]
- EXPOSE 8080 8443
- HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
- CMD wget -q -T 5 --spider http://localhost:8080/health/health
- LABEL org.opencontainers.image.title="schematic-service" \
- org.opencontainers.image.description="schematic-service" \
- org.opencontainers.image.version="${IMG_VERSION}" \
- org.opencontainers.image.source="http://bitbucket.easy.de/scm/dm/service-gomicro-go.git" \
- org.opencontainers.image.vendor="MCS" \
- org.opencontainers.image.authors="MCS" \
- maintainer="MCS" \
- NAME="schematic-service"
|