Skip to content
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

Add a command for building the artifacts inside Docker #9609

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ task assembleOssZipDistribution(dependsOn: downloadAndInstallJRuby) {
}
}

task dockerBuildArtifacts(type: Exec) {
commandLine "sh", "-c", "./ci/docker_build_artifacts.sh"
}

def logstashBuildDir = "${buildDir}/logstash-${project.version}-SNAPSHOT"

task unpackTarDistribution(dependsOn: assembleTarDistribution, type: Copy) {
Expand Down
13 changes: 13 additions & 0 deletions ci/docker_build_artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# This should be called from top repository folder.
# It runs the `rake artifact:all` command in a docker image that has the required
# dependencies.
#
# The artifacts will be placed in the build/ folder.

docker build -f rakelib/Dockerfile.artifacts -t ls-artifacts rakelib/
docker run --rm \
-v $(pwd):/logstash:delegated \
ls-artifacts \
sh -c "cd logstash && rake artifact:all"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason this breaks on docker is that we don't have a gradle task for it. If we had ./gradlew artifactAll invoke the rake task it would probably not segfault. Here's an example gradle task that invokes rake https://github.com/elastic/logstash/blob/master/build.gradle#L176

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that does the trick, I'll update the PR.

18 changes: 18 additions & 0 deletions rakelib/Dockerfile.artifacts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This image contains the right dependencies to run `rake artifacts:all`
# Example usage:
#
# docker build -f rakelib/Dockerfile.artifacts -t ls-artifacts rakelib/
# docker run -it --rm -v `pwd`:/logstash:delegated ls-artifacts sh -c "cd logstash && rake artifact:all"
#
# Note that it seems that rake is a particularly bad case scenario for the
# docker osxfs driver (it touches 10s of K of files). Hence the `:delegated`
# parameter above is needed to get things to work at all, but it is still slow
# and it's going to consume a lot of CPU.
#
# See https://docs.docker.com/docker-for-mac/osxfs/#performance-issues-solutions-and-roadmap
FROM jruby:9

RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
default-jdk git binutils rpm