mirror of https://github.com/portainer/portainer
build: introduce central Makefile and live-reload for Go (#184)
parent
a261f60764
commit
bb6815f681
|
@ -0,0 +1,52 @@
|
||||||
|
root = "."
|
||||||
|
testdata_dir = "testdata"
|
||||||
|
tmp_dir = ".tmp"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
args_bin = []
|
||||||
|
bin = "./dist/portainer"
|
||||||
|
cmd = "SKIP_GO_GET=true make build-server"
|
||||||
|
delay = 1000
|
||||||
|
exclude_dir = []
|
||||||
|
exclude_file = []
|
||||||
|
exclude_regex = ["_test.go"]
|
||||||
|
exclude_unchanged = false
|
||||||
|
follow_symlink = false
|
||||||
|
full_bin = "./dist/portainer --log-level=DEBUG"
|
||||||
|
include_dir = ["api"]
|
||||||
|
include_ext = ["go"]
|
||||||
|
include_file = []
|
||||||
|
kill_delay = "0s"
|
||||||
|
log = "build-errors.log"
|
||||||
|
poll = false
|
||||||
|
poll_interval = 0
|
||||||
|
post_cmd = []
|
||||||
|
pre_cmd = []
|
||||||
|
rerun = false
|
||||||
|
rerun_delay = 500
|
||||||
|
send_interrupt = false
|
||||||
|
stop_on_error = false
|
||||||
|
|
||||||
|
[color]
|
||||||
|
app = ""
|
||||||
|
build = "yellow"
|
||||||
|
main = "magenta"
|
||||||
|
runner = "green"
|
||||||
|
watcher = "cyan"
|
||||||
|
|
||||||
|
[log]
|
||||||
|
main_only = false
|
||||||
|
silent = false
|
||||||
|
time = false
|
||||||
|
|
||||||
|
[misc]
|
||||||
|
clean_on_exit = false
|
||||||
|
|
||||||
|
[proxy]
|
||||||
|
app_port = 0
|
||||||
|
enabled = false
|
||||||
|
proxy_port = 0
|
||||||
|
|
||||||
|
[screen]
|
||||||
|
clear_on_rebuild = false
|
||||||
|
keep_scroll = true
|
8
Makefile
8
Makefile
|
@ -17,11 +17,13 @@ GOTESTSUM=go run gotest.tools/gotestsum@latest
|
||||||
|
|
||||||
|
|
||||||
##@ Building
|
##@ Building
|
||||||
.PHONY: init-dist build-storybook build build-client build-server build-image devops
|
.PHONY: all init-dist build-storybook build build-client build-server build-image devops
|
||||||
init-dist:
|
init-dist:
|
||||||
@mkdir -p dist
|
@mkdir -p dist
|
||||||
|
|
||||||
build-all: deps build-server build-client ## Build the client, server and download external dependancies (doesn't build an image)
|
all: tidy deps build-server build-client ## Build the client, server and download external dependancies (doesn't build an image)
|
||||||
|
|
||||||
|
build-all: all ## Alias for the 'all' target (used by CI)
|
||||||
|
|
||||||
build-client: init-dist ## Build the client
|
build-client: init-dist ## Build the client
|
||||||
export NODE_ENV=$(ENV) && yarn build --config $(WEBPACK_CONFIG)
|
export NODE_ENV=$(ENV) && yarn build --config $(WEBPACK_CONFIG)
|
||||||
|
@ -50,7 +52,7 @@ client-deps: ## Install client dependencies
|
||||||
yarn
|
yarn
|
||||||
|
|
||||||
tidy: ## Tidy up the go.mod file
|
tidy: ## Tidy up the go.mod file
|
||||||
cd api && go mod tidy
|
@go mod tidy
|
||||||
|
|
||||||
|
|
||||||
##@ Cleanup
|
##@ Cleanup
|
||||||
|
|
|
@ -32,8 +32,14 @@ cp -r "./mustache-templates" "./dist"
|
||||||
|
|
||||||
|
|
||||||
cd api || exit 1
|
cd api || exit 1
|
||||||
# the go get adds 8 seconds
|
|
||||||
go get -t -d -v ./...
|
# Conditionally run go get based on the SKIP_GO_GET environment variable
|
||||||
|
# This process adds a bit of time to the build
|
||||||
|
# This is useful in the CI/CD pipeline to ensure that all dependencies are available
|
||||||
|
if [ "${SKIP_GO_GET:-false}" = false ]; then
|
||||||
|
echo "Running go get -t -v ./..."
|
||||||
|
go get -t -v ./...
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
ldflags="-s -X 'github.com/portainer/liblicense.LicenseServerBaseURL=https://api.portainer.io' \
|
ldflags="-s -X 'github.com/portainer/liblicense.LicenseServerBaseURL=https://api.portainer.io' \
|
||||||
|
@ -51,7 +57,6 @@ ldflags="-s -X 'github.com/portainer/liblicense.LicenseServerBaseURL=https://api
|
||||||
|
|
||||||
echo "$ldflags"
|
echo "$ldflags"
|
||||||
|
|
||||||
# the build takes 2 seconds
|
|
||||||
GOOS=${1:-$(go env GOOS)} GOARCH=${2:-$(go env GOARCH)} CGO_ENABLED=0 go build \
|
GOOS=${1:-$(go env GOOS)} GOARCH=${2:-$(go env GOARCH)} CGO_ENABLED=0 go build \
|
||||||
-trimpath \
|
-trimpath \
|
||||||
--installsuffix cgo \
|
--installsuffix cgo \
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
||||||
PLATFORM=${1:-"linux"}
|
PLATFORM=${1:-"linux"}
|
||||||
ARCH=${2:-"amd64"}
|
ARCH=${2:-"amd64"}
|
||||||
|
|
||||||
|
@ -14,10 +13,49 @@ mingitVersion=$(jq -r '.mingit' < "${BINARY_VERSION_FILE}")
|
||||||
|
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
|
|
||||||
echo "Downloading binaries for docker ${dockerVersion}, helm ${helmVersion}, kubectl ${kubectlVersion} and mingit ${mingitVersion}"
|
echo "Checking and downloading binaries for docker ${dockerVersion}, helm ${helmVersion}, kubectl ${kubectlVersion} and mingit ${mingitVersion} (Windows only)"
|
||||||
|
|
||||||
./build/download_docker_binary.sh "$PLATFORM" "$ARCH" "$dockerVersion" &
|
# Determine the binary file names based on the platform
|
||||||
./build/download_helm_binary.sh "$PLATFORM" "$ARCH" "$helmVersion" &
|
dockerBinary="dist/docker"
|
||||||
./build/download_kubectl_binary.sh "$PLATFORM" "$ARCH" "$kubectlVersion" &
|
helmBinary="dist/helm"
|
||||||
./build/download_mingit_binary.sh "$PLATFORM" "$ARCH" "$mingitVersion" &
|
kubectlBinary="dist/kubectl"
|
||||||
wait
|
|
||||||
|
if [ "$PLATFORM" == "windows" ]; then
|
||||||
|
dockerBinary="dist/docker.exe"
|
||||||
|
helmBinary="dist/helm.exe"
|
||||||
|
kubectlBinary="dist/kubectl.exe"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check and download docker binary
|
||||||
|
if [ ! -f "$dockerBinary" ]; then
|
||||||
|
echo "Downloading docker binary..."
|
||||||
|
/usr/bin/env bash ./build/download_docker_binary.sh "$PLATFORM" "$ARCH" "$dockerVersion"
|
||||||
|
else
|
||||||
|
echo "Docker binary already exists, skipping download."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check and download helm binary
|
||||||
|
if [ ! -f "$helmBinary" ]; then
|
||||||
|
echo "Downloading helm binary..."
|
||||||
|
/usr/bin/env bash ./build/download_helm_binary.sh "$PLATFORM" "$ARCH" "$helmVersion"
|
||||||
|
else
|
||||||
|
echo "Helm binary already exists, skipping download."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check and download kubectl binary
|
||||||
|
if [ ! -f "$kubectlBinary" ]; then
|
||||||
|
echo "Downloading kubectl binary..."
|
||||||
|
/usr/bin/env bash ./build/download_kubectl_binary.sh "$PLATFORM" "$ARCH" "$kubectlVersion"
|
||||||
|
else
|
||||||
|
echo "Kubectl binary already exists, skipping download."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check and download mingit binary only for Windows
|
||||||
|
if [ "$PLATFORM" == "windows" ]; then
|
||||||
|
if [ ! -f "dist/mingit" ]; then
|
||||||
|
echo "Downloading mingit binary..."
|
||||||
|
/usr/bin/env bash ./build/download_mingit_binary.sh "$PLATFORM" "$ARCH" "$mingitVersion"
|
||||||
|
else
|
||||||
|
echo "Mingit binary already exists, skipping download."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'*.(js|ts){,x}': 'eslint --cache --fix',
|
'*.(js|ts){,x}': 'yarn lint',
|
||||||
'*.(ts){,x}': () => 'tsc --noEmit',
|
'*.(ts){,x}': () => 'tsc --noEmit',
|
||||||
'*.{js,ts,tsx,css,md,html,json}': 'prettier --write',
|
'*.{js,ts,tsx,css,md,html,json}': 'yarn format',
|
||||||
'*.go': () => 'make lint-server',
|
'*.go': () => 'make lint-server',
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"format": "prettier --log-level warn --write \"**/*.{js,css,html,jsx,tsx,ts,json}\"",
|
"format": "prettier --log-level warn --write \"**/*.{js,css,html,jsx,tsx,ts,json}\"",
|
||||||
"lint": "eslint --cache --fix './**/*.{js,jsx,ts,tsx}'",
|
"lint": "eslint --cache --fix './**/*.{js,jsx,ts,tsx}'",
|
||||||
"test": "vitest",
|
"test": "vitest run",
|
||||||
"sb": "yarn storybook",
|
"sb": "yarn storybook",
|
||||||
"storybook": "storybook dev -p 6006",
|
"storybook": "storybook dev -p 6006",
|
||||||
"storybook:build": "storybook build -o ./dist/storybook",
|
"storybook:build": "storybook build -o ./dist/storybook",
|
||||||
|
|
Loading…
Reference in New Issue