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

Fixed a bug in Docker image build #61

Merged
merged 1 commit into from
Aug 17, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 62 additions & 6 deletions .github/workflows/docker_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func_usage()
echo " antpickax/image:1.0.0-alpine (imagetag is \"alpine\")"
echo " antpickax/image:1.0.0 (imagetag is not specified)"
echo ""
echo " This program uses the GITHUB_REF and GITHUB_EVENT_NAME environment variable internally."
echo " This program uses folowing environment variable internally."
echo " GITHUB_REPOSITORY"
echo " GITHUB_REF"
echo " GITHUB_EVENT_NAME"
echo " GITHUB_EVENT_PATH"
echo ""
}

Expand Down Expand Up @@ -235,19 +239,19 @@ fi
#
# Version
#
GITHUB_REF_VERSION=
TAGGED_VERSION=
if [ "X${GITHUB_REF}" != "X" ]; then
echo ${GITHUB_REF} | grep 'refs/tags/' >/dev/null 2>&1
if [ $? -eq 0 ]; then
GITHUB_REF_VERSION=$(echo ${GITHUB_REF} | sed -e 's#refs/tags/v##g' -e 's#refs/tags/##g')
TAGGED_VERSION=$(echo ${GITHUB_REF} | sed -e 's#refs/tags/v##g' -e 's#refs/tags/##g')
fi
fi
if [ "X${IMAGE_VERSION}" = "X" ]; then
if [ "X${GITHUB_REF_VERSION}" != "X" ]; then
if [ "X${TAGGED_VERSION}" != "X" ]; then
#
# From Github ref
#
IMAGE_VERSION=${GITHUB_REF_VERSION}
IMAGE_VERSION=${TAGGED_VERSION}
else
#
# From RELEASE_VERSION file
Expand Down Expand Up @@ -284,14 +288,59 @@ else
if [ "X${GITHUB_EVENT_NAME}" = "Xschedule" ]; then
DO_PUSH=0
else
if [ "X${GITHUB_REF_VERSION}" != "X" ]; then
if [ "X${TAGGED_VERSION}" != "X" ]; then
DO_PUSH=1
else
DO_PUSH=0
fi
fi
fi

#
# Base Repository/SHA1 for creating Docker images
#
if [ "X${GITHUB_EVENT_NAME}" = "Xpull_request" ]; then
# [NOTE]
# In the PR case, GITHUB_REPOSITORY and GITHUB_REF cannot be used
# because they are the information on the merging side.
# Then the Organization/Repository/branch(or SHA1) of the PR source
# is fetched from the file(json) indicated by the GITHUB_EVENT_PATH
# environment variable.
# ex.
# {
# "pull_request": {
# "head": {
# "repo": {
# "full_name": "org/repo",
# },
# "sha": "776........",
# },
# },
# }
#
if [ ! -f ${GITHUB_EVENT_PATH} ]; then
echo "[ERROR] ${PRGNAME} : \"GITHUB_EVENT_PATH\" environment is empty or not file path."
exit 1
fi

# [NOTE]
# we need "jq" for parsing json
#
PR_GITHUB_REPOSITORY=$(jq -r '.pull_request.head.repo.full_name' ${GITHUB_EVENT_PATH})
DOCKER_GIT_ORGANIZATION=$(echo ${PR_GITHUB_REPOSITORY} | sed 's#/# #g' | awk '{print $1}')
DOCKER_GIT_REPOSITORY=$(echo ${PR_GITHUB_REPOSITORY} | sed 's#/# #g' | awk '{print $2}')
DOCKER_GIT_BRANCH=$(jq -r '.pull_request.head.sha' ${GITHUB_EVENT_PATH})

else
DOCKER_GIT_ORGANIZATION=$(echo ${GITHUB_REPOSITORY} | sed 's#/# #g' | awk '{print $1}')
DOCKER_GIT_REPOSITORY=$(echo ${GITHUB_REPOSITORY} | sed 's#/# #g' | awk '{print $2}')
DOCKER_GIT_BRANCH=$(echo ${GITHUB_REF} | sed 's#^refs/.*/##g')
fi
if [ "X${DOCKER_GIT_ORGANIZATION}" = "X" ] || [ "X${DOCKER_GIT_REPOSITORY}" = "X" ] || [ "X${DOCKER_GIT_BRANCH}" = "X" ]; then
echo "[ERROR] ${PRGNAME} : Not found Organization/Repository/branch(or SHA1)."
exit 1
fi

