-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dockerfile to build DEB packages regardless of host OS
- Loading branch information
Showing
5 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/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 ${BASE} # output dir for packages | ||
docker run -v ${PWD}:/output --env GIT_BRANCH=${GIT_BRANCH} \ | ||
--env BASE=${BASE} glb-builder-${BASE} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters