This project provides a Makefile for common development and runtime tasks.
Current commands reflect the repository Makefile.
- Go
1.24.x gofmtgoimports(used bymake fmt)- Docker (for Docker targets)
Install goimports:
go install golang.org/x/tools/cmd/goimports@latest| Target | Description |
|---|---|
make all |
Run fmt, test, build |
make fmt |
Run gofmt -w . and goimports -w . |
make test |
Run go test -v ./... |
make build |
Build binary to ./bin/${APP_NAME} |
make run |
Run ./bin/${APP_NAME} |
make clean |
Remove built binary |
| Target | Description |
|---|---|
make docker-build |
Build image ${IMAGE_NAME} |
make docker-run |
Run container ${APP_NAME} |
make docker-clean |
Stop and remove container ${APP_NAME} |
| Variable | Default | Description |
|---|---|---|
APP_NAME |
dudu-admin-api |
Binary and container name |
TZ |
Asia/Shanghai |
Docker build timezone argument |
IMAGE_NAME |
${APP_NAME}:latest |
Docker image name |
CONFIG_DIR |
${PWD}/bin/configs |
Config mount path for container |
RUN_ENV |
local |
Runtime environment passed to container |
Basic flow:
make all
make runDocker flow:
make docker-build
RUN_ENV=prod make docker-run
make docker-cleanCustom app/image names:
APP_NAME=dudu-admin-api-dev make build
IMAGE_NAME=my-registry/dudu-admin-api:v1.0.0 make docker-buildgoimports: command not found:
go install golang.org/x/tools/cmd/goimports@latestBinary not found when running make run:
make build
make runDocker permission issues:
sudo make docker-build
sudo make docker-run