Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support local building for multiple platforms #600

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -19,6 +20,9 @@ package:
frontend:
./scripts/build_frontend.sh

localfe:
./scripts/build_local_frontend.sh

binary:
./scripts/build_binary.sh

Expand Down
5 changes: 4 additions & 1 deletion scripts/build_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions scripts/build_local_frontend.sh
Original file line number Diff line number Diff line change
@@ -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

Loading