AvanzaCast/packages/studio-panel/build_and_pack_docker.sh

37 lines
780 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR=$(cd "$(dirname "$0")" && pwd)
cd "$ROOT_DIR"
echo "[1/5] Installing dependencies"
npm ci
echo "[2/5] Running Vite build"
npm run build
echo "[3/5] Creating Dockerfile.simple and building image"
cat > Dockerfile.simple <<'EOF'
FROM nginx:stable-alpine
COPY dist /usr/share/nginx/html
COPY deploy/nginx.avanzacast.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
EOF
IMAGE_TAG="avanzacast/studio-panel:local"
docker build -f Dockerfile.simple -t "$IMAGE_TAG" .
TS=$(date +%s)
OUT=/tmp/studio-panel-image-${TS}.tar
echo "[4/5] Saving docker image to $OUT"
docker save "$IMAGE_TAG" -o "$OUT"
echo "[5/5] Done. Image saved to: $OUT"
ls -lh "$OUT"
# keep the artifact path for caller
echo "$OUT"