Skip to content
Open
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
37 changes: 34 additions & 3 deletions make/common.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
#docker version: 20.10.10+
#docker-compose version: 1.18.0+
#podman version: 4.9.3+
#podman-compose version: 1.0.6+
#golang version: 1.12.0+

set +e
Expand Down Expand Up @@ -75,13 +77,42 @@ function check_golang {
fi
}

function check_docker {
function check_docker {
if ! docker --version &> /dev/null
then
error "Need to install docker(20.10.10+) first and run this script again."
error "Need to install docker(20.10.10+) or podman(4.9.3+) first and run this script again."
exit 1
fi

# either docker is podman
if docker --version 2>&1 | grep -qi podman; then
note "Detected Podman as the Docker CLI."
# Check Podman version
# capture major, minor and patch (e.g. 4.9.3)
if [[ $(podman --version) =~ (([0-9]+)\.([0-9]+)\.([0-9]+)([\.0-9]*)) ]]
then
podman_version=${BASH_REMATCH[1]}
podman_version_part1=${BASH_REMATCH[2]}
podman_version_part2=${BASH_REMATCH[3]}
podman_version_part3=${BASH_REMATCH[4]}

note "Podman version: $podman_version"
# the version of Podman does not meet the requirement 4.9.3+
if [ "$podman_version_part1" -lt 4 ] || \
([ "$podman_version_part1" -eq 4 ] && [ "$podman_version_part2" -lt 9 ]) || \
([ "$podman_version_part1" -eq 4 ] && [ "$podman_version_part2" -eq 9 ] && [ "$podman_version_part3" -lt 3 ])
then
error "Need to upgrade Podman package to 4.9.3+."
exit 1
fi
else
error "Failed to parse Podman version."
exit 1
fi
# Skip Docker version checks if Podman is detected
return
fi

# docker has been installed and check its version
if [[ $(docker --version) =~ (([0-9]+)\.([0-9]+)([\.0-9]*)) ]]
then
Expand All @@ -91,7 +122,7 @@ function check_docker {

note "docker version: $docker_version"
# the version of docker does not meet the requirement
if [ "$docker_version_part1" -lt 17 ] || ([ "$docker_version_part1" -eq 17 ] && [ "$docker_version_part2" -lt 6 ])
if [ "$docker_version_part1" -lt 20 ] || ([ "$docker_version_part1" -eq 20 ] && [ "$docker_version_part2" -lt 10 ])
then
error "Need to upgrade docker package to 20.10.10+."
exit 1
Expand Down
23 changes: 19 additions & 4 deletions make/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set +o noglob

usage=$'Please set hostname and other necessary attributes in harbor.yml first. DO NOT use localhost or 127.0.0.1 for hostname, because Harbor needs to be accessed by external clients.
Please set --with-trivy if needs enable Trivy in Harbor.
Please set --with-podman if you want to force prepare to treat the Docker CLI as Podman.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right pattern, b/c with the param like "--with-xxx", the "xxx" is always a component in Harbor. Like "--with-trivy"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wasn't sure about this one when I started the PR. What should we use here? Will --podman be fine?

Please do NOT set --with-chartmuseum, as chartmusuem has been deprecated and removed.
Please do NOT set --with-notary, as notary has been deprecated and removed.'
item=0
Expand All @@ -17,6 +18,8 @@ item=0
with_clair=$false
# trivy is not enabled by default
with_trivy=$false
# podman option not enabled by default
with_podman=$false

# flag to using docker compose v1 or v2, default would using v1 docker-compose
DOCKER_COMPOSE=docker-compose
Expand All @@ -28,6 +31,8 @@ while [ $# -gt 0 ]; do
exit 0;;
--with-trivy)
with_trivy=true;;
--with-podman)
with_podman=true;;
*)
note "$usage"
exit 1;;
Expand Down Expand Up @@ -64,13 +69,23 @@ then
prepare_para="${prepare_para} --with-trivy"
fi

if [ $with_podman ]
then
prepare_para="${prepare_para} --with-podman"
fi

./prepare $prepare_para

echo ""

if [ -n "$DOCKER_COMPOSE ps -q" ]
then
note "stopping existing Harbor instance ..."
$DOCKER_COMPOSE down -v
# Check if any containers started by compose are present. Capture the compose
# output and filter to only valid container IDs so vendor warnings (for
# example "Emulate Docker CLI using podman...") don't make the check true.
compose_ps_output=$($DOCKER_COMPOSE ps -q 2>/dev/null | grep -E '^[0-9a-fA-F]+$' || true)
if [ -n "$compose_ps_output" ]
then
note "stopping existing Harbor instance ..."
$DOCKER_COMPOSE down -v
fi
echo ""

Expand Down
5 changes: 3 additions & 2 deletions make/photon/prepare/commands/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
@click.command()
@click.option('--conf', default=input_config_path, help="the path of Harbor configuration file")
@click.option('--with-trivy', is_flag=True, help="the Harbor instance is to be deployed with Trivy")
def prepare(conf, with_trivy):
@click.option('--with-podman', is_flag=True, help="the Harbor instance will be deployed using Podman (avoid Docker logging options)")
def prepare(conf, with_trivy, with_podman):

delfile(config_dir)
config_dict = parse_yaml_config(conf, with_trivy=with_trivy)
Expand Down Expand Up @@ -65,4 +66,4 @@ def prepare(conf, with_trivy):
if with_trivy:
prepare_trivy_adapter(config_dict)

prepare_docker_compose(config_dict, with_trivy)
prepare_docker_compose(config_dict, with_trivy, with_podman)
Loading
Loading