mirror of
https://github.com/zokradonh/kopano-docker.git
synced 2026-08-25 07:05:38 +00:00
Separate out testing dependencies to be more independent of travis
* move docker-hub-helper in a general ci folder * move installation of tools into dedicated script (will make it easier to use a different ci platform) * mention the setup-tools script in contributing and move testing instructions in there as well
This commit is contained in:
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
# bash .travis/docker-hub-helper.sh base
|
||||
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
# this is a kind of ugly hack to be able to source the env file
|
||||
# this is sadly needed since postfix in https://github.com/tomav/docker-mailserver/ cannot deal with quoted values
|
||||
tmpfile=$(mktemp /tmp/kopano-docker-env.XXXXXX)
|
||||
cp ./.env "$tmpfile"
|
||||
sed -i '/LDAP_QUERY_FILTER/s/^/#/g' "$tmpfile"
|
||||
sed -i '/SASLAUTHD_LDAP_FILTER/s/^/#/g' "$tmpfile"
|
||||
# shellcheck disable=SC1090
|
||||
source "$tmpfile"
|
||||
|
||||
docker_repo=${docker_repo:-zokradonh}
|
||||
docker_login=${docker_login:-""}
|
||||
docker_pwd=${docker_pwd:-""}
|
||||
|
||||
if [ -z "$docker_login" ]; then
|
||||
docker_login="$(<~/.docker-account-user)"
|
||||
fi
|
||||
|
||||
if [ -z "$docker_pwd" ]; then
|
||||
docker_pwd="$(<~/.docker-account-pwd)"
|
||||
fi
|
||||
|
||||
image=${1:-""}
|
||||
if [ -z "$image" ]; then
|
||||
echo "ERROR: You must specify an image to modify."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# below code is based on https://github.com/moikot/golang-dep/blob/aab3ea8462a19407544f1ce9daa11c3f0924394c/.travis/push.sh
|
||||
#
|
||||
# Pushes README.md content to Docker Hub.
|
||||
#
|
||||
# $1 - The image name.
|
||||
# $2 - The JWT.
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# push_readme "foo/bar" "token"
|
||||
#
|
||||
push_readme() {
|
||||
declare -r image="${1}"
|
||||
declare -r token="${2}"
|
||||
declare -r readme="${3}"
|
||||
|
||||
local code
|
||||
code=$(jq -n --arg msg "$(<"${readme}")" \
|
||||
'{"registry":"registry-1.docker.io","full_description": $msg }' | \
|
||||
curl -s -o /dev/null -L -w "%{http_code}" \
|
||||
https://cloud.docker.com/v2/repositories/"${image}"/ \
|
||||
-d @- -X PATCH \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: JWT ${token}")
|
||||
|
||||
if [[ "${code}" = "200" ]]; then
|
||||
printf "Successfully pushed README to Docker Hub"
|
||||
else
|
||||
printf "Unable to push README to Docker Hub, response code: %s\n" "${code}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local code
|
||||
code=$(jq -n --arg msg "$(head -n 1 "${readme}" | cut -d' ' -f2-)" \
|
||||
'{"registry":"registry-1.docker.io","description": $msg }' | \
|
||||
curl -s -o /dev/null -L -w "%{http_code}" \
|
||||
https://cloud.docker.com/v2/repositories/"${image}"/ \
|
||||
-d @- -X PATCH \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: JWT ${token}")
|
||||
|
||||
if [[ "${code}" = "200" ]]; then
|
||||
printf "Successfully pushed description to Docker Hub"
|
||||
else
|
||||
printf "Unable to push description to Docker Hub, response code: %s\n" "${code}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Login into Docker repository
|
||||
#echo "$docker_pwd" | docker login -u "$docker_login" --password-stdin
|
||||
|
||||
token=$(curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username": "'"$docker_login"'", "password": "'"$docker_pwd"'"}' \
|
||||
https://hub.docker.com/v2/users/login/ | jq -r .token)
|
||||
|
||||
push_readme "${docker_repo}"/kopano_"${image}" "${token}" "${image}"/README.md
|
||||
|
||||
if [ -e "$tmpfile" ]; then
|
||||
rm "$tmpfile"
|
||||
fi
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
HADOLINT_VERSION=1.17.1
|
||||
DOCKER_COMPOSE_VERSION=1.23.2
|
||||
TRIVY_VERSION=0.1.1
|
||||
GOSS_VERSION=0.3.7
|
||||
COMMANDER_VERSION=1.2.1
|
||||
|
||||
if ! command -v hadolint > /dev/null; then
|
||||
sudo curl -L "https://github.com/hadolint/hadolint/releases/download/v$HADOLINT_VERSION/hadolint-$(uname -s)-$(uname -m)" -o /usr/local/bin/hadolint
|
||||
sudo chmod +rx /usr/local/bin/hadolint
|
||||
fi
|
||||
|
||||
if ! command -v docker-compose > /dev/null; then
|
||||
sudo curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
sudo chmod +rx /usr/local/bin/docker-compose
|
||||
fi
|
||||
|
||||
if ! command -v trivy > /dev/null; then
|
||||
wget https://github.com/knqyf263/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz
|
||||
sudo tar zxvf trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz -C /usr/local/bin trivy
|
||||
fi
|
||||
|
||||
if ! command -v goss > /dev/null; then
|
||||
sudo curl -L https://github.com/aelsabbahy/goss/releases/download/v$GOSS_VERSION/goss-linux-amd64 -o /usr/local/bin/goss
|
||||
sudo chmod +rx /usr/local/bin/goss
|
||||
fi
|
||||
|
||||
if ! command -v dcgoss > /dev/null; then
|
||||
sudo curl -L https://raw.githubusercontent.com/fbartels/goss/dcgoss-v2/extras/dcgoss/dcgoss -o /usr/local/bin/dcgoss
|
||||
sudo chmod +rx /usr/local/bin/dcgoss
|
||||
fi
|
||||
|
||||
if ! command -v commander > /dev/null; then
|
||||
sudo curl -L https://github.com/SimonBaeumer/commander/releases/download/v$COMMANDER_VERSION/commander-linux-amd64 -o /usr/local/bin/commander
|
||||
sudo chmod +rx /usr/local/bin/commander
|
||||
fi
|
||||
|
||||
if ! command -v commander > /dev/null; then
|
||||
sudo curl -L https://raw.githubusercontent.com/fbartels/dccommander/master/dccommander -o /usr/local/bin/dccommander
|
||||
sudo chmod +rx /usr/local/bin/commander
|
||||
fi
|
||||
|
||||
if ! command -v expect > /dev/null; then
|
||||
sudo apt update && sudo apt install -y expect
|
||||
fi
|
||||
|
||||
if ! command -v yamllint > /dev/null; then
|
||||
sudo pip install --upgrade pip && sudo pip install yamllint
|
||||
fi
|
||||
|
||||
if ! command -v eclint > /dev/null; then
|
||||
npm install -g eclint
|
||||
fi
|
||||
Reference in New Issue
Block a user