This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APIGOV-27565 - major refactor of docker
- Loading branch information
Showing
3 changed files
with
88 additions
and
91 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
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
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,61 +1,53 @@ | ||
# Build image | ||
# golang:1.21.6-alpine3.19 linux/amd64 | ||
FROM docker.io/golang@sha256:2523a6f68a0f515fe251aad40b18545155135ca6a5b2e61da8254df9153e3648 AS builder | ||
ENV APP_HOME /go/src/github.com/Axway/agents-webmethods | ||
ENV APP_USER axway | ||
ENV AGENT=${APP_HOME}/cmd/traceability | ||
|
||
ARG VERSION | ||
ARG COMMIT_ID | ||
ARG commit_id | ||
ARG version | ||
ARG sdk_version | ||
ARG time | ||
ARG CGO_ENABLED | ||
|
||
ENV BASEPATH /go/src/github.com/Axway/agents-webmethods | ||
ENV APP_USER axway | ||
|
||
RUN mkdir -p $APP_HOME | ||
WORKDIR $APP_HOME | ||
RUN mkdir -p ${BASEPATH} | ||
WORKDIR ${BASEPATH} | ||
|
||
# Copy necessary files | ||
COPY . . | ||
|
||
RUN export time=`date +%Y%m%d%H%M%S` && \ | ||
export commit_id=${COMMIT_ID} && \ | ||
export version=${VERSION} && \ | ||
export sdk_version=`go list -m github.com/Axway/agent-sdk | awk '{print $2}' | awk -F'-' '{print substr($1, 2)}'` && \ | ||
export GOOS=linux && \ | ||
export CGO_ENABLED=0 && \ | ||
export GOARCH=amd64 && \ | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
go build -tags static_all \ | ||
-ldflags="-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildTime=${time}' \ | ||
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildVersion=${version}' \ | ||
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildCommitSha=${commit_id}' \ | ||
-X 'github.com/Axway/agent-sdk/pkg/cmd.SDKBuildVersion=${sdk_version}' \ | ||
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildAgentName=webMethodsTraceabilityAgent'" \ | ||
-a -o ${APP_HOME}/bin/webmethods_traceability_agent ${AGENT}/main.go | ||
|
||
-a -o $webmethods_traceability_agent ${BASEPATH}/cmd/traceability/main.go | ||
|
||
# Create non-root user | ||
RUN addgroup -g 2500 $APP_USER && adduser -u 2500 -D -G $APP_USER $APP_USER | ||
RUN chown -R $APP_USER:$APP_USER ${APP_HOME}/bin/webmethods_traceability_agent | ||
|
||
USER $APP_USER | ||
RUN addgroup -g 2500 ${APP_USER} && adduser -u 2500 -D -G ${APP_USER} ${APP_USER} | ||
RUN chown -R ${APP_USER}:${APP_USER} /webmethods_traceability_agent | ||
USER ${APP_USER} | ||
|
||
# alpine 3.18 linux/amd64 | ||
FROM docker.io/alpine@sha256:d695c3de6fcd8cfe3a6222b0358425d40adfd129a8a47c3416faff1a8aece389 | ||
|
||
ENV APP_USER axway | ||
ENV APP_HOME /go/src/github.com/Axway/agents-webmethods | ||
|
||
# Copy binary, user, config file and certs from previous build step | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder $APP_HOME/build/webmethods_traceability_agent.yml /webmethods_traceability_agent.yml | ||
COPY --from=builder ${APP_HOME}/bin/webmethods_traceability_agent /webmethods_traceability_agent | ||
COPY --from=builder /webmethods_traceability_agent /webmethods_traceability_agent | ||
COPY /webmethods_traceability_agent.yml /webmethods_traceability_agent.yml | ||
|
||
RUN mkdir /keys /data && \ | ||
chown -R axway /keys /data && \ | ||
apk --no-cache add openssl libssl3 libcrypto3 musl musl-utils libc6-compat busybox curl && \ | ||
find / -perm /6000 -type f -exec chmod a-s {} \; || true | ||
|
||
|
||
USER $APP_USER | ||
USER ${APP_USER} | ||
VOLUME ["/keys", "/data"] | ||
HEALTHCHECK --retries=1 CMD curl --fail http://localhost:${STATUS_PORT:-8989}/status || exit 1 | ||
ENTRYPOINT ["/webmethods_traceability_agent"] |