-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: build and push Docker image based on Chainguard base image #3623
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM docker.elastic.co/wolfi/chainguard-base@sha256:9f940409f96296ef56140bcc4665c204dd499af4c32c96cc00e792558097c3f1 | ||
RUN mkdir /usr/agent | ||
ARG JAR_FILE | ||
ARG HANDLER_FILE | ||
COPY ${JAR_FILE} /usr/agent/elastic-apm-agent.jar | ||
COPY ${HANDLER_FILE} /usr/agent/elastic-apm-handler | ||
RUN chmod +x /usr/agent/elastic-apm-handler |
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 |
---|---|---|
|
@@ -18,11 +18,13 @@ readonly SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )" | |
readonly PROJECT_ROOT=$SCRIPT_PATH/../../ | ||
readonly NAMESPACE="observability" | ||
|
||
if [ "$(ls -A ${PROJECT_ROOT}elastic-apm-agent/target/*.jar)" ] | ||
FILE=$(ls -A ${PROJECT_ROOT}elastic-apm-agent/target/*.jar | grep -E "elastic-apm-agent-[0-9]+.[0-9]+.[0-9]+(-SNAPSHOT)?.jar" ) | ||
|
||
if [ -n "${FILE}" ] | ||
then | ||
# We have build files to use | ||
echo "INFO: Found local build artifact. Using locally built for Docker build" | ||
find -E ${PROJECT_ROOT}elastic-apm-agent/target -regex '.*/elastic-apm-agent-[0-9]+.[0-9]+.[0-9]+(-SNAPSHOT)?.jar' -exec cp {} ${PROJECT_ROOT}apm-agent-java.jar \; || echo "INFO: No locally built image found" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid |
||
cp "${FILE}" "${PROJECT_ROOT}apm-agent-java.jar" || echo "INFO: No locally built image found" | ||
elif [ ! -z ${SONATYPE_FALLBACK+x} ] | ||
then | ||
echo "INFO: No local build artifact and SONATYPE_FALLBACK. Falling back to downloading artifact from Sonatype Nexus repository for version $RELEASE_VERSION" | ||
|
@@ -37,19 +39,27 @@ then | |
exit 1 | ||
fi | ||
|
||
echo "INFO: Starting Docker build for version $RELEASE_VERSION" | ||
ls -l apm-agent-java.jar | ||
|
||
docker build -t docker.elastic.co/$NAMESPACE/apm-agent-java:$RELEASE_VERSION \ | ||
--platform linux/amd64 \ | ||
--build-arg JAR_FILE=apm-agent-java.jar \ | ||
--build-arg HANDLER_FILE=apm-agent-lambda-layer/src/main/assembly/elastic-apm-handler . | ||
echo "INFO: Starting Docker build for version $RELEASE_VERSION" | ||
for DOCKERFILE in "Dockerfile" "Dockerfile.wolfi" ; do | ||
DOCKER_TAG=$RELEASE_VERSION | ||
if [[ $DOCKERFILE =~ "wolfi" ]]; then | ||
DOCKER_TAG="${RELEASE_VERSION}-wolfi" | ||
fi | ||
docker build -t docker.elastic.co/$NAMESPACE/apm-agent-java:$DOCKER_TAG \ | ||
--platform linux/amd64 \ | ||
--build-arg JAR_FILE=apm-agent-java.jar \ | ||
--build-arg HANDLER_FILE=apm-agent-lambda-layer/src/main/assembly/elastic-apm-handler \ | ||
--file $DOCKERFILE . | ||
|
||
if [ $? -eq 0 ] | ||
then | ||
echo "INFO: Docker image built successfully" | ||
else | ||
echo "ERROR: Problem building Docker image!" | ||
fi | ||
if [ $? -eq 0 ] | ||
then | ||
echo "INFO: Docker image built successfully" | ||
else | ||
echo "ERROR: Problem building Docker image!" | ||
fi | ||
done | ||
|
||
function finish { | ||
|
||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll eventually switch to just publishing the wolfi images, right?
When that happens I'd suggest to use an
ARG
for the base image:This way we can have a single Dockerfile which locally builts on top of Alpine, but from CI we can pass in the wolfi image as base image.
Nothing to do for now, just something to maybe keep in mind for when we drop publishing the alpine based image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, that's something we are still discussing internally