mirror of
https://gh.wpcy.net/https://github.com/fairpm/server.git
synced 2026-06-19 02:53:45 +08:00
37 lines
857 B
Bash
Executable file
37 lines
857 B
Bash
Executable file
#!/bin/bash
|
|
# shellcheck disable=SC2086
|
|
|
|
set -euxo pipefail
|
|
|
|
here=$(dirname "$0")
|
|
cd "$here/.."
|
|
|
|
image=${IMAGE_NAME?required argument missing}
|
|
dockerfile=${DOCKERFILE:-Dockerfile}
|
|
tag=${TAG:-$(git describe --tags --abbrev=0)}
|
|
platform=${PLATFORM:-linux/amd64,linux/arm64}
|
|
target=${TARGET:-prod}
|
|
|
|
registry=${REGISTRY:-ghcr.io}
|
|
username=${REGISTRY_USERNAME:-required-but-ignored-on-ghcr}
|
|
password=${REGISTRY_PASSWORD:-${GITHUB_TOKEN:-}}
|
|
|
|
main () {
|
|
push_arg=''
|
|
|
|
if [[ -n ${password:-} ]]; then
|
|
echo "$password" | docker login "$registry" -u "$username" --password-stdin
|
|
push_arg='--push'
|
|
fi
|
|
|
|
docker buildx build \
|
|
--file "$dockerfile" \
|
|
--target "$target" \
|
|
--platform "$platform" \
|
|
--tag "ghcr.io/$image:$tag" \
|
|
--tag "ghcr.io/$image:latest" \
|
|
$push_arg \
|
|
.
|
|
}
|
|
|
|
main "$@"
|