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

Docker images for aarch64 #11866

Closed
wants to merge 1 commit into from
Closed
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
57 changes: 39 additions & 18 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ else
endif

IMAGE_FLAVORS ?= oss full
DEFAULT_IMAGE_FLAVOR ?= full

IMAGE_TAG := $(ELASTIC_REGISTRY)/logstash/logstash
HTTPD ?= logstash-docker-artifact-server

Expand All @@ -32,20 +30,10 @@ build-from-local-artifacts: venv dockerfile env2yaml
-p 8000:8000 --expose=8000 -v $(ARTIFACTS_DIR):/mnt \
python:3 bash -c 'cd /mnt && python3 -m http.server'
timeout 120 bash -c 'until curl -s localhost:8000 > /dev/null; do sleep 1; done'
pyfiglet -f puffy -w 160 "Building: full"; \
docker build --network=host -t $(IMAGE_TAG)-full:$(VERSION_TAG) -f $(ARTIFACTS_DIR)/Dockerfile-full data/logstash || \
pyfiglet -f puffy -w 160 "Building: $(IMAGE_TAG)-$(FLAVOR):$(VERSION_TAG)"; \
docker build --network=host -t $(IMAGE_TAG)-$(FLAVOR):$(VERSION_TAG) -f $(ARTIFACTS_DIR)/Dockerfile-$(FLAVOR) data/logstash || \
(docker kill $(HTTPD); false); \
docker tag $(IMAGE_TAG)-full:$(VERSION_TAG) $(IMAGE_TAG):$(VERSION_TAG);
docker kill $(HTTPD)

build-from-local-oss-artifacts: venv dockerfile env2yaml
docker run --rm -d --name=$(HTTPD) \
-p 8000:8000 --expose=8000 -v $(ARTIFACTS_DIR):/mnt \
python:3 bash -c 'cd /mnt && python3 -m http.server'
timeout 120 bash -c 'until curl -s localhost:8000 > /dev/null; do sleep 1; done'
pyfiglet -f puffy -w 160 "Building: oss"; \
docker build --network=host -t $(IMAGE_TAG)-oss:$(VERSION_TAG) -f $(ARTIFACTS_DIR)/Dockerfile-oss data/logstash || \
(docker kill $(HTTPD); false);
docker tag $(IMAGE_TAG)-$(FLAVOR):$(VERSION_TAG) $(IMAGE_TAG):$(VERSION_TAG);
-docker kill $(HTTPD)

COPY_FILES = $(ARTIFACTS_DIR)/docker/config/pipelines.yml $(ARTIFACTS_DIR)/docker/config/logstash-oss.yml $(ARTIFACTS_DIR)/docker/config/logstash-full.yml $(ARTIFACTS_DIR)/docker/config/log4j2.properties $(ARTIFACTS_DIR)/docker/pipeline/default.conf $(ARTIFACTS_DIR)/docker/bin/docker-entrypoint $(ARTIFACTS_DIR)/docker/env2yaml/env2yaml
Expand All @@ -72,18 +60,40 @@ public-dockerfiles: venv templates/Dockerfile.j2 docker_paths $(COPY_FILES)
jinja2 \
-D elastic_version='$(ELASTIC_VERSION)' \
-D version_tag='$(VERSION_TAG)' \
-D architecture='aarch64' \
-D image_flavor='full' \
-D local_artifacts='false' \
-D release='$(RELEASE)' \
templates/Dockerfile.j2 > $(ARTIFACTS_DIR)/Dockerfile-aarch64-full && \
jinja2 \
-D elastic_version='$(ELASTIC_VERSION)' \
-D version_tag='$(VERSION_TAG)' \
-D architecture='amd64' \
-D image_flavor='full' \
-D local_artifacts='false' \
-D release='$(RELEASE)' \
templates/Dockerfile.j2 > $(ARTIFACTS_DIR)/Dockerfile-full && \
jinja2 \
-D elastic_version='$(ELASTIC_VERSION)' \
-D version_tag='$(VERSION_TAG)' \
-D architecture='aarch64' \
-D image_flavor='oss' \
-D local_artifacts='false' \
-D release='$(RELEASE)' \
templates/Dockerfile.j2 > $(ARTIFACTS_DIR)/Dockerfile-oss && \
templates/Dockerfile.j2 > $(ARTIFACTS_DIR)/Dockerfile-aarch64-oss && \
jinja2 \
-D elastic_version='$(ELASTIC_VERSION)' \
-D version_tag='$(VERSION_TAG)' \
-D architecture='amd64' \
-D image_flavor='oss' \
-D local_artifacts='false' \
-D release='$(RELEASE)' \
templates/Dockerfile.j2 > $(ARTIFACTS_DIR)/Dockerfile-oss && \
cd $(ARTIFACTS_DIR)/docker && \
cp $(ARTIFACTS_DIR)/Dockerfile-aarch64-full Dockerfile && \
tar -zcf ../logstash-aarch64-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline && \
cp $(ARTIFACTS_DIR)/Dockerfile-aarch64-oss Dockerfile && \
tar -zcf ../logstash-aarch64-oss-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline && \
cp $(ARTIFACTS_DIR)/Dockerfile-full Dockerfile && \
tar -zcf ../logstash-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline && \
cp $(ARTIFACTS_DIR)/Dockerfile-oss Dockerfile && \
Expand All @@ -93,8 +103,11 @@ public-dockerfiles: venv templates/Dockerfile.j2 docker_paths $(COPY_FILES)
push:
$(foreach FLAVOR, $(IMAGE_FLAVORS), \
docker tag $(IMAGE_TAG)-$(FLAVOR):$(VERSION_TAG) push.$(IMAGE_TAG)-$(FLAVOR):$(VERSION_TAG); \
docker tag $(IMAGE_TAG)-aarch64-$(FLAVOR):$(VERSION_TAG) push.$(IMAGE_TAG)-aarch64-$(FLAVOR):$(VERSION_TAG); \
docker push push.$(IMAGE_TAG)-$(FLAVOR):$(VERSION_TAG); \
docker push push.$(IMAGE_TAG)-aarch64-$(FLAVOR):$(VERSION_TAG); \
docker rmi push.$(IMAGE_TAG)-$(FLAVOR):$(VERSION_TAG); \
docker rmi push.$(IMAGE_TAG)-aarch64-$(FLAVOR):$(VERSION_TAG); \
)
# Also push the default version, with no suffix like '-oss' or '-full'
docker tag $(IMAGE_TAG):$(VERSION_TAG) push.$(IMAGE_TAG):$(VERSION_TAG);
Expand Down Expand Up @@ -129,15 +142,23 @@ env2yaml: golang
-v $(PWD)/data/logstash/env2yaml:/usr/local/src/env2yaml:Z \
golang:env2yaml

