61 lines
1.3 KiB
Bash
Executable File
61 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
cd "$(dirname "$0")"
|
|
|
|
BASE="${PWD}/../"
|
|
IMAGE="m1k1o/neko"
|
|
|
|
build_client() {
|
|
docker build -t neko-dev-client -f base/Dockerfile --target client "${BASE}"
|
|
docker run --rm \
|
|
--user "$(id -u):$(id -g)" \
|
|
-v "${BASE}client/dist:/tmp/dist" \
|
|
neko-dev-client sh -c "rm -rf /tmp/dist/*; cp -r /src/dist/* /tmp/dist"
|
|
}
|
|
|
|
build_server() {
|
|
docker build -t neko-dev-server -f base/Dockerfile --target server "${BASE}"
|
|
docker run --rm \
|
|
--user "$(id -u):$(id -g)" \
|
|
-v "${BASE}server/bin:/tmp/bin" \
|
|
neko-dev-server sh -c "rm -rf /tmp/bin/neko; cp /src/bin/neko /tmp/bin"
|
|
}
|
|
|
|
build() {
|
|
IMAGE="${IMAGE}:$1"
|
|
echo "Building $IMAGE"
|
|
|
|
if [ "$1" = "base" ]
|
|
then
|
|
# build base
|
|
docker build -t "${IMAGE}" -f base/Dockerfile "${BASE}"
|
|
else
|
|
# buld image
|
|
docker build -t "${IMAGE}" -f "$1/Dockerfile" "$1/"
|
|
fi
|
|
}
|
|
|
|
build_arm() {
|
|
IMAGE="${IMAGE}:arm-$1"
|
|
echo "Building (arm) $IMAGE"
|
|
|
|
if [ "$1" = "base" ]
|
|
then
|
|
# build ARM base
|
|
docker build -t "${IMAGE}" -f arm-base/Dockerfile "${BASE}"
|
|
else
|
|
# buld ARM image
|
|
docker build -t "${IMAGE}" --build-arg="BASE_IMAGE=${IMAGE}:arm-base" -f "$1/Dockerfile" "$1/"
|
|
fi
|
|
}
|
|
|
|
case $1 in
|
|
client) build_client;;
|
|
server) build_server;;
|
|
|
|
# build arm- images
|
|
arm-*) build_arm "${1#arm-}";;
|
|
|
|
# build images
|
|
*) build "$1";;
|
|
esac
|