Skip to content

Commit

Permalink
Add hook script and Makefile entry for datanode (#253)
Browse files Browse the repository at this point in the history
* Add hook script and Makefile entry for datanode
* Fix path to entrypoint
* Adjust Dockerfile for datanode for the build environment
* Fix VCS_REF setting
* Fix source URL label for data node
* Add graylog-datanode to release build steps
  • Loading branch information
bernd authored Apr 20, 2023
1 parent 6e1ab80 commit a18930d
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 21 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
export GIT_SHA1=$(git rev-parse --short HEAD)
export IMAGE_NAME=graylog

default: docker_build

docker_build:
cd docker/oss; hooks/build
cd docker/oss && IMAGE_NAME=graylog hooks/build
cd docker/enterprise && IMAGE_NAME=graylog-enterprise hooks/build
cd docker/forwarder && IMAGE_NAME=graylog-forwarder hooks/build
cd docker/datanode && IMAGE_NAME=graylog-datanode hooks/build

linter:
@test/linter.sh
Expand Down
16 changes: 9 additions & 7 deletions docker/datanode/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM ubuntu:22.04

# Build time variables - not persistent in the container image
ARG GRAYLOG_VERSION
ARG VCS_REF
ARG BUILD_DATE
ARG BUILD_VERSION
ARG SNAPSHOT_URL_X64
ARG SNAPSHOT_URL_AARCH64
ARG SNAPSHOT_URL_X64=https://downloads.graylog.org/releases/graylog-datanode/graylog-datanode-${GRAYLOG_VERSION}-linux-x64.tgz
ARG SNAPSHOT_URL_AARCH64=https://downloads.graylog.org/releases/graylog-datanode/graylog-datanode-${GRAYLOG_VERSION}-linux-aarch64.tgz
ARG DEBIAN_FRONTEND=noninteractive

# Will be persistet in the container image
Expand Down Expand Up @@ -63,20 +64,21 @@ RUN apt-get purge -y curl \
&& apt-get autoremove -y --purge \
&& rm -rf /var/log/*

COPY entrypoint.sh /entrypoint.sh
COPY docker/datanode/entrypoint.sh /entrypoint.sh

ENTRYPOINT ["tini", "--", "/entrypoint.sh"]
CMD ["graylog-datanode"]

# Put at the very end to avoid rebuilding all layers for ARG changes like
# BUILD_DATE, BUILD_REV, and BUILD_VERSION.
# BUILD_DATE, VCS_REV, and GRAYLOG_VERSION.
LABEL org.opencontainers.image.authors="Graylog, Inc. <[email protected]>"
LABEL org.opencontainers.image.created="$BUILD_DATE"
LABEL org.opencontainers.image.description="Container image to run the Graylog Data Node"
LABEL org.opencontainers.image.documentation="https://docs.graylog.org/"
LABEL org.opencontainers.image.licenses="SSPL-1.0"
LABEL org.opencontainers.image.source="https://github.com/Graylog2/graylog2-server"
LABEL org.opencontainers.image.revision="$VCS_REF"
LABEL org.opencontainers.image.source="https://github.com/Graylog2/graylog-docker"
LABEL org.opencontainers.image.title="Graylog Data Node"
LABEL org.opencontainers.image.url="https://www.graylog.org/"
LABEL org.opencontainers.image.vendor="Graylog, Inc."
LABEL org.opencontainers.image.version="$BUILD_VERSION"
LABEL org.opencontainers.image.version="$GRAYLOG_VERSION"
16 changes: 16 additions & 0 deletions docker/datanode/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Custom build for Docker Hub
# see: https://medium.com/microscaling-systems/labelling-automated-builds-on-docker-hub-f3d073fb8e1

cd ../..

apt-get install -y python3-pip
pip3 install pyyaml

# Build Graylog
docker build --build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg GRAYLOG_VERSION="$(./release.py --get-graylog-version)" \
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--file docker/datanode/Dockerfile \
--tag $IMAGE_NAME .
6 changes: 3 additions & 3 deletions docker/enterprise/hooks/build
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ apt-get install -y python3-pip
pip3 install pyyaml

# Build Graylog Enterprise & Integration Included
docker build --build-arg VCS_REF=$GIT_SHA1 \
--build-arg GRAYLOG_VERSION=`./release.py --get-graylog-version` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
docker build --build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg GRAYLOG_VERSION="$(./release.py --get-graylog-version)" \
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--file docker/enterprise/Dockerfile \
--tag $IMAGE_NAME .
8 changes: 4 additions & 4 deletions docker/forwarder/hooks/build
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ apt-get install -y python3-pip
pip3 install pyyaml

# Build Graylog Forwarder
docker build --build-arg VCS_REF=$GIT_SHA1 \
--build-arg GRAYLOG_FORWARDER_VERSION=`./release.py --get-forwarder-version` \
--build-arg GRAYLOG_FORWARDER_IMAGE_VERSION=`./release.py --get-forwarder-image-version` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
docker build --build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg GRAYLOG_FORWARDER_VERSION="$(./release.py --get-forwarder-version)" \
--build-arg GRAYLOG_FORWARDER_IMAGE_VERSION="$(./release.py --get-forwarder-image-version)" \
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--file docker/forwarder/Dockerfile \
--tag $IMAGE_NAME .
6 changes: 3 additions & 3 deletions docker/oss/hooks/build
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ apt-get install -y python3-pip
pip3 install pyyaml

# Build Graylog
docker build --build-arg VCS_REF=$GIT_SHA1 \
--build-arg GRAYLOG_VERSION=`./release.py --get-graylog-version` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
docker build --build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg GRAYLOG_VERSION="$(./release.py --get-graylog-version)" \
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--file docker/oss/Dockerfile \
--tag $IMAGE_NAME .
23 changes: 23 additions & 0 deletions jenkins.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ pipeline
--tag graylog/graylog:${MAJOR}.${MINOR}.${PATCH} \
--tag graylog/graylog:${MAJOR}.${MINOR}"""

TAG_ARGS_DATANODE = """--tag graylog/graylog-datanode:${env.TAG_NAME} \
--tag graylog/graylog-datanode:${MAJOR}.${MINOR}.${PATCH} \
--tag graylog/graylog-datanode:${MAJOR}.${MINOR}"""

TAG_ARGS_ENTERPRISE = """--tag graylog/graylog-enterprise:${env.TAG_NAME} \
--tag graylog/graylog-enterprise:${MAJOR}.${MINOR}.${PATCH} \
--tag graylog/graylog-enterprise:${MAJOR}.${MINOR}"""
Expand All @@ -86,6 +90,7 @@ pipeline
{
//This is an alpha/beta/rc release, so don't update the version tags
TAG_ARGS = "--tag graylog/graylog:${env.TAG_NAME}"
TAG_ARGS_DATANODE = "--tag graylog/graylog-datanode:${env.TAG_NAME}"
TAG_ARGS_ENTERPRISE = "--tag graylog/graylog-enterprise:${env.TAG_NAME}"
}

Expand All @@ -94,12 +99,14 @@ pipeline
sh 'docker run --rm --privileged multiarch/qemu-user-static --reset -p yes'
sh 'docker buildx create --name multiarch --driver docker-container --use | true'
sh 'docker buildx inspect --bootstrap'

sh """
docker buildx build \
--platform linux/amd64,linux/arm64/v8 \
--no-cache \
--build-arg GRAYLOG_VERSION=\$(./release.py --get-graylog-version) \
--build-arg BUILD_DATE=\$(date -u +\"%Y-%m-%dT%H:%M:%SZ\") \
--build-arg VCS_REF=\$(git rev-parse HEAD) \
${TAG_ARGS} \
--file docker/oss/Dockerfile \
--pull \
Expand All @@ -113,6 +120,21 @@ pipeline
--no-cache \
--build-arg GRAYLOG_VERSION=\$(./release.py --get-graylog-version) \
--build-arg BUILD_DATE=\$(date -u +\"%Y-%m-%dT%H:%M:%SZ\") \
--build-arg VCS_REF=\$(git rev-parse HEAD) \
${TAG_ARGS_DATANODE} \
--file docker/datanode/Dockerfile \
--pull \
--push \
.
"""

sh """
docker buildx build \
--platform linux/amd64,linux/arm64/v8 \
--no-cache \
--build-arg GRAYLOG_VERSION=\$(./release.py --get-graylog-version) \
--build-arg BUILD_DATE=\$(date -u +\"%Y-%m-%dT%H:%M:%SZ\") \
--build-arg VCS_REF=\$(git rev-parse HEAD) \
${TAG_ARGS_ENTERPRISE} \
--file docker/enterprise/Dockerfile \
--pull \
Expand Down Expand Up @@ -155,6 +177,7 @@ pipeline
--build-arg GRAYLOG_FORWARDER_VERSION=\$(./release.py --get-forwarder-version) \
--build-arg GRAYLOG_FORWARDER_IMAGE_VERSION=\$(./release.py --get-forwarder-image-version) \
--build-arg BUILD_DATE=\$(date -u +\"%Y-%m-%dT%H:%M:%SZ\") \
--build-arg VCS_REF=\$(git rev-parse HEAD) \
${TAG_ARGS} \
--file docker/forwarder/Dockerfile \
--pull \
Expand Down

0 comments on commit a18930d

Please sign in to comment.