# Generate the Dockerfiles from Jinja2 templates.
# # Generate the Dockerfiles from Jinja2 templates.
dockerfile: venv templates/Dockerfile.j2
$(foreach FLAVOR, $(IMAGE_FLAVORS), \
jinja2 \
-D elastic_version='$(ELASTIC_VERSION)' \
-D version_tag='$(VERSION_TAG)' \
-D image_flavor='$(FLAVOR)' \
-D architecture='aarch64' \
-D local_artifacts='true' \
templates/Dockerfile.j2 > $(ARTIFACTS_DIR)/Dockerfile-$(FLAVOR); \
templates/Dockerfile.j2 > $(ARTIFACTS_DIR)/Dockerfile-aarch64-$(FLAVOR) && \
jinja2 \
-D elastic_version='$(ELASTIC_VERSION)' \
-D version_tag='$(VERSION_TAG)' \
-D image_flavor='$(FLAVOR)' \
-D architecture='amd64' \
-D local_artifacts='true' \
templates/Dockerfile.j2 > $(ARTIFACTS_DIR)/Dockerfile-$(FLAVOR); \
)

clean:
Expand Down
8 changes: 7 additions & 1 deletion docker/templates/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
{% set url_root = 'http://localhost:8000' -%}
{% endif -%}

{% if architecture == 'aarch64' -%}
{% set base_image = 'arm64v8/centos:7' -%}
{% else -%}
{% set base_image = 'centos:7'-%}
{% endif -%}

{% if image_flavor == 'oss' -%}
{% set tarball = 'logstash-oss-%s.tar.gz' % elastic_version -%}
{% else -%}
{% set tarball = 'logstash-%s.tar.gz' % elastic_version -%}
{% endif -%}


FROM centos:7
FROM {{ base_image }}

# Install Java and the "which" command, which is needed by Logstash's shell
# scripts.
Expand Down
27 changes: 19 additions & 8 deletions rakelib/artifacts.rake
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,25 @@ namespace "artifact" do
desc "Build docker image"
task "docker" => ["prepare", "generate_build_metadata", "tar"] do
puts("[docker] Building docker image")
build_docker(false)
build_docker(false, 'amd64')
end

desc "Build docker image"
task "docker_aarch64" => ["prepare", "generate_build_metadata", "tar"] do
puts("[docker_aarch64] Building aarch64 docker image")
build_docker(false, 'aarch64')
end

desc "Build OSS docker image"
task "docker_oss" => ["prepare", "generate_build_metadata", "tar_oss"] do
puts("[docker_oss] Building OSS docker image")
build_docker(true)
build_docker(true, 'amd64')
end

desc "Build OSS docker image"
task "docker_aarch64_oss" => ["prepare", "generate_build_metadata", "tar_oss"] do
puts("[docker_aarch64_oss] Building aarch64 OSS docker image")
build_docker(true, 'aarch64')
end

desc "Generate Dockerfile for default and oss images"
Expand All @@ -226,7 +238,9 @@ namespace "artifact" do
Rake::Task["artifact:tar_oss"].invoke
unless ENV['SKIP_DOCKER'] == "1"
Rake::Task["artifact:docker"].invoke
Rake::Task["artifact:docker_aarch64"].invoke
Rake::Task["artifact:docker_oss"].invoke
Rake::Task["artifact:docker_aarch64_oss"].invoke
Rake::Task["artifact:dockerfiles"].invoke
end
end
Expand Down Expand Up @@ -555,18 +569,15 @@ namespace "artifact" do
end
end # def package

def build_docker(oss = false)
def build_docker(oss = false, architecture = 'amd64')
env = {
"ARTIFACTS_DIR" => ::File.join(Dir.pwd, "build"),
"RELEASE" => ENV["RELEASE"],
"FLAVOR" => "#{architecture == 'aarch64' ? 'aarch64-' : '' }#{oss ? 'oss' : 'full'}",
"VERSION_QUALIFIER" => VERSION_QUALIFIER
}
Dir.chdir("docker") do |dir|
if oss
system(env, "make build-from-local-oss-artifacts")
else
system(env, "make build-from-local-artifacts")
end
system(env, "make build-from-local-artifacts")
end
end

Expand Down