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 build #36

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.50)
AC_INIT(glb, 1.0.1, info@codership.com)
AC_INIT(glb, 1.0.2, info@codership.com)
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_SRCDIR([src/glb_main.c])
AC_CONFIG_HEADER([config.h])
Expand Down
6 changes: 3 additions & 3 deletions glbd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ fi
%endif

%changelog
* Tue Sep 26 2021 ALexey Yurchenko <alexey.yurchenko@galeracluster.com> - 1.0.1-1
- Remove gcc-c++ dependecy

* Wed Oct 20 2021 Alexey Bychko <alexey.bychko@galeracluster.com> - 1.0.1-1
- Initial RPM release

* Tue Sep 26 2021 ALexey Yurchenko <alexey..yurchenko@galeracluster.com> - 1.0.1-1
- Remove gcc-c++ dependecy
16 changes: 16 additions & 0 deletions packaging/build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -eu

# Resulting packages will be placed in the current working directory.
# Environment variables:
# GIT_BRANCH - which branch to build

GIT_BRANCH=${GIT_BRANCH:='master'}

DIRNAME=$(dirname $0)

BASE='centos:7' ${DIRNAME}/rpm/build.sh
BASE='rockylinux:8' ${DIRNAME}/rpm/build.sh

BASE='debian:stable' ${DIRNAME}/deb/build.sh
BASE='ubuntu:22.04' ${DIRNAME}/deb/build.sh
BASE='ubuntu:24.04' ${DIRNAME}/deb/build.sh
16 changes: 16 additions & 0 deletions packaging/deb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Use a base image with a Linux distribution of your choice
# that supports RPM package building, e.g., CentOS or Fedora.

ARG base=debian:stable
FROM ${base}

# Install necessary packages to build DEB
RUN apt-get update && \
apt-get install -y git dpkg-dev && \
apt-get install -y autoconf automake debhelper libtool && \
rm -rf /var/lib/apt/lists/*

# Set up the build script to be executed on docker run
COPY entrypoint.sh /root
WORKDIR /root
ENTRYPOINT /root/entrypoint.sh
17 changes: 17 additions & 0 deletions packaging/deb/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh -eu

# This script only relies on access to GitHub and can be run from anywhere.
# Resulting packages will be placed in the current working directory.
# Environment variables:
# GIT_BRANCH - which branch to build
# BASE - which distribution to use for packaging

GIT_BRANCH=${GIT_BRANCH:='master'}
BASE=${BASE:='debian:stable'}

docker buildx build -t glb-builder-${BASE} --build-arg base=${BASE} \
https://github.com/codership/glb.git\#${GIT_BRANCH}:packaging/deb/
mkdir -p ${BASE} # output dir for packages
rm -rf ${BASE}/*
docker run -v ${PWD}:/output --env GIT_BRANCH=${GIT_BRANCH} \
--env BASE=${BASE} glb-builder-${BASE}
21 changes: 21 additions & 0 deletions packaging/deb/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -eu

# Clone the GitHub repository using the specified branch
git clone --depth 1 --branch ${GIT_BRANCH:='master'} https://github.com/codership/glb /root/glb
cd glb

# Build the DEB package
dpkg-buildpackage -uc -us

# Verify if the DEB build was successful
if [ $? -eq 0 ]; then
echo "DEB package built successfully."
else
echo "Error: DEB package build failed."
exit 1
fi

# Move the DEB package to the mounted volume
OUTPUT=/output/${BASE}/
mv /root/*.deb ${OUTPUT}
echo "DEB package moved to: ${OUTPUT}"
19 changes: 19 additions & 0 deletions packaging/rpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Use a base image with a Linux distribution of your choice
# that supports RPM package building, e.g., CentOS or Fedora.

ARG base=rockylinux:8
FROM ${base}

# Install necessary packages to build RPM
RUN yum install -y epel-release && \
yum install -y git rpm-build rpmdevtools && \
yum install -y autoconf automake gcc libtool make && \
yum clean all

# Set up RPM build environment
RUN rpmdev-setuptree

# Set up the build script to be executed on docker run
COPY entrypoint.sh /root
WORKDIR /root
ENTRYPOINT /root/entrypoint.sh
17 changes: 17 additions & 0 deletions packaging/rpm/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh -eu

# This script only relies on access to GitHub and can be run from anywhere.
# Resulting packages will be placed in the current working directory.
# Environment variables:
# GIT_BRANCH - which branch to build
# BASE - which distribution to use for packaging

GIT_BRANCH=${GIT_BRANCH:='master'}
BASE=${BASE:='rockylinux:8'}

docker buildx build -t glb-builder-${BASE} --build-arg base=${BASE} \
https://github.com/codership/glb.git\#${GIT_BRANCH}:packaging/rpm/
mkdir -p ${BASE} # output dir for packages
rm -rf ${BASE}/*
docker run -v ${PWD}:/output --env GIT_BRANCH=${GIT_BRANCH} \
--env BASE=${BASE} glb-builder-${BASE}
36 changes: 36 additions & 0 deletions packaging/rpm/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash -eu

# Clone the GitHub repository using the specified branch
git clone --depth 1 --branch ${GIT_BRANCH:='master'} https://github.com/codership/glb /root/glb
cd glb

# Check if the RPM spec file exists
SPEC_FILE="glbd.spec"
if [ ! -f "$SPEC_FILE" ]; then
echo "Error: $SPEC_FILE not found in the current directory."
exit 1
fi

# Set the RPM build directory
RPMBUILD_DIR="${HOME}/rpmbuild"

# Find package version
GLBD_VERSION=$(grep Version: "$SPEC_FILE" | tr -s ' ' | cut -d ' ' -f 2)
PREFIX="glbd-${GLBD_VERSION:='x.y.z'}"
git archive --format=tar.gz -o /root/rpmbuild/SOURCES/${PREFIX}.tar.gz --prefix=${PREFIX}/ ${GIT_BRANCH}

# Build the RPM package
rpmbuild -ba "$SPEC_FILE"

# Verify if the RPM build was successful
if [ $? -eq 0 ]; then
echo "RPM package built successfully."
else
echo "Error: RPM package build failed."
exit 1
fi

# Move the RPM package to the mounted volume
OUTPUT="/output/${BASE}"
mv "${RPMBUILD_DIR}/RPMS/x86_64/"*.rpm "${OUTPUT}"
echo "RPM package moved to: ${OUTPUT}"
5 changes: 3 additions & 2 deletions src/glb_wdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ wdog_copy_result (wdog_dst_t* const d, double* const max_lat, int const lf)
if (others_len < res->others_len ||
others_len > (res->others_len * 2)) {
// buffer size is too different, reallocate
d->result.others = realloc (others, res->others_len);
if (!d->result.others && res->others_len > 0) {
void* const tmp = realloc (others, res->others_len);
if (!tmp && res->others_len > 0) {
// this is pretty much fatal, but we'll try
free (others);
d->result.others_len = 0;
Expand All @@ -339,6 +339,7 @@ wdog_copy_result (wdog_dst_t* const d, double* const max_lat, int const lf)
changed_length = true;
d->result.others_len = res->others_len;
}
d->result.others = tmp;
}

assert (d->result.others || 0 == d->result.others_len);
Expand Down