2022-10-06 20:10:05 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# RUN IN REPO ROOT DIR !!
|
|
|
|
|
2024-07-19 21:51:16 +02:00
|
|
|
export IMAGE_PREFIX="git.pbiernat.io/egommerce/identity"
|
|
|
|
export BUILDER_IMAGE="egommerce-builder:identity"
|
2022-12-03 23:36:59 +01:00
|
|
|
export BUILD_TIME=$(date +"%Y%m%d%H%M%S")
|
2022-12-02 21:03:08 +01:00
|
|
|
export SERVER_IMAGE="$IMAGE_PREFIX-svc"
|
2022-12-03 23:36:59 +01:00
|
|
|
export DOCKER_BUILDKIT=1
|
2022-10-06 20:10:05 +02:00
|
|
|
|
2022-12-02 21:03:08 +01:00
|
|
|
TARGET=${1:-latest}
|
|
|
|
|
2022-12-05 21:34:45 +01:00
|
|
|
[ ! -d "src/vendor" ] && sh -c "cd src; go mod vendor"
|
2022-12-02 21:03:08 +01:00
|
|
|
|
2022-12-25 21:07:30 +01:00
|
|
|
echo "Building tmp $IMAGE_PREFIX image..."
|
2022-12-03 23:36:59 +01:00
|
|
|
docker build --rm -t $BUILDER_IMAGE -f Dockerfile.builder .
|
2022-12-02 21:03:08 +01:00
|
|
|
|
|
|
|
if [ $TARGET = "latest" ]
|
|
|
|
then
|
|
|
|
# SERVER
|
2024-07-19 21:51:16 +02:00
|
|
|
docker build --build-arg SVC_NAME=identity-service --build-arg SVC_VER="1.0" --build-arg BIN_OUTPUT=/go/bin/server \
|
2022-12-03 23:36:59 +01:00
|
|
|
--build-arg BUILDER_IMAGE=$BUILDER_IMAGE --build-arg BUILD_TIME --rm --cache-from $SERVER_IMAGE:$TARGET -t $SERVER_IMAGE:$TARGET \
|
|
|
|
-f Dockerfile.target . >/dev/null 2>&1 && echo "Successfully tagged $SERVER_IMAGE:$TARGET"
|
2022-12-02 21:03:08 +01:00
|
|
|
else
|
|
|
|
# SERVER
|
2024-07-19 21:51:16 +02:00
|
|
|
docker build --build-arg SVC_NAME=identity-service --build-arg SVC_VER="dev" --build-arg BIN_OUTPUT=/go/bin/server \
|
2022-12-03 23:36:59 +01:00
|
|
|
--build-arg BUILDER_IMAGE=$BUILDER_IMAGE --build-arg BUILD_TIME --rm --no-cache -t $SERVER_IMAGE:$TARGET \
|
2023-10-01 22:57:26 +02:00
|
|
|
-f Dockerfile.target . >/dev/null 2>&1 && echo "Successfully tagged $SERVER_IMAGE:$TARGET"
|
2022-12-02 21:03:08 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Done."
|