-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathDockerfile
44 lines (33 loc) · 1.23 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
FROM --platform=${BUILDPLATFORM} golang:1.22.6-alpine AS builder
ENV APP_DIR=/go/src/github.com/org/repo
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG APP_VERSION=develop
ARG PACKAGE_COMMONS=github.com/reportportal/commons-go/v5
ARG REPO_NAME=reportportal/service-index
ARG BUILD_BRANCH
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=${BUILD_BRANCH} \
-X ${PACKAGE_COMMONS}/commons.buildDate=${BUILD_DATE} \
-X ${PACKAGE_COMMONS}/commons.version=${APP_VERSION}" \
-o app ./
FROM alpine:3.20.2
ENV DEPOLY_DIR=/app/service-index
RUN mkdir -p ${DEPOLY_DIR}
WORKDIR ${DEPOLY_DIR}
RUN chgrp -R 0 ${DEPOLY_DIR} && chmod -R g=u ${DEPOLY_DIR}
ENV APP_DIR=/go/src/github.com/org/repo
ARG APP_VERSION
LABEL maintainer="Andrei Varabyeu <[email protected]>"
LABEL version=${APP_VERSION}
RUN apk --no-cache add --upgrade apk-tools
COPY --from=builder ${APP_DIR}/app .
EXPOSE 8080
ENTRYPOINT ["./app"]