-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-build.sh
More file actions
38 lines (31 loc) · 1.09 KB
/
docker-build.sh
File metadata and controls
38 lines (31 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
# Build, dual-tag, and export the Docker image.
# No host Node.js required — everything runs inside the container.
#
# Usage:
# ./docker-build.sh # build for native platform
# ./docker-build.sh --export # build + save tar
# ./docker-build.sh --synology # build for linux/amd64 (Synology deploy)
# ./docker-build.sh --synology --export
set -e
IMAGE="mm-compmatrix"
VERSION=$(grep '"version"' package.json | head -1 | sed 's/.*"\([0-9][^"]*\)".*/\1/')
PLATFORM_FLAG=""
EXPORT=false
for arg in "$@"; do
case "$arg" in
--synology) PLATFORM_FLAG="--platform linux/amd64" ;;
--export) EXPORT=true ;;
esac
done
echo "Building ${IMAGE}:${VERSION} + ${IMAGE}:latest ${PLATFORM_FLAG:+($PLATFORM_FLAG)}..."
docker build ${PLATFORM_FLAG} \
-t "${IMAGE}:${VERSION}" \
-t "${IMAGE}:latest" \
.
echo "Build complete: ${IMAGE}:${VERSION}, ${IMAGE}:latest"
if [ "$EXPORT" = "true" ]; then
echo "Exporting to ${IMAGE}.tar ..."
docker save -o "${IMAGE}.tar" "${IMAGE}:${VERSION}" "${IMAGE}:latest"
echo "Saved ${IMAGE}.tar ($(du -h "${IMAGE}.tar" | cut -f1))"
fi