build
This commit is contained in:
1 parent
89d85b4369
commit
a73cd2311d
2 files changed
+24
-12
No files matched your search
@@ -1,21 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# webhook.hu - Docker image build és futtatás egy konténerben
|
||||
# webhook.hu - Docker image build és push a Gitea registrybe.
|
||||
# A tag mindig a package.json verziója (ott kezeld a verziózást), nincs 'latest'.
|
||||
set -euo pipefail
|
||||
|
||||
IMAGE="webhook-hu:latest"
|
||||
REGISTRY="git.ervin.hu/ervin"
|
||||
NAME="webhook-hu"
|
||||
CONTAINER="webhook-hu"
|
||||
PORT="${PORT:-3000}"
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Verzió kiolvasása a package.json-ból (ez a single source of truth)
|
||||
VERSION="$(node -p "require('./package.json').version")"
|
||||
IMAGE="${REGISTRY}/${NAME}:${VERSION}"
|
||||
|
||||
echo "==> Docker image építése: $IMAGE"
|
||||
docker build -t "$IMAGE" .
|
||||
|
||||
# "run" argumentummal rögtön el is indítja a konténert
|
||||
if [[ "${1:-}" == "run" ]]; then
|
||||
case "${1:-}" in
|
||||
push)
|
||||
echo "==> Push a registrybe: $IMAGE"
|
||||
docker push "$IMAGE"
|
||||
echo "==> Kész: $IMAGE"
|
||||
;;
|
||||
run)
|
||||
echo "==> Korábbi konténer leállítása (ha fut)"
|
||||
docker rm -f "$CONTAINER" 2>/dev/null || true
|
||||
|
||||
echo "==> Konténer indítása a $PORT porton"
|
||||
docker run -d \
|
||||
--name "$CONTAINER" \
|
||||
@@ -23,10 +33,11 @@ if [[ "${1:-}" == "run" ]]; then
|
||||
-p "${PORT}:3000" \
|
||||
-e NODE_ENV=production \
|
||||
"$IMAGE"
|
||||
|
||||
echo "==> Kész. Elérhető: http://localhost:${PORT}"
|
||||
echo " Logok: docker logs -f $CONTAINER"
|
||||
else
|
||||
echo "==> Elérhető: http://localhost:${PORT} (logok: docker logs -f $CONTAINER)"
|
||||
;;
|
||||
*)
|
||||
echo "==> Build kész: $IMAGE"
|
||||
echo " Futtatás: ./build.sh run vagy docker compose up -d"
|
||||
fi
|
||||
echo " Push: ./build.sh push"
|
||||
echo " Futtatás: ./build.sh run"
|
||||
;;
|
||||
esac
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
services:
|
||||
webhook:
|
||||
build: .
|
||||
image: webhook-hu:latest
|
||||
# A verziót a .env-ből vagy környezetből veszi (VERSION=$(node -p "require('./package.json').version"))
|
||||
image: git.ervin.hu/ervin/webhook-hu:${VERSION:-1.0.0}
|
||||
container_name: webhook-hu
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
|
||||
Reference in new issue
Block a user