2022-11-29 22:35:02 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# RUN IN REPO ROOT DIR !!
|
|
|
|
|
2022-11-30 02:08:59 +01:00
|
|
|
export IMAGE_PREFIX="git.pbiernat.dev/egommerce/order"
|
|
|
|
export BUILDER_IMAGE="$IMAGE_PREFIX-builder:tmp"
|
|
|
|
export SERVER_IMAGE="$IMAGE_PREFIX-svc"
|
|
|
|
export WORKER_IMAGE="$IMAGE_PREFIX-worker"
|
2022-11-29 22:35:02 +01:00
|
|
|
|
|
|
|
TARGET=${1:-latest}
|
|
|
|
|
2022-12-01 06:22:54 +01:00
|
|
|
[ ! -d \"src/vendor\" ] && sh -c "cd src; go mod vendor"
|
|
|
|
|
|
|
|
export DOCKER_BUILDKIT=1
|
|
|
|
|
|
|
|
docker build -t "$BUILDER_IMAGE" -f Dockerfile.builder . >/dev/null 2>&1 && echo "Successfully tagged $BUILDER_IMAGE"
|
2022-11-30 02:08:59 +01:00
|
|
|
|
|
|
|
echo "Building target $IMAGE_PREFIX images..."
|
|
|
|
if [ $TARGET = "latest" ]
|
|
|
|
then
|
|
|
|
# SERVER
|
2022-12-01 06:22:54 +01:00
|
|
|
docker build --build-arg SVC_NAME=catalog-svc --build-arg SVC_VER="1.0" --build-arg BIN_OUTPUT=/go/bin/server \
|
|
|
|
--rm --build-arg BUILDER_IMAGE --cache-from "$SERVER_IMAGE:$TARGET" -t "$SERVER_IMAGE:$TARGET" \
|
|
|
|
-f Dockerfile.target . >/dev/null 2>&1 && echo "Successfully tagged $SERVER_IMAGE:$TARGET" &
|
2022-11-30 02:08:59 +01:00
|
|
|
|
|
|
|
# WORKER
|
2022-12-01 06:22:54 +01:00
|
|
|
docker build --build-arg SVC_NAME=catalog-worker --build-arg SVC_VER="1.0" --build-arg BIN_OUTPUT=/go/bin/worker \
|
|
|
|
--rm --build-arg BUILDER_IMAGE --cache-from "$WORKER_IMAGE:$TARGET" -t "$WORKER_IMAGE:$TARGET" \
|
|
|
|
-f Dockerfile.target . >/dev/null 2>&1 && echo "Successfully tagged $WORKER_IMAGE:$TARGET"
|
2022-11-30 02:08:59 +01:00
|
|
|
else
|
|
|
|
# SERVER
|
2022-12-01 06:22:54 +01:00
|
|
|
docker build --build-arg SVC_NAME=catalog-svc --build-arg SVC_VER="dev" --build-arg BIN_OUTPUT=/go/bin/server \
|
|
|
|
--rm --build-arg BUILDER_IMAGE --no-cache -t "$SERVER_IMAGE:$TARGET" \
|
|
|
|
-f Dockerfile.target . >/dev/null 2>&1 && echo "Successfully tagged $SERVER_IMAGE:$TARGET" &
|
2022-11-29 22:35:02 +01:00
|
|
|
|
2022-11-30 02:08:59 +01:00
|
|
|
# WORKER
|
2022-12-01 06:22:54 +01:00
|
|
|
docker build --build-arg SVC_NAME=catalog-worker --build-arg SVC_VER="dev" --build-arg BIN_OUTPUT=/go/bin/worker \
|
|
|
|
--rm --build-arg BUILDER_IMAGE --no-cache -t "$WORKER_IMAGE:$TARGET" \
|
|
|
|
-f Dockerfile.target . >/dev/null 2>&1 && echo "Successfully tagged $WORKER_IMAGE:$TARGET"
|
2022-11-29 22:35:02 +01:00
|
|
|
fi
|
|
|
|
|
2022-12-01 06:22:54 +01:00
|
|
|
echo "Done."
|