Skip to content

Commit d87c155

Browse files
author
Daniel Bunte
committed
feat(install): Adds support for podman(compose), while maintaining compatibility with docker
1 parent 92b419b commit d87c155

13 files changed

+90
-49
lines changed

install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ source install/_lib.sh
1111

1212
# Pre-flight. No impact yet.
1313
source install/parse-cli.sh
14+
source install/detect-container-technology.sh
1415
source install/detect-platform.sh
1516
source install/dc-detect-version.sh
1617
source install/error-handling.sh

install/_min-requirements.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
MIN_DOCKER_VERSION='19.03.6'
33
MIN_COMPOSE_VERSION='2.32.2'
44

5+
MIN_PODMAN_VERSION='4.9.4'
6+
MIN_PODMAN_COMPOSE_VERSION='1.3.0'
7+
58
# 16 GB minimum host RAM, but there'll be some overhead outside of what
69
# can be allotted to docker
710
if [[ "$COMPOSE_PROFILES" == "errors-only" ]]; then

install/check-minimum-requirements.sh

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,41 @@ echo "${_group}Checking minimum requirements ..."
22

33
source install/_min-requirements.sh
44

5-
DOCKER_VERSION=$(docker version --format '{{.Server.Version}}' || echo '')
5+
DOCKER_VERSION=$($CONTAINER_TECHNOLOGY version --format '{{.Server.Version}}' || echo '')
66
if [[ -z "$DOCKER_VERSION" ]]; then
7-
echo "FAIL: Unable to get docker version, is the docker daemon running?"
7+
echo "FAIL: Unable to get $CONTAINER_TECHNOLOGY version, is the $CONTAINER_TECHNOLOGY daemon running?"
88
exit 1
99
fi
1010

