fix(buildscripts): make build process more closely resemble EE (#8881)
parent
98e6393274
commit
58d130ee37
26
Makefile
26
Makefile
|
@ -5,6 +5,7 @@ PLATFORM=$(shell go env GOOS)
|
|||
ARCH=$(shell go env GOARCH)
|
||||
|
||||
TAG=latest
|
||||
SWAG_VERSION=v1.8.11
|
||||
|
||||
# build target, can be one of "production", "testing", "development"
|
||||
ENV=development
|
||||
|
@ -17,21 +18,21 @@ WEBPACK_CONFIG=webpack/webpack.$(ENV).js
|
|||
##@ Building
|
||||
|
||||
init-dist:
|
||||
mkdir -p dist
|
||||
@mkdir -p dist
|
||||
|
||||
build-storybook:
|
||||
yarn storybook:build
|
||||
|
||||
build-client: init-dist ## Build the client
|
||||
@export NODE_ENV=$(ENV) && yarn build --config $(WEBPACK_CONFIG)
|
||||
|
||||
build-server: init-dist ## Build the server binary
|
||||
@./build/build_binary.sh "$(PLATFORM)" "$(ARCH)"
|
||||
|
||||
build: build-server build-client ## Build the server and client
|
||||
|
||||
build-client: init-dist client-deps ## Build the client
|
||||
export NODE_ENV=$(ENV) && yarn build --config $(WEBPACK_CONFIG)
|
||||
|
||||
build-server: init-dist ## Build the server binary
|
||||
./build/build_binary.sh "$(PLATFORM)" "$(ARCH)"
|
||||
|
||||
build-image: build ## Build the Portainer image
|
||||
docker build -t portainerci/portainer:$(TAG) -f build/linux/Dockerfile .
|
||||
docker buildx build --load -t portainerci/portainer:$(TAG) -f build/linux/Dockerfile .
|
||||
|
||||
devops: clean init-dist download-binaries build-client ## Build the server binary for CI
|
||||
echo "Building the devops binary..."
|
||||
|
@ -66,6 +67,9 @@ test: test-client test-server ## Run all tests
|
|||
|
||||
##@ Dev
|
||||
|
||||
dev-client: ## Run the client in development mode
|
||||
yarn dev
|
||||
|
||||
dev-server: build-image ## Run the server in development mode
|
||||
@./dev/run_container.sh
|
||||
|
||||
|
@ -82,14 +86,14 @@ format: format-client format-server ## Format all code
|
|||
|
||||
##@ Lint
|
||||
|
||||
lint: lint-client lint-server ## Lint all code
|
||||
|
||||
lint-client: ## Lint client code
|
||||
yarn lint
|
||||
|
||||
lint-server: ## Lint server code
|
||||
cd api && go vet ./...
|
||||
|
||||
lint: lint-client lint-server ## Lint all code
|
||||
|
||||
##@ Extension
|
||||
|
||||
dev-extension: build-server build-client ## Run the extension in development mode
|
||||
|
@ -98,7 +102,7 @@ dev-extension: build-server build-client ## Run the extension in development mod
|
|||
##@ Docs
|
||||
|
||||
docs-deps: ## Install docs dependencies
|
||||
go install github.com/swaggo/swag/cmd/swag@v1.8.11
|
||||
go install github.com/swaggo/swag/cmd/swag@$(SWAG_VERSION)
|
||||
|
||||
docs-build: docs-deps ## Build docs
|
||||
cd api && swag init -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 --markdownFiles ./
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
|
||||
$ErrorActionPreference = "Stop";
|
||||
|
||||
$binary = "portainer.exe"
|
||||
$project_path = $((Get-Location).Path)
|
||||
|
||||
New-Item -Name dist -Path "$project_path" -ItemType Directory | Out-Null
|
||||
Set-Location -Path "$project_path\api\cmd\portainer"
|
||||
|
||||
# copy templates
|
||||
Copy-Item -Path "./mustache-templates" -Destination "./dist" -Recurse
|
||||
|
||||
|
||||
C:\go\bin\go.exe get -t -d -v ./...
|
||||
C:\go\bin\go.exe build -v
|
||||
|
||||
Move-Item -Path "$($binary)" -Destination "..\..\..\dist"
|
|
@ -1,20 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
DEBUG=${DEBUG:-""}
|
||||
if [ -n "$DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
mkdir -p dist
|
||||
|
||||
# populate tool versions
|
||||
BUILD_NUMBER=${BUILD_NUMBER:-"N/A"}
|
||||
CONTAINER_IMAGE_TAG=${CONTAINER_IMAGE_TAG:-"N/A"}
|
||||
NODE_VERSION=${NODE_VERSION:-"0"}
|
||||
YARN_VERSION=${YARN_VERSION:-"0"}
|
||||
WEBPACK_VERSION=${WEBPACK_VERSION:-"0"}
|
||||
GO_VERSION=${GO_VERSION:-"0"}
|
||||
BUILDNUMBER="N/A"
|
||||
CONTAINER_IMAGE_TAG="N/A"
|
||||
NODE_VERSION="0"
|
||||
YARN_VERSION="0"
|
||||
WEBPACK_VERSION="0"
|
||||
GO_VERSION="0"
|
||||
|
||||
# copy templates
|
||||
cp -r "./mustache-templates" "./dist"
|
||||
|
@ -24,16 +19,23 @@ cd api || exit 1
|
|||
# the go get adds 8 seconds
|
||||
go get -t -d -v ./...
|
||||
|
||||
|
||||
ldflags="-s -X 'github.com/portainer/liblicense.LicenseServerBaseURL=https://api.portainer.io' \
|
||||
-X 'github.com/portainer/portainer-ee/api/build.BuildNumber=${BUILDNUMBER}' \
|
||||
-X 'github.com/portainer/portainer-ee/api/build.ImageTag=${CONTAINER_IMAGE_TAG}' \
|
||||
-X 'github.com/portainer/portainer-ee/api/build.NodejsVersion=${NODE_VERSION}' \
|
||||
-X 'github.com/portainer/portainer-ee/api/build.YarnVersion=${YARN_VERSION}' \
|
||||
-X 'github.com/portainer/portainer-ee/api/build.WebpackVersion=${WEBPACK_VERSION}' \
|
||||
-X 'github.com/portainer/portainer-ee/api/build.GoVersion=${GO_VERSION}'"
|
||||
|
||||
BINARY_VERSION_FILE="../binary-version.json"
|
||||
|
||||
echo "$ldflags"
|
||||
|
||||
# the build takes 2 seconds
|
||||
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build \
|
||||
GOOS=${1:-$(go env GOOS)} GOARCH=${2:-$(go env GOARCH)} CGO_ENABLED=0 go build \
|
||||
-trimpath \
|
||||
--installsuffix cgo \
|
||||
--ldflags "-s \
|
||||
--X 'github.com/portainer/portainer/api/build.BuildNumber=${BUILD_NUMBER}' \
|
||||
--X 'github.com/portainer/portainer/api/build.ImageTag=${CONTAINER_IMAGE_TAG}' \
|
||||
--X 'github.com/portainer/portainer/api/build.NodejsVersion=${NODE_VERSION}' \
|
||||
--X 'github.com/portainer/portainer/api/build.YarnVersion=${YARN_VERSION}' \
|
||||
--X 'github.com/portainer/portainer/api/build.WebpackVersion=${WEBPACK_VERSION}' \
|
||||
--X 'github.com/portainer/portainer/api/build.GoVersion=${GO_VERSION}'" \
|
||||
-o "../dist/portainer" \
|
||||
./cmd/portainer/
|
||||
--ldflags "$ldflags" \
|
||||
-o "../dist/portainer" \
|
||||
./cmd/portainer/
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
PORTAINER_DATA=${PORTAINER_DATA:-/tmp/portainer}
|
||||
PORTAINER_PROJECT=${PORTAINER_PROJECT:-$(pwd)}
|
||||
PORTAINER_FLAGS=${PORTAINER_FLAGS:-}
|
||||
|
||||
PORTAINER_DATA=${PORTAINER_DATA:-/tmp/portainer};
|
||||
PORTAINER_PROJECT=${PORTAINER_PROJECT:-$(pwd)};
|
||||
PORTAINER_FLAGS=${PORTAINER_FLAGS:-};
|
||||
|
||||
docker rm -f portainer
|
||||
docker rm -f portainer > /dev/null
|
||||
|
||||
docker run -d \
|
||||
-p 8000:8000 \
|
||||
|
@ -20,4 +18,4 @@ docker run -d \
|
|||
-v /tmp:/tmp \
|
||||
--name portainer \
|
||||
portainer/base \
|
||||
/app/portainer "${@:PORTAINER_FLAGS}"
|
||||
/app/portainer ${PORTAINER_FLAGS}
|
||||
|
|
Loading…
Reference in New Issue