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
|
#!/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
|
set -euo pipefail
|
||||||
|
|
||||||
IMAGE="webhook-hu:latest"
|
REGISTRY="git.ervin.hu/ervin"
|
||||||
|
NAME="webhook-hu"
|
||||||
CONTAINER="webhook-hu"
|
CONTAINER="webhook-hu"
|
||||||
PORT="${PORT:-3000}"
|
PORT="${PORT:-3000}"
|
||||||
|
|
||||||
cd "$(dirname "$0")"
|
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"
|
echo "==> Docker image építése: $IMAGE"
|
||||||
docker build -t "$IMAGE" .
|
docker build -t "$IMAGE" .
|
||||||
|
|
||||||
# "run" argumentummal rögtön el is indítja a konténert
|
case "${1:-}" in
|
||||||
if [[ "${1:-}" == "run" ]]; then
|
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)"
|
echo "==> Korábbi konténer leállítása (ha fut)"
|
||||||
docker rm -f "$CONTAINER" 2>/dev/null || true
|
docker rm -f "$CONTAINER" 2>/dev/null || true
|
||||||
|
|
||||||
echo "==> Konténer indítása a $PORT porton"
|
echo "==> Konténer indítása a $PORT porton"
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name "$CONTAINER" \
|
--name "$CONTAINER" \
|
||||||
@@ -23,10 +33,11 @@ if [[ "${1:-}" == "run" ]]; then
|
|||||||
-p "${PORT}:3000" \
|
-p "${PORT}:3000" \
|
||||||
-e NODE_ENV=production \
|
-e NODE_ENV=production \
|
||||||
"$IMAGE"
|
"$IMAGE"
|
||||||
|
echo "==> Elérhető: http://localhost:${PORT} (logok: docker logs -f $CONTAINER)"
|
||||||
echo "==> Kész. Elérhető: http://localhost:${PORT}"
|
;;
|
||||||
echo " Logok: docker logs -f $CONTAINER"
|
*)
|
||||||
else
|
|
||||||
echo "==> Build kész: $IMAGE"
|
echo "==> Build kész: $IMAGE"
|
||||||
echo " Futtatás: ./build.sh run vagy docker compose up -d"
|
echo " Push: ./build.sh push"
|
||||||
fi
|
echo " Futtatás: ./build.sh run"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
+2
-1
@@ -1,7 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
webhook:
|
webhook:
|
||||||
build: .
|
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
|
container_name: webhook-hu
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
Reference in new issue
Block a user