Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
support docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Apr 17, 2023
1 parent 2ddf248 commit 5823a6b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ CENTRAL_AUTH_CLIENTID=<Amplify Central Service Account> # created in Prepare AM
CENTRAL_AUTH_PRIVATEKEY=/keys/private_key.pem # path to the key file created with openssl
CENTRAL_AUTH_PUBLICKEY=/keys/public_key.pem # path to the key file created with openssl

WEBMETHODS__URL=<Webmethods API Gateway UI URL> # created in Prepare Webmethods agent step
WEBMETHODS_URL=<Webmethods API Gateway UI URL> # created in Prepare Webmethods agent step
WEBMETHODS_MATURITYSTATE=<Webmethods Maturity State> # created in Webmethods agent step
WEBMETHODS_FILTER=<Webmethods Tag filter> # created in Webmethods agent step
WEBMETHODS_AUTH_USERNAME=<Webmethods Username> # created in Prepare Webmethods agent step
Expand Down
48 changes: 35 additions & 13 deletions build/discovery.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,57 @@
# Build image
FROM golang:1.19.2 as builder
ENV APP_HOME /build
FROM docker.io/golang@sha256:46752c2ee3bd8388608e41362964c84f7a6dffe99d86faeddc82d917740c5968 as builder
ENV APP_HOME /go/src/github.com/Axway/agents-webmetods
ENV APP_USER axway
ENV AGENT=${APP_HOME}/cmd/discovery


RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME

# Copy necessary files
COPY . .

RUN make download
#RUN make verify
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build-discovery
RUN export time=`date +%Y%m%d%H%M%S` && \
export commit_id=`git rev-parse --short HEAD` && \
export version=`git tag -l --sort='version:refname' | grep -Eo '[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,3}$' | tail -1` && \
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 && \
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=ApigeeDiscoveryAgent'" \
-a -o ${APP_HOME}/bin/webmethods_discovery_agent ${AGENT}/main.go

# Create non-root user
RUN addgroup $APP_USER && adduser --system $APP_USER --ingroup $APP_USER
RUN chown -R $APP_USER:$APP_USER $APP_HOME
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_discovery_agent

USER $APP_USER

# Base image
FROM scratch
ENV APP_HOME /build
FROM docker.io/alpine@sha256:1304f174557314a7ed9eddb4eab12fed12cb0cd9809e4c28f29af86979a3c870
ENV APP_USER axway
ENV APP_HOME /go/src/github.com/Axway/agents-webmetods

# 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 $APP_HOME/build/webmethods_discovery_agent.yml /webmethods_discovery_agent.yml
COPY --from=builder $APP_HOME/bin/discovery /discovery
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder $APP_HOME/build/webmethods_discovery_agent.yml /webmethods_discovery_agent.yml
COPY --from=builder ${APP_HOME}/bin/webmethods_discovery_agent /webmethods_discovery_agent

RUN mkdir /keys && \
chown -R axway /keys && \
apk --no-cache add openssl libssl1.1 libcrypto1.1 musl musl-utils libc6-compat busybox curl && \
find / -perm /6000 -type f -exec chmod a-s {} \; || true


USER $APP_USER
VOLUME ["/tmp"]
VOLUME ["/keys"]
HEALTHCHECK --retries=1 CMD curl --fail http://localhost:${STATUS_PORT:-8989}/status || exit 1
ENTRYPOINT ["/discovery"]
ENTRYPOINT ["/webmethods_discovery_agent"]
10 changes: 6 additions & 4 deletions build/webmethods_discovery_agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ central:
agentName:
organizationID:
environment:
grpc:
enabled: 'true'

log:
level: debug
Expand All @@ -12,8 +14,8 @@ log:
webmethods:
pollInterval: 30s
url: ""
maturityState: "${}"
filter: "${}"
maturityState: ""
filter: ""
auth:
username: "${}"
password: "${}"
username: ""
password: ""

0 comments on commit 5823a6b

Please sign in to comment.