Skip to content

Commit 175f957

Browse files
Add new docker Multi-Arch image building scripts for logstash-output-opensearch (#41)
* Add new docker building scripts for logstash Signed-off-by: Peter Zhu <[email protected]> * Move build related vars to the top Signed-off-by: Peter Zhu <[email protected]>
1 parent d96fa12 commit 175f957

File tree

7 files changed

+55
-87
lines changed

7 files changed

+55
-87
lines changed

dockerfiles/docker-compose.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

dockerfiles/run.sh

Lines changed: 0 additions & 54 deletions
This file was deleted.

release/docker/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.gem

dockerfiles/Dockerfile renamed to release/docker/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# VERSION: Optional. Specify the label for image. Defaults to 7.13.2
1313

1414
ARG VERSION
15-
ARG ARCH
16-
FROM docker.elastic.co/logstash/logstash-oss:${VERSION}-${ARCH}
15+
FROM docker.elastic.co/logstash/logstash-oss:${VERSION}
1716
USER logstash
18-
COPY --chown=logstash:logstash dockerfiles/bin/logstash-output-opensearch-*.gem /tmp/logstash-output-opensearch.gem
19-
COPY --chown=logstash:logstash dockerfiles/logstash-opensearch-sample.conf /usr/share/logstash/config/
17+
COPY --chown=logstash:logstash ./logstash-output-opensearch-*.gem /tmp/logstash-output-opensearch.gem
18+
COPY --chown=logstash:logstash ./logstash-opensearch-sample.conf /usr/share/logstash/config/
2019
RUN /usr/share/logstash/bin/logstash-plugin install /tmp/logstash-output-opensearch.gem
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# This is intended to be run the plugin's root directory. `dockerfiles/run.sh`
7+
# Ensure you have Docker and docker-compose installed locally
8+
set -e
9+
10+
# Variables
11+
BUILDER_NUM=`date +%s`
12+
BUILDER_NAME="multiarch_${BUILDER_NUM}"
13+
14+
# Imports and functions
15+
function cleanup_docker_buildx() {
16+
# Cleanup docker buildx
17+
echo -e "\n* Cleanup docker buildx"
18+
docker buildx use default
19+
docker buildx rm $BUILDER_NAME > /dev/null 2>&1
20+
}
21+
22+
# Building plugin
23+
bash build-plugin.sh
24+
25+
# Identify Logstash version
26+
version=${LOGSTASH_VERSION}
27+
if [[ -z "$version" ]]; then
28+
version=7.13.2
29+
fi
30+
31+
# Prepare docker buildx
32+
trap cleanup_docker_buildx TERM INT EXIT
33+
echo -e "\n* Prepare docker buildx"
34+
docker buildx use default
35+
docker buildx create --name $BUILDER_NAME --use
36+
docker buildx inspect --bootstrap
37+
38+
# Check buildx status
39+
echo -e "\n* Check buildx status"
40+
docker buildx ls | grep $BUILDER_NAME
41+
docker ps | grep $BUILDER_NAME
42+
43+
# Docker Build Images
44+
docker buildx build --platform linux/amd64,linux/arm64 --build-arg VERSION=$version -t opensearchstaging/logstash-oss-with-opensearch-output-plugin:$version -f Dockerfile --push .
45+

dockerfiles/build.sh renamed to release/docker/build-plugin.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
# Ensure you have Docker installed locally and set the VERSION and BUILD_DATE environment variable.
1313
set -e
1414

15-
if [ -d dockerfiles/bin ]; then
16-
rm -rf dockerfiles/bin
17-
fi
15+
echo 'Clear previous gem'
16+
echo -n "Remove "; rm -rfv logstash-output-opensearch*.gem
1817

19-
mkdir -p dockerfiles/bin
18+
echo 'Copy gemspec'
19+
trap '{ echo -n "Remove "; rm -rfv logstash-output-opensearch.gemspec; }' INT TERM EXIT
20+
cp -v ../../logstash-output-opensearch.gemspec .
2021

21-
echo 'Building plugin'
22+
echo 'Building plugin gem'
2223
gem build logstash-output-opensearch.gemspec
2324

24-
echo "Moving gem to bin directory"
25-
mv logstash-output-opensearch*.gem dockerfiles/bin/

0 commit comments

Comments
 (0)