mirror of https://github.com/portainer/portainer
fix(buildscripts): make build process more closely resemble EE (#8881)
parent
5fd36ee986
commit
96a626324c
26
Makefile
26
Makefile
|
@ -5,6 +5,7 @@ PLATFORM=$(shell go env GOOS)
|
||||||
ARCH=$(shell go env GOARCH)
|
ARCH=$(shell go env GOARCH)
|
||||||
|
|
||||||
TAG=latest
|
TAG=latest
|
||||||
|
SWAG_VERSION=v1.8.11
|
||||||
|
|
||||||
# build target, can be one of "production", "testing", "development"
|
# build target, can be one of "production", "testing", "development"
|
||||||
ENV=development
|
ENV=development
|
||||||
|
@ -17,21 +18,21 @@ WEBPACK_CONFIG=webpack/webpack.$(ENV).js
|
||||||
##@ Building
|
##@ Building
|
||||||
|
|
||||||
init-dist:
|
init-dist:
|
||||||
mkdir -p dist
|
@mkdir -p dist
|
||||||
|
|
||||||
build-storybook:
|
build-storybook:
|
||||||
yarn storybook:build
|
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: 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
|
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
|
devops: clean init-dist download-binaries build-client ## Build the server binary for CI
|
||||||
echo "Building the devops binary..."
|
echo "Building the devops binary..."
|
||||||
|
@ -66,6 +67,9 @@ test: test-client test-server ## Run all tests
|
||||||
|
|
||||||
##@ Dev
|
##@ Dev
|
||||||
|
|
||||||
|
dev-client: ## Run the client in development mode
|
||||||
|
yarn dev
|
||||||
|
|
||||||
dev-server: build-image ## Run the server in development mode
|
dev-server: build-image ## Run the server in development mode
|
||||||
@./dev/run_container.sh
|
@./dev/run_container.sh
|
||||||
|
|
||||||
|
@ -82,14 +86,14 @@ format: format-client format-server ## Format all code
|
||||||
|
|
||||||
##@ Lint
|
##@ Lint
|
||||||
|
|
||||||
|
lint: lint-client lint-server ## Lint all code
|
||||||
|
|
||||||
lint-client: ## Lint client code
|
lint-client: ## Lint client code
|
||||||
yarn lint
|
yarn lint
|
||||||
|
|
||||||
lint-server: ## Lint server code
|
lint-server: ## Lint server code
|
||||||
cd api && go vet ./...
|
cd api && go vet ./...
|
||||||
|
|
||||||
lint: lint-client lint-server ## Lint all code
|
|
||||||
|
|
||||||
##@ Extension
|
##@ Extension
|
||||||
|
|
||||||
dev-extension: build-server build-client ## Run the extension in development mode
|
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
|
||||||
|
|
||||||
docs-deps: ## Install docs dependencies
|
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
|
docs-build: docs-deps ## Build docs
|
||||||
cd api && swag init -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 --markdownFiles ./
|
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,13 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
DEBUG=${DEBUG:-""}
|
|
||||||
if [ -n "$DEBUG" ]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p dist
|
|
||||||
|
|
||||||
# populate tool versions
|
# populate tool versions
|
||||||
BUILDNUMBER="N/A"
|
BUILDNUMBER="N/A"
|
||||||
CONTAINER_IMAGE_TAG="N/A"
|
CONTAINER_IMAGE_TAG="N/A"
|
||||||
|
@ -16,14 +9,28 @@ YARN_VERSION="0"
|
||||||
WEBPACK_VERSION="0"
|
WEBPACK_VERSION="0"
|
||||||
GO_VERSION="0"
|
GO_VERSION="0"
|
||||||
|
|
||||||
|
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}'"
|
||||||
|
|
||||||
|
echo "LDFLAGS=${ldflags}"
|
||||||
|
|
||||||
|
# create output folder
|
||||||
|
mkdir -p dist
|
||||||
|
|
||||||
# copy templates
|
# copy templates
|
||||||
cp -r "./mustache-templates" "./dist"
|
cp -r "./mustache-templates" "./dist"
|
||||||
|
|
||||||
|
|
||||||
cd api || exit 1
|
cd api || exit 1
|
||||||
|
|
||||||
# the go get adds 8 seconds
|
# the go get adds 8 seconds
|
||||||
go get -t -d -v ./...
|
go get -t -d -v ./...
|
||||||
|
|
||||||
|
|
||||||
# the build takes 2 seconds
|
# the build takes 2 seconds
|
||||||
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build \
|
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build \
|
||||||
-trimpath \
|
-trimpath \
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
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};
|
docker rm -f portainer > /dev/null
|
||||||
PORTAINER_PROJECT=${PORTAINER_PROJECT:-$(pwd)};
|
|
||||||
PORTAINER_FLAGS=${PORTAINER_FLAGS:-};
|
|
||||||
|
|
||||||
docker rm -f portainer
|
|
||||||
|
|
||||||
docker run -d \
|
docker run -d \
|
||||||
-p 8000:8000 \
|
-p 8000:8000 \
|
||||||
|
@ -20,4 +18,4 @@ docker run -d \
|
||||||
-v /tmp:/tmp \
|
-v /tmp:/tmp \
|
||||||
--name portainer \
|
--name portainer \
|
||||||
portainer/base \
|
portainer/base \
|
||||||
/app/portainer "${@:PORTAINER_FLAGS}"
|
/app/portainer ${PORTAINER_FLAGS}
|
||||||
|
|
Loading…
Reference in New Issue