#
# Load variables file
#
Expand All @@ -318,6 +367,9 @@ echo " DOCKER_IMAGE_INFO = ${DOCKER_IMAGE_INFO}"
echo " DOCKER_IMAGE_BASE = ${DOCKER_IMAGE_BASE}"
echo " DOCKER_IMAGE_DEV_BASE = ${DOCKER_IMAGE_DEV_BASE}"
echo " DOCKER_IMAGE_OSTYPE = ${DOCKER_IMAGE_OSTYPE}"
echo " DOCKER_GIT_ORGANIZATION = ${DOCKER_GIT_ORGANIZATION}"
echo " DOCKER_GIT_REPOSITORY = ${DOCKER_GIT_REPOSITORY}"
echo " DOCKER_GIT_BRANCH = ${DOCKER_GIT_BRANCH}"
echo " DEFAULT_IMAGE_TAGGING = ${DEFAULT_IMAGE_TAGGING}"
echo " DOCKER_HUB_ORG = ${DOCKER_HUB_ORG}"
echo " IMAGE_NAMES = ${IMAGE_NAMES}"
Expand All @@ -329,6 +381,7 @@ echo " PKGMGR_UPDATE_OPT = ${PKGMGR_UPDATE_OPT}"
echo " PKGMGR_INSTALL_OPT = ${PKGMGR_INSTALL_OPT}"
echo " PKG_INSTALL_LIST_BUILDER = ${PKG_INSTALL_LIST_BUILDER}"
echo " PKG_INSTALL_LIST_BIN = ${PKG_INSTALL_LIST_BIN}"
echo " BUILDER_CONFIGURE_FLAG = ${BUILDER_CONFIGURE_FLAG}"
echo " BUILDER_MAKE_FLAGS = ${BUILDER_MAKE_FLAGS}"
echo " BUILDER_ENVIRONMENT = ${BUILDER_ENVIRONMENT}"
echo " RUNNER_INSTALL_PACKAGES = ${RUNNER_INSTALL_PACKAGES}"
Expand Down Expand Up @@ -420,6 +473,9 @@ fi
cat ${BUILDUTILS_DIR}/${DOCKER_TEMPL_FILE} | \
sed -e "s#%%DOCKER_IMAGE_BASE%%#${DOCKER_IMAGE_BASE}#g" \
-e "s#%%DOCKER_IMAGE_DEV_BASE%%#${DOCKER_IMAGE_DEV_BASE}#g" \
-e "s#%%DOCKER_GIT_ORGANIZATION%%#${DOCKER_GIT_ORGANIZATION}#g" \
-e "s#%%DOCKER_GIT_REPOSITORY%%#${DOCKER_GIT_REPOSITORY}#g" \
-e "s#%%DOCKER_GIT_BRANCH%%#${DOCKER_GIT_BRANCH}#g" \
-e "s#%%PKG_UPDATE%%#${PKGMGR_NAME} ${PKGMGR_UPDATE_OPT}#g" \
-e "s#%%PKG_INSTALL_BUILDER%%#${PKG_INSTALL_BUILDER_COMMAND}#g" \
-e "s#%%PKG_INSTALL_BIN%%#${PKG_INSTALL_BIN_COMMAND}#g" \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/imagetypevars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ if [ "X${DOCKER_IMAGE_OSTYPE}" = "Xalpine" ]; then

elif [ "X${DOCKER_IMAGE_OSTYPE}" = "Xubuntu" ]; then
PKGMGR_NAME="apt-get"
PKGMGR_UPDATE_OPT="update -q -y"
PKGMGR_INSTALL_OPT="install -q -y"
PKGMGR_UPDATE_OPT="update -qq -y"
PKGMGR_INSTALL_OPT="install -qq -y"
PKG_INSTALL_LIST_BUILDER="git autoconf autotools-dev gcc g++ make gdb dh-make fakeroot dpkg-dev devscripts libtool pkg-config procps libgcrypt20-dev"
PKG_INSTALL_LIST_BIN=""

