Skip to content

Commit

Permalink
Add building
Browse files Browse the repository at this point in the history
  • Loading branch information
KopiasCsaba committed Nov 8, 2023
1 parent 518f279 commit 6acaf3b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
29 changes: 2 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,9 @@ SHELL := /bin/bash
help: ## Display this help screen
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

#.PHONY: build
#build: _setup_buildx ## Builds the production binaries, and exits
# @docker compose -f docker/docker-compose.yml build app-prod-builder
# @rm build/app-prod.image.tar.gz > /dev/null 2>&1 || true
# @docker save app-prod | gzip > build/app-prod.image.tar.gz
# @echo ""
# @echo "Exported build/app-prod.image.tar.gz"
# @ls -lha build/app-prod.image.tar.gz

.PHONY: build
build: _setup_buildx ## Builds the production binaries, and exits
@docker/build.sh
@cp /tmp/codebase/build/app-linux-amd64.bin /data/home/csaba/cprojects/audio/ccp_audio_system_manual/setup/streampc/docker/console-obs-bridge/oscbridge;
@cp src/config.yml /data/home/csaba/cprojects/audio/ccp_audio_system_manual/setup/streampc/docker/console-obs-bridge/config/ccp-oscbridge.yml



.PHONY: build_debug
build_debug: _setup_buildx ## Executes a shell in the build container, you can manually execute the build script and tweak/debug.
@echo "To start the building, execute /mnt/docker/build.sh"
@docker container rm app-builder || true
@docker compose -f docker/docker-compose.yml run -u root --entrypoint "/bin/bash -l" app-prod-builder

build: _setup_buildx _dev_init ## Builds the production binaries, and exits
@docker compose -f docker/docker-compose.yml run --entrypoint "bash -l /mnt/docker/build.sh" app-dev

.PHONY: dev_start
dev_start: _setup_buildx _dev_init ## Starts the development environment.
Expand All @@ -60,18 +40,13 @@ dev_start_debug: _setup_buildx _dev_init ## Starts the development container w
dev_shell: ## Attaches a shell to the running development environment. (make dev_start needed for it)
@docker compose -f docker/docker-compose.yml exec app-dev bash -l

.PHONY: dev_generate
dev_generate: ## Updates/generates code
@docker compose -f docker/docker-compose.yml exec app-dev bash -l "/mnt/src/adapters/pgrepos/orm/generate.sh"

.PHONY: dev_root_shell
dev_root_shell: ## Attaches a root shell to the running development environment. (make dev_start needed for it)
@docker compose -f docker/docker-compose.yml exec -u root app-dev bash -l

.PHONY: lint
lint: _lint_prep _lint_exec ## Executes the linter in the dev env


.PHONY: _lint_prep
_lint_prep: _setup_buildx _dev_init
@docker compose -f docker/docker-compose.yml build --build-arg UID=$$(id -u) --build-arg GID=$$(id -g) app-dev
Expand Down
7 changes: 0 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ RUN echo 'export PATH="${PATH}:/usr/local/go/bin"' >> /etc/profile
WORKDIR /mnt


# =========================================================================================================
FROM buildbase as build


ENTRYPOINT ["/bin/bash","-l","-c", "./docker/build.sh;"]



# =========================================================================================================
FROM buildbase AS development
Expand Down
8 changes: 5 additions & 3 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Jump to the src directory, with a relative cd to this script's location.
cd "$(dirname "$0")/../src" || exit

BUILD_DIR="/tmp/codebase/build/"
BUILD_DIR="/mnt/build/"
export GOPATH=""

echo -e "Downloading dependencies...\n"
Expand All @@ -18,14 +18,15 @@ build_application() {
export CGO_ENABLED=0
export GOOS=$1
export GOARCH=$2
export EXTENSION=$3

echo "BUILDING for $GOOS/$GOARCH"

rm "$BUILD_DIR/app-$GOOS-$GOARCH.bin" >/dev/null 2>&1

go build -tags netgo \
-ldflags "-s -w -X main.Revision=$(git rev-parse HEAD 2>/dev/null || echo 1) -X main.BuildTime=$(date +'%Y-%m-%d_%T') " \
-o "$BUILD_DIR/app-$GOOS-$GOARCH.bin" \
-o "$BUILD_DIR/app-$GOOS-$GOARCH.$EXTENSION" \
cmd/main/main.go


Expand All @@ -36,7 +37,8 @@ build_application() {

# Normal compilation for linux/amd64 platform
export CC=gcc
build_application linux amd64
build_application linux amd64 bin
build_application windows amd64 exe

echo "BUILT ARTIFACTS:"
ls -lh "$BUILD_DIR"

0 comments on commit 6acaf3b

Please sign in to comment.