mirror of
https://github.com/frappe/frappe_docker.git
synced 2024-12-23 10:38:58 +00:00
swap out travis.sh for python and be compat with #100
This commit is contained in:
parent
77aca4d3cc
commit
8c00873065
82
.travis.yml
82
.travis.yml
@ -13,7 +13,7 @@ before_install:
|
||||
- if [[ $BUILD == "development" ]];then
|
||||
sudo apt-get update && sudo apt-get -y install docker-compose;
|
||||
fi
|
||||
- chmod u+x ./travis.sh
|
||||
- chmod u+x ./travis.py
|
||||
|
||||
after_success:
|
||||
- docker --version
|
||||
@ -23,87 +23,87 @@ matrix:
|
||||
- name: "Build Frappe python environment (edge)"
|
||||
if: branch = develop AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --worker --service frappe --tag edge
|
||||
- ./travis.sh --worker --service frappe --tag develop --tag-only
|
||||
- ./travis.py frappe --worker --tag edge
|
||||
- ./travis.py frappe --worker --tag develop --tag-only
|
||||
- name: "Build Frappe nginx + static assets (edge)"
|
||||
if: branch = develop AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --assets --service frappe --tag edge
|
||||
- ./travis.sh --assets --service frappe --tag develop--tag-only
|
||||
- ./travis.py frappe --nginx --tag edge
|
||||
- ./travis.py frappe --nginx --tag develop--tag-only
|
||||
- name: "Build ERPNext python environment (edge)"
|
||||
if: branch = develop AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --worker --service erpnext --tag edge
|
||||
- ./travis.sh --worker --service erpnext --tag develop --tag-only
|
||||
- ./travis.py erpnext --worker --tag edge
|
||||
- ./travis.py erpnext --worker --tag develop --tag-only
|
||||
- name: "Build ERPNext nginx + static assets (edge)"
|
||||
if: branch = develop AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --assets --service erpnext --tag edge
|
||||
- ./travis.sh --assets --service erpnext --tag develop --tag-only
|
||||
- ./travis.py erpnext --nginx --tag edge
|
||||
- ./travis.py erpnext --nginx --tag develop --tag-only
|
||||
- name: "Build Frappe socketio service (edge)"
|
||||
if: branch = develop AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --socketio --service frappe --tag edge
|
||||
- ./travis.sh --socketio --service frappe --tag develop --tag-only
|
||||
- ./travis.py frappe --socketio --tag edge
|
||||
- ./travis.py frappe --socketio --tag develop --tag-only
|
||||
- name: "Build Frappe python environment (v12)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --worker --service frappe --git-branch 12
|
||||
- ./travis.sh --worker --service frappe --tag v12 --tag-only
|
||||
- ./travis.sh --worker --service frappe --tag version-12 --tag-only
|
||||
- ./travis.py frappe --worker --git-branch 12
|
||||
- ./travis.py frappe --worker --tag v12 --tag-only
|
||||
- ./travis.py frappe --worker --tag version-12 --tag-only
|
||||
- name: "Build Frappe nginx + static assets (v12)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --assets --service frappe --git-branch 12
|
||||
- ./travis.sh --assets --service frappe --tag v12 --tag-only
|
||||
- ./travis.sh --assets --service frappe --tag version-12 --tag-only
|
||||
- ./travis.py frappe --nginx --git-branch 12
|
||||
- ./travis.py frappe --nginx --tag v12 --tag-only
|
||||
- ./travis.py frappe --nginx --tag version-12 --tag-only
|
||||
- name: "Build ERPNext python environment (v12)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --worker --service erpnext --git-branch 12
|
||||
- ./travis.sh --worker --service erpnext --tag v12 --tag-only
|
||||
- ./travis.sh --worker --service erpnext --tag version-12 --tag-only
|
||||
- ./travis.py erpnext --worker --git-branch 12
|
||||
- ./travis.py erpnext --worker --tag v12 --tag-only
|
||||
- ./travis.py erpnext --worker --tag version-12 --tag-only
|
||||
- name: "Build ERPNext nginx + static assets (v12)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --assets --service erpnext--git-branch 12
|
||||
- ./travis.sh --assets --service erpnext --tag v12 --tag-only
|
||||
- ./travis.sh --assets --service erpnext --tag version-12 --tag-only
|
||||
- ./travis.py erpnext --nginx --git-branch 12
|
||||
- ./travis.py erpnext --nginx --tag v12 --tag-only
|
||||
- ./travis.py erpnext --nginx --tag version-12 --tag-only
|
||||
- name: "Build Frappe socketio service (v11)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --socketio --service frappe --git-branch 11
|
||||
- ./travis.sh --socketio --service frappe --tag v11 --tag-only
|
||||
- ./travis.sh --socketio --service frappe --tag version-11 --tag-only
|
||||
- ./travis.py frappe --socketio --git-branch 11
|
||||
- ./travis.py frappe --socketio --tag v11 --tag-only
|
||||
- ./travis.py frappe --socketio --tag version-11 --tag-only
|
||||
- name: "Build Frappe python environment (v11)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --worker --service frappe --git-branch 11
|
||||
- ./travis.sh --worker --service frappe --tag v11 --tag-only
|
||||
- ./travis.sh --worker --service frappe --tag version-11 --tag-only
|
||||
- ./travis.py frappe --worker --git-branch 11
|
||||
- ./travis.py frappe --worker --tag v11 --tag-only
|
||||
- ./travis.py frappe --worker --tag version-11 --tag-only
|
||||
- name: "Build Frappe nginx + static assets (v11)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --assets --service frappe --git-branch 11
|
||||
- ./travis.sh --assets --service frappe --tag v11 --tag-only
|
||||
- ./travis.sh --assets --service frappe --tag version-11 --tag-only
|
||||
- ./travis.py erpnext frappe --nginx --git-branch 11
|
||||
- ./travis.py erpnext frappe --nginx --tag v11 --tag-only
|
||||
- ./travis.py erpnext frappe --nginx --tag version-11 --tag-only
|
||||
- name: "Build ERPNext python environment (v11)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --worker --service erpnext --git-branch 11
|
||||
- ./travis.sh --worker --service erpnext --tag v11 --tag-only
|
||||
- ./travis.sh --worker --service erpnext --tag version-11 --tag-only
|
||||
- ./travis.py erpnext --worker --git-branch 11
|
||||
- ./travis.py erpnext --worker --tag v11 --tag-only
|
||||
- ./travis.py erpnext --worker --tag version-11 --tag-only
|
||||
- name: "Build ERPNext nginx + static assets (v11)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --assets --service erpnext--git-branch 11
|
||||
- ./travis.sh --assets --service erpnext --tag v11 --tag-only
|
||||
- ./travis.sh --assets --service erpnext --tag version-11 --tag-only
|
||||
- ./travis.py erpnext --nginx --git-branch 11
|
||||
- ./travis.py erpnext --nginx --tag v11 --tag-only
|
||||
- ./travis.py erpnext --nginx --tag version-11 --tag-only
|
||||
- name: "Build Frappe socketio service (v11)"
|
||||
if: branch = master AND type != pull_request
|
||||
script:
|
||||
- ./travis.sh --socketio --service frappe --git-branch 11
|
||||
- ./travis.sh --socketio --service frappe --tag v11 --tag-only
|
||||
- ./travis.sh --socketio --service frappe --tag version-11 --tag-only
|
||||
- ./travis.py frappe --socketio --git-branch 11
|
||||
- ./travis.py frappe --socketio --tag v11 --tag-only
|
||||
- ./travis.py frappe --socketio --tag version-11 --tag-only
|
||||
|
||||
|
66
travis.py
Executable file
66
travis.py
Executable file
@ -0,0 +1,66 @@
|
||||
#!/bin/env python3
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
parser = argparse.ArgumentParser(description='frappe_docker common CI elements', add_help=True)
|
||||
|
||||
image_type = parser.add_mutually_exclusive_group(required=True)
|
||||
image_type.add_argument('-a', '--nginx', action='store_const', dest='image_type', const='nginx', help='Build the nginx + static assets image')
|
||||
image_type.add_argument('-s', '--socketio', action='store_const', dest='image_type', const='socketio', help='Build the frappe-socketio image')
|
||||
image_type.add_argument('-w', '--worker', action='store_const', dest='image_type', const='worker', help='Build the python environment image')
|
||||
|
||||
parser.add_argument('service', action='store', type=str, help='Name of the service to build: "erpnext" or "frappe"')
|
||||
|
||||
tag_type = parser.add_mutually_exclusive_group(required=True)
|
||||
tag_type.add_argument('-g', '--git-version', action='store', type=int, dest='version', help='The version number of --service (i.e. "11", "12", etc.)')
|
||||
tag_type.add_argument('-t', '--tag', action='store', type=str, dest='tag', help='The image tag (i.e. erpnext-worker:$TAG )')
|
||||
|
||||
parser.add_argument('-o', '--tag-only', required=False, action='store_true', dest='tag_only', help='Only tag an image and push it.')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print('image_type = {!r}'.format(args.image_type))
|
||||
print('service = {!r}'.format(args.service))
|
||||
print('version = {!r}'.format(args.version))
|
||||
print('tag = {!r}'.format(args.tag))
|
||||
print('tag_only = {!r}'.format(args.tag_only))
|
||||
|
||||
def git_version(service, version):
|
||||
print(f'Pulling {service} v{version}')
|
||||
subprocess.run(f'git clone https://github.com/frappe/{service} --branch version-{version}', shell=True)
|
||||
cd = os.getcwd()
|
||||
os.chdir(os.getcwd() + f'/{service}')
|
||||
subprocess.run('git fetch --tags', shell=True)
|
||||
version_tag = subprocess.check_output(f'git tag --list --sort=-version:refname "v{version}*" | sed -n 1p | sed -e \'s#.*@\(\)#\\1#\'', shell=True).strip().decode('ascii')
|
||||
os.chdir(cd)
|
||||
return version_tag
|
||||
|
||||
def build(service, tag, image, dockerfile):
|
||||
print(f'Building {service} {image} image using {dockerfile}')
|
||||
subprocess.run(f'docker build -t {service}-{image} -f build/{service}-{image}/{dockerfile} .', shell=True)
|
||||
tag_and_push(f'{service}-{image}', tag)
|
||||
|
||||
def tag_and_push(image_name, tag):
|
||||
print(f'Tagging {image_name} as "{tag}" and pushing')
|
||||
subprocess.run(f'docker tag {image_name} frappe/{image_name}:{tag}', shell=True)
|
||||
subprocess.run(f'docker push frappe/{image_name}:{tag}', shell=True)
|
||||
|
||||
def main():
|
||||
global tag
|
||||
global dockerfile
|
||||
|
||||
if args.version:
|
||||
tag = git_version(args.service, args.version)
|
||||
dockerfile = 'v{!r}.Dockerfile'.format(args.version)
|
||||
else:
|
||||
tag = args.tag
|
||||
dockerfile = 'Dockerfile'
|
||||
|
||||
if args.tag_only:
|
||||
tag_and_push(f'{args.service}-{args.image_type}', tag)
|
||||
else:
|
||||
build(args.service, tag, args.image_type, dockerfile)
|
||||
|
||||
main()
|
150
travis.sh
150
travis.sh
@ -1,150 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
################# ./travis.sh #################
|
||||
# This script takes care of the common steps
|
||||
# found in the frappe_docker Travis CI builds.
|
||||
#
|
||||
# Usage: [-a | -s | -w | -h] [-n <name of service>] [-t <tag> | -g <version number>] [-o]
|
||||
#
|
||||
# Argumets:
|
||||
#
|
||||
# -a | --assets (exclusive): Build the nginx + static assets image
|
||||
# -s | --socketio (exclusive): Build the frappe-socketio image
|
||||
# -w | --worker (exclusive): Build the python environment image
|
||||
# -h | --help (exclusive): Print this page
|
||||
#
|
||||
# -n | --service <name of service>: Name of the service to build: "erpnext" or "frappe"
|
||||
# Note: --socketio does not respect this argument
|
||||
# Note: This will build an image with the name "$SERVICE-assets" (i.e. "erpnext-worker", "frappe-assets", etc.)
|
||||
#
|
||||
# -t | --tag <tag> (exclusive): The image tag (i.e. erpnext-worker:$TAG )
|
||||
# -g | --git-version <version number> (exclusive): The version number of --service (i.e. "11", "12", etc.)
|
||||
# Note: This must be a number, not a string!
|
||||
#
|
||||
# -o | --tag-only: Only tag an image and push it.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
-a|--assets)
|
||||
ASSETS=1
|
||||
shift
|
||||
;;
|
||||
-g|--git-version)
|
||||
version="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
HELP=1
|
||||
shift
|
||||
;;
|
||||
-n|--service)
|
||||
SERVICE="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-o|--tag-only)
|
||||
TAGONLY=1
|
||||
shift
|
||||
;;
|
||||
-s|--socketio)
|
||||
SOCKETIO=1
|
||||
shift
|
||||
;;
|
||||
-t|--tag)
|
||||
TAG="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-w|--worker)
|
||||
WORKER=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
HELP=1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
function help() {
|
||||
echo "################ $0 #################"
|
||||
echo " This script takes care of the common steps found in the frappe_docker Travis CI builds."
|
||||
echo ""
|
||||
echo " Usage: [-a | -s | -w | -h] [-n <name of service>] [-t <tag> | -g <version number>] [-o]"
|
||||
echo ""
|
||||
echo " Argumets:"
|
||||
echo ""
|
||||
echo " -a | --assets (exclusive): Build the nginx + static assets image"
|
||||
echo " -s | --socketio (exclusive): Build the frappe-socketio image"
|
||||
echo " -w | --worker (exclusive): Build the python environment image"
|
||||
echo " -h | --help (exclusive): Print this page"
|
||||
echo ""
|
||||
echo " -n | --service <name of service>: Name of the service to build: \"erpnext\" or \"frappe\""
|
||||
echo " Note: --socketio does not respect this argument"
|
||||
echo " Note: This will build an image with the name \"\$SERVICE-assets\" (i.e. \"erpnext-worker\", \"frappe-assets\", etc.)"
|
||||
echo ""
|
||||
echo " -t | --tag <tag> (exclusive): The image tag (i.e. erpnext-worker:\$TAG)"
|
||||
echo " -g | --git-version <version number> (exclusive): The version number of --service (i.e. \"11\", \"12\", etc.)"
|
||||
echo " Note: This must be a number, not a string!"
|
||||
echo ""
|
||||
echo " -o | --tag-only: Only tag an image and push it."
|
||||
}
|
||||
|
||||
function gitVersion() {
|
||||
echo "Pulling ${1} v${2}"
|
||||
git clone https://github.com/frappe/${1} --branch version-${2}
|
||||
cd ${1}
|
||||
git fetch --tags
|
||||
TAG=$(git tag --list --sort=-version:refname "v${2}*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
|
||||
cd ..
|
||||
DOCKERFILE="v${2}.Dockerfile"
|
||||
}
|
||||
|
||||
function tagAndPush() {
|
||||
echo "Tagging ${1} as \"${2}\" and pushing"
|
||||
docker tag ${1} frappe/${1}:${2}
|
||||
docker push frappe/${1}:${2}
|
||||
}
|
||||
|
||||
function build () {
|
||||
echo "Building ${1} ${3} image using ${4}"
|
||||
docker build -t ${1}-${3} -f build/${1}-${3}/${4:-Dockerfile} .
|
||||
tagAndPush "${1}-${3}" ${2}
|
||||
}
|
||||
|
||||
if [[ HELP ]]; then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $VERSION ]]; then
|
||||
gitVersion $SERVICE $VERSION
|
||||
fi
|
||||
|
||||
DOCKERFILE=${DOCKERFILE:-Dockerfile}
|
||||
|
||||
if [[ $WORKER ]]; then
|
||||
if [[ $TAGONLY ]]; then
|
||||
tagAndPush "${SERVICE}-worker" ${TAG}
|
||||
else
|
||||
build $SERVICE $TAG worker ${DOCKERFILE}
|
||||
fi
|
||||
elif [[ $ASSETS ]]; then
|
||||
if [[ $TAGONLY ]]; then
|
||||
tagAndPush "${SERVICE}-assets" ${TAG}
|
||||
else
|
||||
build $SERVICE $TAG assets ${DOCKERFILE}
|
||||
fi
|
||||
elif [[ $SOCKETIO ]]; then
|
||||
if [[ $TAGONLY ]]; then
|
||||
tagAndPush "frappe-socketio" ${TAG}
|
||||
else
|
||||
build frappe $TAG socketio ${DOCKERFILE}
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue
Block a user