Expand Down
45 changes: 22 additions & 23 deletions buildutils/Dockerfile.templ.in
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# syntax=docker/dockerfile:1
#
# Utility tools for building configure/packages by AntPickax
# K2HASH
#
# Copyright 2021 Yahoo Japan Corporation.
# Copyright 2013 Yahoo Japan Corporation.
#
# AntPickax provides utility tools for supporting autotools
# builds.
# K2HASH is key-valuew store base libraries.
# K2HASH is made for the purpose of the construction of
# original KVS system and the offer of the library.
# The characteristic is this KVS library which Key can
# layer. And can support multi-processing and multi-thread,
# and is provided safely as available KVS.
#
# These tools retrieve the necessary information from the
# repository and appropriately set the setting values of
# configure, Makefile, spec,etc file and so on.
# These tools were recreated to reduce the number of fixes and
# reduce the workload of developers when there is a change in
# the project configuration.
#
# For the full copyright and license information, please view
# the license file that was distributed with this source code.
#
Expand All @@ -25,19 +22,20 @@
# [NOTE]
# This file expects the following variables to be expanded by autoconf.
# GIT_DOMAIN
# GIT_ORG
# GIT_REPO
# PACKAGE_NAME
#
# Also, replace the following variables.
# DOCKER_IMAGE_BASE (ex. "antpickax/libfullock:latest")
# DOCKER_IMAGE_DEV_BASE (ex. "antpickax/libfullock-dev:latest")
# PKG_UPDATE (ex. "apk update -q --no-progress")
# PKG_INSTALL_BUILDER (ex. "apk add -q --no-progress --no-cache git build-base openssl libtool automake autoconf procps")
# PKG_INSTALL_BIN (ex. "apk add -q --no-progress --no-cache libstdc++")
# CONFIGURE_FLAG (ex. "--with-gcrypt")
# BUILD_FLAGS (ex. "CXXFLAGS=-Wno-address-of-packed-member")
# BUILD_ENV (ex, "ENV DEBIAN_FRONTEND=noninteractive")
# DOCKER_IMAGE_BASE (ex. "antpickax/libfullock:latest")
# DOCKER_IMAGE_DEV_BASE (ex. "antpickax/libfullock-dev:latest")
# DOCKER_GIT_ORGANIZATION (ex. "antpickax")
# DOCKER_GIT_REPOSITORY (ex. "xxxxx")
# DOCKER_GIT_BRANCH (ex. "yyyyy")
# PKG_UPDATE (ex. "apk update -q --no-progress")
# PKG_INSTALL_BUILDER (ex. "apk add -q --no-progress --no-cache git build-base openssl libtool automake autoconf procps")
# PKG_INSTALL_BIN (ex. "apk add -q --no-progress --no-cache libstdc++")
# CONFIGURE_FLAG (ex. "--with-gcrypt")
# BUILD_FLAGS (ex. "CXXFLAGS=-Wno-address-of-packed-member")
# BUILD_ENV (ex, "ENV DEBIAN_FRONTEND=noninteractive")
#

#
Expand All @@ -55,8 +53,9 @@ RUN set -x && \
%%PKG_UPDATE%% && \
%%PKG_INSTALL_BUILDER%% && \
cd / && \
git clone https://@GIT_DOMAIN@/@GIT_ORG@/@[email protected] && \
cd @GIT_REPO@ && \
git clone https://@GIT_DOMAIN@/%%DOCKER_GIT_ORGANIZATION%%/%%DOCKER_GIT_REPOSITORY%%.git && \
cd %%DOCKER_GIT_REPOSITORY%% && \
git checkout %%DOCKER_GIT_BRANCH%% && \
./autogen.sh && \
./configure %%CONFIGURE_FLAG%% && \
make %%BUILD_FLAGS%% && \
Expand Down
19 changes: 8 additions & 11 deletions buildutils/k2hash.postinst
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#!/bin/sh
#
# Utility tools for building configure/packages by AntPickax
# K2HASH
#
# Copyright 2021 Yahoo Japan Corporation.
# Copyright 2013 Yahoo Japan Corporation.
#
# AntPickax provides utility tools for supporting autotools
# builds.
# K2HASH is key-valuew store base libraries.
# K2HASH is made for the purpose of the construction of
# original KVS system and the offer of the library.
# The characteristic is this KVS library which Key can
# layer. And can support multi-processing and multi-thread,
# and is provided safely as available KVS.
#
# These tools retrieve the necessary information from the
# repository and appropriately set the setting values of
# configure, Makefile, spec,etc file and so on.
# These tools were recreated to reduce the number of fixes and
# reduce the workload of developers when there is a change in
# the project configuration.
#
# For the full copyright and license information, please view
# the license file that was distributed with this source code.
#
Expand Down