11-
if ! vergte ${DOCKER_VERSION//v/} $MIN_DOCKER_VERSION; then
12-
echo "FAIL: Expected minimum docker version to be $MIN_DOCKER_VERSION but found $DOCKER_VERSION"
13-
exit 1
14-
fi
15-
echo "Found Docker version $DOCKER_VERSION"
16-
17-
if ! vergte ${COMPOSE_VERSION//v/} $MIN_COMPOSE_VERSION; then
18-
echo "FAIL: Expected minimum $dc_base version to be $MIN_COMPOSE_VERSION but found $COMPOSE_VERSION"
19-
exit 1
11+
if [[ "$CONTAINER_TECHNOLOGY" == "docker" ]]; then
12+
if ! vergte ${DOCKER_VERSION//v/} $MIN_DOCKER_VERSION; then
13+
echo "FAIL: Expected minimum docker version to be $MIN_DOCKER_VERSION but found $DOCKER_VERSION"
14+
exit 1
15+
fi
16+
if ! vergte ${COMPOSE_VERSION//v/} $MIN_COMPOSE_VERSION; then
17+
echo "FAIL: Expected minimum $dc_base version to be $MIN_COMPOSE_VERSION but found $COMPOSE_VERSION"
18+
exit 1
19+
fi
20+
elif [[ "$CONTAINER_TECHNOLOGY" == "podman" ]]; then
21+
if ! vergte ${DOCKER_VERSION//v/} $MIN_PODMAN_VERSION; then
22+
echo "FAIL: Expected minimum podman version to be $MIN_PODMAN_VERSION but found $DOCKER_VERSION"
23+
exit 1
24+
fi
25+
if ! vergte ${COMPOSE_VERSION//v/} $MIN_PODMAN_COMPOSE_VERSION; then
26+
echo "FAIL: Expected minimum $dc_base version to be $MIN_PODMAN_COMPOSE_VERSION but found $COMPOSE_VERSION"
27+
exit 1
28+
fi
2029
fi
21-
echo "Found Docker Compose version $COMPOSE_VERSION"
30+
echo "Found $CONTAINER_TECHNOLOGY version $DOCKER_VERSION"
31+
echo "Found $CONTAINER_TECHNOLOGY Compose version $COMPOSE_VERSION"
2232

23-
CPU_AVAILABLE_IN_DOCKER=$(docker run --rm busybox nproc --all)
33+
CPU_AVAILABLE_IN_DOCKER=$($CONTAINER_TECHNOLOGY run --rm busybox nproc --all)
2434
if [[ "$CPU_AVAILABLE_IN_DOCKER" -lt "$MIN_CPU_HARD" ]]; then
2535
echo "FAIL: Required minimum CPU cores available to Docker is $MIN_CPU_HARD, found $CPU_AVAILABLE_IN_DOCKER"
2636
exit 1
2737
fi
2838

29-
RAM_AVAILABLE_IN_DOCKER=$(docker run --rm busybox free -m 2>/dev/null | awk '/Mem/ {print $2}')
39+
RAM_AVAILABLE_IN_DOCKER=$($CONTAINER_TECHNOLOGY run --rm busybox free -m 2>/dev/null | awk '/Mem/ {print $2}')
3040
if [[ "$RAM_AVAILABLE_IN_DOCKER" -lt "$MIN_RAM_HARD" ]]; then
3141
echo "FAIL: Required minimum RAM available to Docker is $MIN_RAM_HARD MB, found $RAM_AVAILABLE_IN_DOCKER MB"
3242
exit 1
@@ -35,9 +45,9 @@ fi
3545
#SSE4.2 required by Clickhouse (https://clickhouse.yandex/docs/en/operations/requirements/)
3646
# On KVM, cpuinfo could falsely not report SSE 4.2 support, so skip the check. https://github.com/ClickHouse/ClickHouse/issues/20#issuecomment-226849297
3747
# This may also happen on other virtualization software such as on VMWare ESXi hosts.
38-
IS_KVM=$(docker run --rm busybox grep -c 'Common KVM processor' /proc/cpuinfo || :)
48+
IS_KVM=$($CONTAINER_TECHNOLOGY run --rm busybox grep -c 'Common KVM processor' /proc/cpuinfo || :)
3949
if [[ ! "$SKIP_SSE42_REQUIREMENTS" -eq 1 && "$IS_KVM" -eq 0 && "$DOCKER_ARCH" = "x86_64" ]]; then
40-
SUPPORTS_SSE42=$(docker run --rm busybox grep -c sse4_2 /proc/cpuinfo || :)
50+
SUPPORTS_SSE42=$($CONTAINER_TECHNOLOGY run --rm busybox grep -c sse4_2 /proc/cpuinfo || :)
4151
if [[ "$SUPPORTS_SSE42" -eq 0 ]]; then
4252
echo "FAIL: The CPU your machine is running on does not support the SSE 4.2 instruction set, which is required for one of the services Sentry uses (Clickhouse). See https://github.com/getsentry/self-hosted/issues/340 for more info."
4353
exit 1

install/create-docker-volumes.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
echo "${_group}Creating volumes for persistent storage ..."
22

3-
echo "Created $(docker volume create --name=sentry-clickhouse)."
4-
echo "Created $(docker volume create --name=sentry-data)."
5-
echo "Created $(docker volume create --name=sentry-kafka)."
6-
echo "Created $(docker volume create --name=sentry-postgres)."
7-
echo "Created $(docker volume create --name=sentry-redis)."
8-
echo "Created $(docker volume create --name=sentry-symbolicator)."
3+
echo "Created $($CONTAINER_TECHNOLOGY volume create --name=sentry-clickhouse)."
4+
echo "Created $($CONTAINER_TECHNOLOGY volume create --name=sentry-data)."
5+
echo "Created $($CONTAINER_TECHNOLOGY volume create --name=sentry-kafka)."
6+
echo "Created $($CONTAINER_TECHNOLOGY volume create --name=sentry-postgres)."
7+
echo "Created $($CONTAINER_TECHNOLOGY volume create --name=sentry-redis)."
8+
echo "Created $($CONTAINER_TECHNOLOGY volume create --name=sentry-symbolicator)."
99

1010
echo "${_endgroup}"

install/dc-detect-version.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ else
66
_endgroup=""
77
fi
88

9-
echo "${_group}Initializing Docker Compose ..."
9+
echo "${_group}Initializing Docker|Podman Compose ..."
1010

1111
# To support users that are symlinking to docker-compose
12-
dc_base="$(docker compose version --short &>/dev/null && echo 'docker compose' || echo '')"
13-
dc_base_standalone="$(docker-compose version --short &>/dev/null && echo 'docker-compose' || echo '')"
12+
dc_base="$(${CONTAINER_TECHNOLOGY} compose version --short &>/dev/null && echo "$CONTAINER_TECHNOLOGY compose" || echo '')"
13+
dc_base_standalone="$(${CONTAINER_TECHNOLOGY}-compose version --short &>/dev/null && echo "$CONTAINER_TECHNOLOGY-compose" || echo '')"
1414

1515
COMPOSE_VERSION=$([ -n "$dc_base" ] && $dc_base version --short || echo '')
1616
STANDALONE_COMPOSE_VERSION=$([ -n "$dc_base_standalone" ] && $dc_base_standalone version --short || echo '')
1717

1818
if [[ -z "$COMPOSE_VERSION" && -z "$STANDALONE_COMPOSE_VERSION" ]]; then
19-
echo "FAIL: Docker Compose is required to run self-hosted"
19+
echo "FAIL: Docker|Podman Compose is required to run self-hosted"
2020
exit 1
2121
fi
2222

@@ -25,14 +25,25 @@ if [[ -z "$COMPOSE_VERSION" ]] || [[ -n "$STANDALONE_COMPOSE_VERSION" ]] && ! ve
2525
dc_base="$dc_base_standalone"
2626
fi
2727

28+
if [[ "$CONTAINER_TECHNOLOGY" == "docker" ]]; then
29+
NO_ANSI="--ansi never"
30+
elif [[ "$CONTAINER_TECHNOLOGY" == "podman" ]]; then
31+
NO_ANSI="--no-ansi"
32+
fi
33+
2834
if [[ "$(basename $0)" = "install.sh" ]]; then
29-
dc="$dc_base --ansi never --env-file ${_ENV}"
35+
dc="$dc_base $NO_ANSI --env-file ${_ENV}"
3036
else
31-
dc="$dc_base --ansi never"
37+
dc="$dc_base $NO_ANSI"
38+
fi
39+
40+
if [[ "$CONTAINER_TECHNOLOGY" == "docker" ]]; then
41+
proxy_args="--build-arg http_proxy=${http_proxy:-} --build-arg https_proxy=${https_proxy:-} --build-arg no_proxy=${no_proxy:-}"
42+
elif [[ "$CONTAINER_TECHNOLOGY" == "podman" ]]; then
43+
proxy_args="--podman-build-args http_proxy=${http_proxy:-},https_proxy=${https_proxy:-},no_proxy=${no_proxy:-}"
3244
fi
33-
proxy_args="--build-arg http_proxy=${http_proxy:-} --build-arg https_proxy=${https_proxy:-} --build-arg no_proxy=${no_proxy:-}"
3445
dcr="$dc run --pull=never --rm"
3546
dcb="$dc build $proxy_args"
36-
dbuild="docker build $proxy_args"
47+
dbuild="$CONTAINER_TECHNOLOGY build $proxy_args"
3748

3849
echo "${_endgroup}"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
echo "${_group}Detecting container technology ..."
2+
3+
export CONTAINER_TECHNOLOGY=""
4+
5+
if command -v podman &> /dev/null; then
6+
CONTAINER_TECHNOLOGY="podman"
7+
elif command -v docker &> /dev/null; then
8+
CONTAINER_TECHNOLOGY="docker"
9+
else
10+
echo "FAIL: Neither podman nor docker is installed on the system."
11+
exit 1
12+
fi
13+
echo "Detected container technology: $CONTAINER_TECHNOLOGY"
14+
echo "${_endgroup}"

install/detect-platform.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ echo "${_group}Detecting Docker platform"
1212
# linux/amd64 by default due to virtualization.
1313
# See https://github.com/docker/cli/issues/3286 for the Docker bug.
1414

15-
if ! command -v docker &>/dev/null; then
16-
echo "FAIL: Could not find a \`docker\` binary on this system. Are you sure it's installed?"
17-
exit 1
15+
FORMAT=""
16+
if [[ $CONTAINER_TECHNOLOGY == "podman" ]]; then
17+
FORMAT="{{.Host.Arch}}"
18+
elif [[ $CONTAINER_TECHNOLOGY == "docker" ]]; then
19+
FORMAT="{{.Architecture}}"
1820
fi
1921

20-
export DOCKER_ARCH=$(docker info --format '{{.Architecture}}')
22+
export DOCKER_ARCH=$($CONTAINER_TECHNOLOGY info --format "$FORMAT")
2123
if [[ "$DOCKER_ARCH" = "x86_64" ]]; then
2224
export DOCKER_PLATFORM="linux/amd64"
2325
elif [[ "$DOCKER_ARCH" = "aarch64" ]]; then

install/error-handling.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ fi
66

77
$dbuild -t sentry-self-hosted-jq-local --platform="$DOCKER_PLATFORM" jq
88

9-
jq="docker run --rm -i sentry-self-hosted-jq-local"
10-
sentry_cli="docker run --rm -v /tmp:/work -e SENTRY_DSN=$SENTRY_DSN getsentry/sentry-cli"
9+
jq="$CONTAINER_TECHNOLOGY run --rm -i sentry-self-hosted-jq-local"
10+
sentry_cli="$CONTAINER_TECHNOLOGY run --rm -v /tmp:/work -e SENTRY_DSN=$SENTRY_DSN getsentry/sentry-cli"
1111

1212
send_envelope() {
1313
# Send envelope

install/geoip.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ install_geoip() {
2121
else
2222
echo "IP address geolocation is configured for updates."
2323
echo "Updating IP address geolocation database ... "
24-
if ! docker run --rm -v "./geoip:/sentry" --entrypoint '/usr/bin/geoipupdate' "ghcr.io/maxmind/geoipupdate:v6.1.0" "-d" "/sentry" "-f" "/sentry/GeoIP.conf"; then
24+
if ! $CONTAINER_TECHNOLOGY run --rm -v "./geoip:/sentry" --entrypoint '/usr/bin/geoipupdate' "ghcr.io/maxmind/geoipupdate:v6.1.0" "-d" "/sentry" "-f" "/sentry/GeoIP.conf"; then
2525
result='Error'
2626
fi
2727
echo "$result updating IP address geolocation database."

install/parse-cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ show_help() {
44
cat <<EOF
55
Usage: $0 [options]
66
7-
Install Sentry with \`docker compose\`.
7+
Install Sentry with \`docker|podman compose\`.
88
99
Options:
1010
-h, --help Show this message and exit.

0 commit comments

Comments
 (0)