-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docker file for Multi-Platform Builds
- Loading branch information
1 parent
a4ecf35
commit 531cea8
Showing
1 changed file
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,38 @@ | ||
FROM alpine:3.16.2 | ||
FROM --platform=${BUILDPLATFORM} golang:1.19.1-alpine AS builder | ||
|
||
LABEL maintainer="Andrei Varabyeu <andrei_varabyeu@epam.com>" | ||
LABEL version=5.8.0 | ||
ENV APP_DIR=/go/src/github.com/org/repo | ||
|
||
ENV APP_DOWNLOAD_URL https://github.com/reportportal/service-index/releases/download/v5.8.0/service-index_linux_amd64 | ||
RUN apk --no-cache add --upgrade apk-tools | ||
ARG BUILDPLATFORM TARGETOS TARGETARCH | ||
ARG APP_VERSION=develop | ||
ARG PACKAGE_COMMONS=github.com/reportportal/commons-go/v5 | ||
ARG REPO_NAME=reportportal/service-index | ||
ARG COMMIT_HASH | ||
ARG BUILD_DATE | ||
|
||
ADD . ${APP_DIR} | ||
WORKDIR ${APP_DIR} | ||
|
||
RUN echo "I am running on $BUILDPLATFORM, building for TargetOS: $TARGETOS and Targetarch: $TARGETARCH" | ||
|
||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \ | ||
-ldflags "-extldflags '"-static"' \ | ||
-X ${PACKAGE_COMMONS}/commons.repo=${REPO_NAME} \ | ||
-X ${PACKAGE_COMMONS}/commons.branch=${COMMIT_HASH} \ | ||
-X ${PACKAGE_COMMONS}/commons.buildDate=${BUILD_DATE} \ | ||
-X ${PACKAGE_COMMONS}/commons.version=${APP_VERSION}" \ | ||
-o app ./ | ||
|
||
ADD ${APP_DOWNLOAD_URL} /service-index | ||
FROM --platform=$BUILDPLATFORM alpine:3.16.2 | ||
WORKDIR /root/ | ||
|
||
RUN chmod +x /service-index | ||
ENV APP_DIR=/go/src/github.com/org/repo | ||
ARG APP_VERSION | ||
|
||
LABEL maintainer="Andrei Varabyeu <andrei_varabyeu@epam.com>" | ||
LABEL version=${APP_VERSION} | ||
|
||
RUN apk --no-cache add --upgrade apk-tools | ||
COPY --from=builder ${APP_DIR}/app . | ||
|
||
EXPOSE 8080 | ||
ENTRYPOINT ["/service-index"] | ||
ENTRYPOINT ["./app"] |