move func requirements at start
This commit is contained in:
parent
8d0803b48e
commit
392a033913
@ -12,8 +12,6 @@ CONTAINER_IMAGE_ORGANIZATION=${GITHUB_REPOSITORY_OWNER:-"searxng"}
|
|||||||
CONTAINER_IMAGE_NAME="searxng"
|
CONTAINER_IMAGE_NAME="searxng"
|
||||||
|
|
||||||
container.build() {
|
container.build() {
|
||||||
pyenv.install
|
|
||||||
|
|
||||||
local parch=${OVERRIDE_ARCH:-$(uname -m)}
|
local parch=${OVERRIDE_ARCH:-$(uname -m)}
|
||||||
local container_engine
|
local container_engine
|
||||||
local dockerfile
|
local dockerfile
|
||||||
@ -21,6 +19,36 @@ container.build() {
|
|||||||
local variant
|
local variant
|
||||||
local platform
|
local platform
|
||||||
|
|
||||||
|
# Check if git is installed
|
||||||
|
if ! command -v git &>/dev/null; then
|
||||||
|
die 1 "Git is not installed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if podman or docker is installed
|
||||||
|
if [ "$1" = "docker" ]; then
|
||||||
|
if command -v docker &>/dev/null; then
|
||||||
|
container_engine="docker"
|
||||||
|
else
|
||||||
|
die 1 "Docker is not installed"
|
||||||
|
fi
|
||||||
|
elif [ "$1" = "podman" ]; then
|
||||||
|
if command -v podman &>/dev/null; then
|
||||||
|
container_engine="podman"
|
||||||
|
else
|
||||||
|
die 1 "Podman is not installed"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# If no explicit engine is passed, prioritize podman over docker
|
||||||
|
if command -v podman &>/dev/null; then
|
||||||
|
container_engine="podman"
|
||||||
|
elif command -v docker &>/dev/null; then
|
||||||
|
container_engine="docker"
|
||||||
|
else
|
||||||
|
die 1 "Podman/Docker is not installed"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
info_msg "Selected engine: $container_engine"
|
||||||
|
|
||||||
# Setup arch specific
|
# Setup arch specific
|
||||||
case $parch in
|
case $parch in
|
||||||
"X64" | "x86_64" | "amd64")
|
"X64" | "x86_64" | "amd64")
|
||||||
@ -48,35 +76,7 @@ container.build() {
|
|||||||
esac
|
esac
|
||||||
info_msg "Selected platform: $platform"
|
info_msg "Selected platform: $platform"
|
||||||
|
|
||||||
# Check if podman or docker is installed
|
pyenv.install
|
||||||
if [ "$1" = "docker" ]; then
|
|
||||||
if command -v docker &>/dev/null; then
|
|
||||||
container_engine="docker"
|
|
||||||
else
|
|
||||||
die 1 "Docker is not installed"
|
|
||||||
fi
|
|
||||||
elif [ "$1" = "podman" ]; then
|
|
||||||
if command -v podman &>/dev/null; then
|
|
||||||
container_engine="podman"
|
|
||||||
else
|
|
||||||
die 1 "Podman is not installed"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# If no explicit engine is passed, prioritize podman over docker
|
|
||||||
if command -v podman &>/dev/null; then
|
|
||||||
container_engine="podman"
|
|
||||||
elif command -v docker &>/dev/null; then
|
|
||||||
container_engine="docker"
|
|
||||||
else
|
|
||||||
die 1 "Podman/Docker is not installed"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
info_msg "Selected engine: $container_engine"
|
|
||||||
|
|
||||||
# Check if git is installed
|
|
||||||
if ! command -v git &>/dev/null; then
|
|
||||||
die 1 "Git is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
@ -159,15 +159,20 @@ container.build() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container.test() {
|
container.test() {
|
||||||
if [ "$GITHUB_ACTIONS" != "true" ]; then
|
|
||||||
die 1 "This command is intended to be run in GitHub Actions"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local parch=${OVERRIDE_ARCH:-$(uname -m)}
|
local parch=${OVERRIDE_ARCH:-$(uname -m)}
|
||||||
local arch
|
local arch
|
||||||
local variant
|
local variant
|
||||||
local platform
|
local platform
|
||||||
|
|
||||||
|
if [ "$GITHUB_ACTIONS" != "true" ]; then
|
||||||
|
die 1 "This command is intended to be run in GitHub Actions"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if podman is installed
|
||||||
|
if ! command -v podman &>/dev/null; then
|
||||||
|
die 1 "podman is not installed"
|
||||||
|
fi
|
||||||
|
|
||||||
# Setup arch specific
|
# Setup arch specific
|
||||||
case $parch in
|
case $parch in
|
||||||
"X64" | "x86_64" | "amd64")
|
"X64" | "x86_64" | "amd64")
|
||||||
@ -192,11 +197,6 @@ container.test() {
|
|||||||
esac
|
esac
|
||||||
build_msg CONTAINER "Selected platform: $platform"
|
build_msg CONTAINER "Selected platform: $platform"
|
||||||
|
|
||||||
# Check if podman is installed
|
|
||||||
if ! command -v podman &>/dev/null; then
|
|
||||||
die 1 "podman is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -223,17 +223,22 @@ container.test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container.push() {
|
container.push() {
|
||||||
if [ "$GITHUB_ACTIONS" != "true" ]; then
|
# Architectures on manifest
|
||||||
die 1 "This command is intended to be run in GitHub Actions"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Architectures to release
|
|
||||||
local release_archs=("amd64" "arm64" "armv7")
|
local release_archs=("amd64" "arm64" "armv7")
|
||||||
|
|
||||||
local archs=()
|
local archs=()
|
||||||
local variants=()
|
local variants=()
|
||||||
local platforms=()
|
local platforms=()
|
||||||
|
|
||||||
|
if [ "$GITHUB_ACTIONS" != "true" ]; then
|
||||||
|
die 1 "This command is intended to be run in GitHub Actions"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if podman is installed
|
||||||
|
if ! command -v podman &>/dev/null; then
|
||||||
|
die 1 "podman is not installed"
|
||||||
|
fi
|
||||||
|
|
||||||
for arch in "${release_archs[@]}"; do
|
for arch in "${release_archs[@]}"; do
|
||||||
case $arch in
|
case $arch in
|
||||||
"X64" | "x86_64" | "amd64")
|
"X64" | "x86_64" | "amd64")
|
||||||
@ -258,11 +263,6 @@ container.push() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if podman is installed
|
|
||||||
if ! command -v podman &>/dev/null; then
|
|
||||||
die 1 "podman is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -271,12 +271,12 @@ container.push() {
|
|||||||
podman pull "ghcr.io/$CONTAINER_IMAGE_ORGANIZATION/cache:$CONTAINER_IMAGE_NAME-${archs[$i]}${variants[$i]}"
|
podman pull "ghcr.io/$CONTAINER_IMAGE_ORGANIZATION/cache:$CONTAINER_IMAGE_NAME-${archs[$i]}${variants[$i]}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Tags to release
|
# Manifest tags
|
||||||
tags=("latest")
|
release_tags=("latest")
|
||||||
tags+=("$DOCKER_TAG")
|
release_tags+=("$DOCKER_TAG")
|
||||||
|
|
||||||
# Create manifests
|
# Create manifests
|
||||||
for tag in "${tags[@]}"; do
|
for tag in "${release_tags[@]}"; do
|
||||||
if ! podman manifest exists "localhost/$CONTAINER_IMAGE_ORGANIZATION/$CONTAINER_IMAGE_NAME:$tag"; then
|
if ! podman manifest exists "localhost/$CONTAINER_IMAGE_ORGANIZATION/$CONTAINER_IMAGE_NAME:$tag"; then
|
||||||
podman manifest create "localhost/$CONTAINER_IMAGE_ORGANIZATION/$CONTAINER_IMAGE_NAME:$tag"
|
podman manifest create "localhost/$CONTAINER_IMAGE_ORGANIZATION/$CONTAINER_IMAGE_NAME:$tag"
|
||||||
fi
|
fi
|
||||||
@ -292,7 +292,7 @@ container.push() {
|
|||||||
podman image list
|
podman image list
|
||||||
|
|
||||||
# Push manifests
|
# Push manifests
|
||||||
for tag in "${tags[@]}"; do
|
for tag in "${release_tags[@]}"; do
|
||||||
build_msg CONTAINER "Pushing manifest with tag: $tag"
|
build_msg CONTAINER "Pushing manifest with tag: $tag"
|
||||||
|
|
||||||
podman manifest push \
|
podman manifest push \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user