36 lines
1.1 KiB
Makefile
36 lines
1.1 KiB
Makefile
APP_NAME = backend
|
|
CMD_DIR = cmd/$(APP_NAME)
|
|
DOCKER_IMAGE_NAME = photodisk:latest
|
|
DOCKER_REGISTRY = registry.rgkn.dev
|
|
|
|
# Default target: builds the application for the host OS
|
|
build:
|
|
@echo "Building the application for the host OS..."
|
|
go build -o $(CMD_DIR)/$(APP_NAME) $(CMD_DIR)/main.go
|
|
|
|
# Build the application for Linux
|
|
build-linux:
|
|
@echo "Building the application for Linux..."
|
|
CGO_ENABLED=1 go build -tags musl --ldflags "-extldflags -static" -o $(CMD_DIR)/$(APP_NAME) $(CMD_DIR)/main.go
|
|
|
|
# Run the application
|
|
run:
|
|
@echo "Running the application..."
|
|
go run $(CMD_DIR)/main.go $(ARGS)
|
|
|
|
# Build Docker image
|
|
docker:
|
|
@echo "Building Docker image..."
|
|
docker buildx build -t $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME) --platform linux/amd64,linux/arm64 -f Dockerfile --push .
|
|
|
|
deploy: docker
|
|
@echo "Deploying Docker image..."
|
|
docker tag $(DOCKER_IMAGE_NAME) $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME)
|
|
docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME)
|
|
|
|
# Clean up
|
|
clean:
|
|
@echo "Cleaning up..."
|
|
rm -f $(CMD_DIR)/$(APP_NAME)
|
|
|
|
.PHONY: build build-linux run docker clean |