diff --git a/Makefile b/Makefile index ddaa9932..f3bc9ffa 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ NAME=homer-app +GOOS ?= linux all: - CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -buildvcs=false -o $(NAME) + CGO_ENABLED=0 GOOS=$(GOOS) go build -ldflags "-s -w" -buildvcs=false -o $(NAME) #go build -a -ldflags '-extldflags "-static"' -o $(NAME) debug: @@ -19,6 +20,9 @@ package: frontend: ./scripts/build_frontend.sh +localfe: + ./scripts/build_local_frontend.sh + binary: ./scripts/build_binary.sh diff --git a/scripts/build_binary.sh b/scripts/build_binary.sh index aea97c96..ec587802 100755 --- a/scripts/build_binary.sh +++ b/scripts/build_binary.sh @@ -5,11 +5,14 @@ if ! [ -x "$(command -v docker)" ]; then exit 1 fi +GOOS=${GOOS:-linux} + # BUILD GO BINARY -read -p "This will drop and rebuild the homer-app binary from source. Continue (y/n)?" CONT +read -p "This will drop and rebuild the homer-app binary from source for ${GOOS}. Continue (y/n)?" CONT if [ "$CONT" = "y" ]; then docker run --rm \ -v $PWD:/app \ + -e GOOS=${GOOS} \ golang:1.22 \ bash -c "cd /app && make modules && make all" else diff --git a/scripts/build_local_frontend.sh b/scripts/build_local_frontend.sh new file mode 100755 index 00000000..f1438f04 --- /dev/null +++ b/scripts/build_local_frontend.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# CHECK FOR DOCKER +if ! [ -x "$(command -v docker)" ]; then + echo 'Error: docker is not installed. Exiting...' >&2 + exit 1 +fi + +# CHECK FOR SPECIFIC DOCKER IMAGE +IMAGE_NAME="homer-ui" +if ! docker image inspect $IMAGE_NAME > /dev/null 2>&1; then + echo "Error: Docker image '$IMAGE_NAME' does not exist. Exiting..." >&2 + exit 1 +fi + +# PULL FRONTEND +read -p "This will pull the Frontend from local ${IMAGE_NAME} docker image. Continue (y/n)?" CONT +if [ "$CONT" = "y" ]; then + echo "Cleaning up..." + mv dist dist.backup + mkdir dist + echo "Pulling Frontend..."; + + if ! docker create --name homer-ui ${IMAGE_NAME} > /dev/null 2>&1; then + echo "Error: unable to create homer-ui container. Exiting..." >&2 + exit 1 + fi + + docker cp homer-ui:/app/dist/homer-ui/. ./dist/ + docker cp homer-ui:/app/src/VERSION.ts /tmp/VERSION.ts + cat /tmp/VERSION.ts | egrep -o '[0-9].[0-9].[0-9]+' > ./dist/VERSION + docker rm -f homer-ui + + ls -alF ./dist + rm -rf dist.backup +else + echo "Exiting..."; +fi +