Skip to content

Commit b640e7e

Browse files
robbaveyandsel
andauthored
Add arm64 support for env2yaml (elastic#15980)
* Add arm64 support for env2yaml This commit builds env2yaml in arm64 and amd64 flavors, and uses $TARGETARCH in the Dockerfile to ensure that the correct version is used when building for alternative architectures Fixes: elastic#15913 * Add env2yaml executables to build context * Split `COPY_FILES` for readability Co-authored-by: Andrea Selva <[email protected]> --------- Co-authored-by: Andrea Selva <[email protected]>
1 parent dec53ba commit b640e7e

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

docker/Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ build-from-local-ubi8-artifacts: dockerfile env2yaml
5656

5757
COPY_FILES := $(ARTIFACTS_DIR)/docker/config/pipelines.yml $(ARTIFACTS_DIR)/docker/config/logstash-oss.yml $(ARTIFACTS_DIR)/docker/config/logstash-full.yml
5858
COPY_FILES += $(ARTIFACTS_DIR)/docker/config/log4j2.file.properties $(ARTIFACTS_DIR)/docker/config/log4j2.properties
59-
COPY_FILES += $(ARTIFACTS_DIR)/docker/pipeline/default.conf $(ARTIFACTS_DIR)/docker/bin/docker-entrypoint $(ARTIFACTS_DIR)/docker/env2yaml/env2yaml
59+
COPY_FILES += $(ARTIFACTS_DIR)/docker/pipeline/default.conf $(ARTIFACTS_DIR)/docker/bin/docker-entrypoint
60+
COPY_FILES += $(ARTIFACTS_DIR)/docker/env2yaml/env2yaml-arm64
61+
COPY_FILES += $(ARTIFACTS_DIR)/docker/env2yaml/env2yaml-amd64
6062

6163
$(ARTIFACTS_DIR)/docker/config/pipelines.yml: data/logstash/config/pipelines.yml
6264
$(ARTIFACTS_DIR)/docker/config/logstash-oss.yml: data/logstash/config/logstash-oss.yml
@@ -65,7 +67,8 @@ $(ARTIFACTS_DIR)/docker/config/log4j2.file.properties: data/logstash/config/log4
6567
$(ARTIFACTS_DIR)/docker/config/log4j2.properties: data/logstash/config/log4j2.properties
6668
$(ARTIFACTS_DIR)/docker/pipeline/default.conf: data/logstash/pipeline/default.conf
6769
$(ARTIFACTS_DIR)/docker/bin/docker-entrypoint: data/logstash/bin/docker-entrypoint
68-
$(ARTIFACTS_DIR)/docker/env2yaml/env2yaml: data/logstash/env2yaml/env2yaml
70+
$(ARTIFACTS_DIR)/docker/env2yaml/env2yaml-arm64: data/logstash/env2yaml/env2yaml-arm64
71+
$(ARTIFACTS_DIR)/docker/env2yaml/env2yaml-amd64: data/logstash/env2yaml/env2yaml-amd64
6972

7073
$(ARTIFACTS_DIR)/docker/%:
7174
cp -f $< $@
@@ -184,7 +187,12 @@ push:
184187
env2yaml:
185188
docker run --rm \
186189
-v "$(PWD)/data/logstash/env2yaml:/usr/src/env2yaml" \
187-
-w /usr/src/env2yaml golang:1 go build
190+
-e GOARCH=arm64 -e GOOS=linux \
191+
-w /usr/src/env2yaml golang:1 go build -o /usr/src/env2yaml/env2yaml-arm64
192+
docker run --rm \
193+
-v "$(PWD)/data/logstash/env2yaml:/usr/src/env2yaml" \
194+
-e GOARCH=amd64 -e GOOS=linux \
195+
-w /usr/src/env2yaml golang:1 go build -o /usr/src/env2yaml/env2yaml-amd64
188196

189197
# Generate the Dockerfiles from ERB templates.
190198
dockerfile: templates/Dockerfile.erb
@@ -200,6 +208,7 @@ dockerfile: templates/Dockerfile.erb
200208
)
201209

202210
clean:
203-
rm -f ${ARTIFACTS_DIR}/env2yaml/env2yaml ${ARTIFACTS_DIR}/Dockerfile
211+
rm -f ${ARTIFACTS_DIR}/env2yaml/env2yaml-* ${ARTIFACTS_DIR}/Dockerfile
212+
204213

205214
.PHONY: clean push

docker/templates/Dockerfile.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ COPY pipeline/default.conf pipeline/logstash.conf
147147
RUN chown --recursive logstash:root config/ pipeline/
148148
# Ensure Logstash gets the correct locale by default.
149149
ENV LANG=<%= locale %> LC_ALL=<%= locale %>
150-
COPY env2yaml/env2yaml /usr/local/bin/
150+
# Copy over the appropriate env2yaml artifact
151+
ARG TARGETARCH
152+
COPY env2yaml/env2yaml-${TARGETARCH} /usr/local/bin/env2yaml
151153
# Place the startup wrapper script.
152154
COPY bin/docker-entrypoint /usr/local/bin/
153155
<% else -%>

0 commit comments

Comments
 (0)