Standalone Deployment
Add Makefile:
# Binary name
BINARY_NAME=lrbooks
.PHONY: lint
lint:
@echo "Linting..."
golangci-lint run
build:
@echo "Building $(BINARY_NAME)..."
go build -o $(BINARY_NAME)
build-linux:
@echo "Building $(BINARY_NAME) for Linux..."
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o $(BINARY_NAME)
golangci-lint
is a Go linters aggregator.
Run make build
to build a binary:
make build
This is equivalent to go build -o lrbooks
. It will create a binary file named lrbooks
in your project folder.
Make sure you have the config.yml
config file along with your bin file, and all yours databases are ready to serve.
Then, you can just run it as a standalone server:
export GIN_MODE=release
./lrbooks
Send some requests with curl, you will see something like this in the server logs:
[GIN] 2024/02/27 - 17:43:52 | 200 | 8.251271ms | 127.0.0.1 | GET "/books/2/reviews?q=masterpiece"
[GIN] 2024/02/27 - 17:50:48 | 200 | 6.398599ms | 127.0.0.1 | GET "/books"
It works like a charm! ⭐️
Loading...
> code result goes here