mirror of https://github.com/portainer/portainer
fix(ci): use makefile again (#8987)
fix(makefile): revert makefile build process for 2.18 (#8977)"pull/8999/head
parent
7ed9f310eb
commit
62ac9c5a5a
|
@ -1,44 +0,0 @@
|
||||||
version: "2"
|
|
||||||
checks:
|
|
||||||
argument-count:
|
|
||||||
enabled: false
|
|
||||||
complex-logic:
|
|
||||||
enabled: false
|
|
||||||
file-lines:
|
|
||||||
enabled: false
|
|
||||||
method-complexity:
|
|
||||||
enabled: false
|
|
||||||
method-count:
|
|
||||||
enabled: false
|
|
||||||
method-lines:
|
|
||||||
enabled: false
|
|
||||||
nested-control-flow:
|
|
||||||
enabled: false
|
|
||||||
return-statements:
|
|
||||||
enabled: false
|
|
||||||
similar-code:
|
|
||||||
enabled: false
|
|
||||||
identical-code:
|
|
||||||
enabled: false
|
|
||||||
plugins:
|
|
||||||
gofmt:
|
|
||||||
enabled: true
|
|
||||||
eslint:
|
|
||||||
enabled: true
|
|
||||||
channel: "eslint-5"
|
|
||||||
config:
|
|
||||||
config: .eslintrc.yml
|
|
||||||
exclude_patterns:
|
|
||||||
- assets/
|
|
||||||
- build/
|
|
||||||
- dist/
|
|
||||||
- distribution/
|
|
||||||
- node_modules
|
|
||||||
- test/
|
|
||||||
- webpack/
|
|
||||||
- gruntfile.js
|
|
||||||
- webpack.config.js
|
|
||||||
- api/
|
|
||||||
- "!app/kubernetes/**"
|
|
||||||
- .github/
|
|
||||||
- .tmp/
|
|
|
@ -114,8 +114,11 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 18.x
|
||||||
|
|
||||||
- name: Install packages and build
|
- name: Install packages
|
||||||
run: yarn install && yarn build
|
run: yarn --frozen-lockfile
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
run: make build
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
|
@ -149,8 +149,11 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 18.x
|
||||||
|
|
||||||
- name: Install packages and build
|
- name: Install packages
|
||||||
run: yarn install && yarn build
|
run: yarn --frozen-lockfile
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
run: make build
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
|
@ -220,7 +223,6 @@ jobs:
|
||||||
godiff: ${{fromJson(needs.server-dependencies.outputs.godiff)}}
|
godiff: ${{fromJson(needs.server-dependencies.outputs.godiff)}}
|
||||||
imagediff: ${{fromJson(needs.image-vulnerability.outputs.imagediff)}}
|
imagediff: ${{fromJson(needs.image-vulnerability.outputs.imagediff)}}
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Check job status of diff result
|
- name: Check job status of diff result
|
||||||
if: >-
|
if: >-
|
||||||
matrix.jsdiff.status == 'failure' ||
|
matrix.jsdiff.status == 'failure' ||
|
||||||
|
|
|
@ -8,12 +8,12 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: '18'
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
- run: yarn --frozen-lockfile
|
- run: yarn --frozen-lockfile
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: yarn test:client
|
run: yarn jest --maxWorkers=2
|
||||||
# test-server:
|
# test-server:
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
# env:
|
# env:
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
name: Validate OpenAPI specs
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- 'release/*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
openapi-spec:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.18'
|
||||||
|
|
||||||
|
- name: Download golang modules
|
||||||
|
run: cd ./api && go get -t -v -d ./...
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
cache: 'yarn'
|
||||||
|
- run: yarn --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Validate OpenAPI Spec
|
||||||
|
run: make docs-validate
|
|
@ -1,53 +0,0 @@
|
||||||
name: Validate
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- 'release/*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
openapi-spec:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout Code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Node v14
|
|
||||||
uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: 14
|
|
||||||
|
|
||||||
# https://github.com/actions/cache/blob/main/examples.md#node---yarn
|
|
||||||
- name: Get yarn cache directory path
|
|
||||||
id: yarn-cache-dir-path
|
|
||||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
|
|
||||||
- name: Setup Go v1.17.3
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '^1.17.3'
|
|
||||||
|
|
||||||
- name: Prebuild docs
|
|
||||||
run: yarn prebuild:docs
|
|
||||||
|
|
||||||
- name: Build OpenAPI 2.0 Spec
|
|
||||||
run: yarn build:docs
|
|
||||||
|
|
||||||
# Install dependencies globally to bypass installing all frontend deps
|
|
||||||
- name: Install swagger2openapi and swagger-cli
|
|
||||||
run: yarn global add swagger2openapi @apidevtools/swagger-cli
|
|
||||||
|
|
||||||
# OpenAPI2.0 does not support multiple body params (which we utilise in some of our handlers).
|
|
||||||
# OAS3.0 however does support multiple body params - hence its best to convert the generated OAS 2.0
|
|
||||||
# to OAS 3.0 and validate the output of generated OAS 3.0 instead.
|
|
||||||
- name: Convert OpenAPI 2.0 to OpenAPI 3.0 and validate spec
|
|
||||||
run: yarn validate:docs
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
# See: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63
|
||||||
|
# For a list of valid GOOS and GOARCH values
|
||||||
|
# Note: these can be overriden on the command line e.g. `make PLATFORM=<platform> ARCH=<arch>`
|
||||||
|
PLATFORM=$(shell go env GOOS)
|
||||||
|
ARCH=$(shell go env GOARCH)
|
||||||
|
|
||||||
|
# build target, can be one of "production", "testing", "development"
|
||||||
|
ENV=development
|
||||||
|
WEBPACK_CONFIG=webpack/webpack.$(ENV).js
|
||||||
|
TAG=latest
|
||||||
|
|
||||||
|
SWAG=go run github.com/swaggo/swag/cmd/swag@v1.8.11
|
||||||
|
GOTESTSUM=go run gotest.tools/gotestsum@latest
|
||||||
|
|
||||||
|
# Don't change anything below this line unless you know what you're doing
|
||||||
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
|
|
||||||
|
##@ Building
|
||||||
|
.PHONY: init-dist build-storybook build build-client build-server build-image devops
|
||||||
|
init-dist:
|
||||||
|
@mkdir -p dist
|
||||||
|
|
||||||
|
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 locally
|
||||||
|
docker buildx build --load -t portainerci/portainer:$(TAG) -f build/linux/Dockerfile .
|
||||||
|
|
||||||
|
devops: clean init-dist server-deps build-client ## Build the server binary for CI
|
||||||
|
echo "Building the devops binary..."
|
||||||
|
@./build/build_binary_azuredevops.sh "$(PLATFORM)" "$(ARCH)"
|
||||||
|
|
||||||
|
build-storybook:
|
||||||
|
yarn storybook:build
|
||||||
|
|
||||||
|
##@ Build dependencies
|
||||||
|
.PHONY: deps server-deps client-deps tidy
|
||||||
|
deps-all: server-deps client-deps ## Download all client and server build dependancies
|
||||||
|
|
||||||
|
server-deps: ## Download dependant server binaries
|
||||||
|
@./build/download_binaries.sh $(PLATFORM) $(ARCH)
|
||||||
|
|
||||||
|
client-deps: ## Install client dependencies
|
||||||
|
yarn
|
||||||
|
|
||||||
|
tidy: ## Tidy up the go.mod file
|
||||||
|
cd api && go mod tidy
|
||||||
|
|
||||||
|
|
||||||
|
##@ Cleanup
|
||||||
|
.PHONY: clean
|
||||||
|
clean: ## Remove all build and download artifacts
|
||||||
|
@echo "Clearing the dist directory..."
|
||||||
|
@rm -rf dist/*
|
||||||
|
|
||||||
|
|
||||||
|
##@ Testing
|
||||||
|
.PHONY: test test-client test-server
|
||||||
|
test: test-server test-client ## Run all tests
|
||||||
|
|
||||||
|
test-client: ## Run client tests
|
||||||
|
yarn test
|
||||||
|
|
||||||
|
test-server: ## Run server tests
|
||||||
|
cd api && $(GOTESTSUM) --format pkgname-and-test-fails --format-hide-empty-pkg --hide-summary skipped -- -cover ./...
|
||||||
|
|
||||||
|
##@ Dev
|
||||||
|
.PHONY: dev dev-client dev-server
|
||||||
|
dev: ## Run both the client and server in development mode
|
||||||
|
make dev-server
|
||||||
|
make dev-client
|
||||||
|
|
||||||
|
dev-client: ## Run the client in development mode
|
||||||
|
yarn dev
|
||||||
|
|
||||||
|
dev-server: ## Run the server in development mode
|
||||||
|
@./dev/run_container.sh
|
||||||
|
|
||||||
|
|
||||||
|
##@ Format
|
||||||
|
.PHONY: format format-client format-server
|
||||||
|
|
||||||
|
format: format-client format-server ## Format all code
|
||||||
|
|
||||||
|
format-client: ## Format client code
|
||||||
|
yarn format
|
||||||
|
|
||||||
|
format-server: ## Format server code
|
||||||
|
cd api && go fmt ./...
|
||||||
|
|
||||||
|
##@ Lint
|
||||||
|
.PHONY: lint lint-client lint-server
|
||||||
|
lint: lint-client lint-server ## Lint all code
|
||||||
|
|
||||||
|
lint-client: ## Lint client code
|
||||||
|
yarn lint
|
||||||
|
|
||||||
|
lint-server: ## Lint server code
|
||||||
|
cd api && go vet ./...
|
||||||
|
|
||||||
|
|
||||||
|
##@ Extension
|
||||||
|
.PHONY: dev-extension
|
||||||
|
dev-extension: build-server build-client ## Run the extension in development mode
|
||||||
|
make local -f build/docker-extension/Makefile
|
||||||
|
|
||||||
|
|
||||||
|
##@ Docs
|
||||||
|
.PHONY: docs-build docs-validate docs-clean docs-validate-clean
|
||||||
|
docs-build: ## Build docs
|
||||||
|
cd api && $(SWAG) init -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 --markdownFiles ./
|
||||||
|
|
||||||
|
docs-validate: docs-build ## Validate docs
|
||||||
|
yarn swagger2openapi --warnOnly api/docs/swagger.yaml -o api/docs/openapi.yaml
|
||||||
|
yarn swagger-cli validate api/docs/openapi.yaml
|
||||||
|
|
||||||
|
docs-clean: ## Clean docs
|
||||||
|
rm -rf api/docs
|
||||||
|
|
||||||
|
docs-validate-clean: docs-validate docs-clean ## Validate and clean docs
|
||||||
|
|
||||||
|
|
||||||
|
##@ Helpers
|
||||||
|
.PHONY: help
|
||||||
|
help: ## Display this help
|
||||||
|
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"docker": "v20.10.21",
|
||||||
|
"dockerCompose": "v2.17.2",
|
||||||
|
"helm": "v3.11.0",
|
||||||
|
"kubectl": "v1.26.3"
|
||||||
|
}
|
48
build.sh
48
build.sh
|
@ -1,48 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
ARCHIVE_BUILD_FOLDER="/tmp/portainer-builds"
|
|
||||||
|
|
||||||
# parameter: "platform-architecture"
|
|
||||||
function build_and_push_images() {
|
|
||||||
docker build -t "portainer/portainer:$1-${VERSION}" -f build/linux/Dockerfile .
|
|
||||||
docker tag "portainer/portainer:$1-${VERSION}" "portainer/portainer:$1"
|
|
||||||
docker push "portainer/portainer:$1-${VERSION}"
|
|
||||||
docker push "portainer/portainer:$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# parameter: "platform-architecture"
|
|
||||||
function build_archive() {
|
|
||||||
BUILD_FOLDER="${ARCHIVE_BUILD_FOLDER}/$1"
|
|
||||||
rm -rf ${BUILD_FOLDER} && mkdir -pv ${BUILD_FOLDER}/portainer
|
|
||||||
cp -r dist/* ${BUILD_FOLDER}/portainer/
|
|
||||||
cd ${BUILD_FOLDER}
|
|
||||||
tar cvpfz "portainer-${VERSION}-$1.tar.gz" portainer
|
|
||||||
mv "portainer-${VERSION}-$1.tar.gz" ${ARCHIVE_BUILD_FOLDER}/
|
|
||||||
cd -
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_all() {
|
|
||||||
mkdir -pv "${ARCHIVE_BUILD_FOLDER}"
|
|
||||||
for tag in $@; do
|
|
||||||
yarn grunt "release:`echo "$tag" | tr '-' ':'`"
|
|
||||||
name="portainer"; if [ "$(echo "$tag" | cut -c1)" = "w" ]; then name="${name}.exe"; fi
|
|
||||||
mv dist/portainer-$tag* dist/$name
|
|
||||||
if [ `echo $tag | cut -d \- -f 1` == 'linux' ]; then build_and_push_images "$tag"; fi
|
|
||||||
build_archive "$tag"
|
|
||||||
done
|
|
||||||
docker rmi $(docker images -q -f dangling=true)
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ $# -ne 1 ]] ; then
|
|
||||||
echo "Usage: $(basename $0) <VERSION>"
|
|
||||||
echo " $(basename $0) \"echo 'Custom' && <BASH COMMANDS>\""
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
VERSION="$1"
|
|
||||||
if [ `echo "$@" | cut -c1-4` == 'echo' ]; then
|
|
||||||
bash -c "$@";
|
|
||||||
else
|
|
||||||
build_all 'linux-amd64 linux-arm linux-arm64 linux-ppc64le linux-s390x darwin-amd64 windows-amd64'
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
|
@ -1,21 +0,0 @@
|
||||||
param (
|
|
||||||
[string]$platform,
|
|
||||||
[string]$arch
|
|
||||||
)
|
|
||||||
|
|
||||||
$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,6 +1,5 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
set -x
|
|
||||||
|
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
|
|
||||||
|
@ -16,20 +15,27 @@ GO_VERSION="0"
|
||||||
cp -r "./mustache-templates" "./dist"
|
cp -r "./mustache-templates" "./dist"
|
||||||
|
|
||||||
|
|
||||||
cd api
|
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 ./...
|
||||||
|
|
||||||
|
|
||||||
|
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
|
# 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 \
|
-trimpath \
|
||||||
--installsuffix cgo \
|
--installsuffix cgo \
|
||||||
--ldflags "-s \
|
--ldflags "$ldflags" \
|
||||||
--X 'github.com/portainer/portainer/api/build.BuildNumber=${BUILDNUMBER}' \
|
|
||||||
--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" \
|
-o "../dist/portainer" \
|
||||||
./cmd/portainer/
|
./cmd/portainer/
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
||||||
|
PLATFORM=${1:-"linux"}
|
||||||
|
ARCH=${2:-"amd64"}
|
||||||
|
|
||||||
|
BINARY_VERSION_FILE="./binary-version.json"
|
||||||
|
|
||||||
|
dockerVersion=$(jq -r '.docker' < "${BINARY_VERSION_FILE}")
|
||||||
|
dockerComposeVersion=$(jq -r '.dockerCompose' < "${BINARY_VERSION_FILE}")
|
||||||
|
helmVersion=$(jq -r '.helm' < "${BINARY_VERSION_FILE}")
|
||||||
|
kubectlVersion=$(jq -r '.kubectl' < "${BINARY_VERSION_FILE}")
|
||||||
|
|
||||||
|
mkdir -p dist
|
||||||
|
|
||||||
|
echo "Downloading binaries for docker ${dockerVersion}, docker-compose ${dockerComposeVersion}, helm ${helmVersion}, kubectl ${kubectlVersion}"
|
||||||
|
|
||||||
|
./build/download_docker_binary.sh "$PLATFORM" "$ARCH" "$dockerVersion" &
|
||||||
|
./build/download_docker_compose_binary.sh "$PLATFORM" "$ARCH" "$dockerComposeVersion" &
|
||||||
|
./build/download_helm_binary.sh "$PLATFORM" "$ARCH" "$helmVersion" &
|
||||||
|
./build/download_kubectl_binary.sh "$PLATFORM" "$ARCH" "$kubectlVersion" &
|
||||||
|
wait
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
|
||||||
|
PORTAINER_DATA=${PORTAINER_DATA:-/tmp/portainer};
|
||||||
|
PORTAINER_PROJECT=${PORTAINER_PROJECT:-$(pwd)};
|
||||||
|
PORTAINER_FLAGS=${PORTAINER_FLAGS:-};
|
||||||
|
|
||||||
|
docker rm -f portainer
|
||||||
|
|
||||||
|
docker run -d \
|
||||||
|
-p 8000:8000 \
|
||||||
|
-p 9000:9000 \
|
||||||
|
-p 9443:9443 \
|
||||||
|
-v "$PORTAINER_PROJECT/dist:/app" \
|
||||||
|
-v "$PORTAINER_DATA:/data" \
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock:z \
|
||||||
|
-v /var/run/docker.sock:/var/run/alternative.sock:z \
|
||||||
|
-v /tmp:/tmp \
|
||||||
|
--name portainer \
|
||||||
|
portainer/base \
|
||||||
|
/app/portainer "${@:PORTAINER_FLAGS}"
|
|
@ -0,0 +1,2 @@
|
||||||
|
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||||
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
238
gruntfile.js
238
gruntfile.js
|
@ -1,238 +0,0 @@
|
||||||
const os = require('os');
|
|
||||||
const loadGruntTasks = require('load-grunt-tasks');
|
|
||||||
const webpackDevConfig = require('./webpack/webpack.develop');
|
|
||||||
const webpackProdConfig = require('./webpack/webpack.production');
|
|
||||||
const webpackTestingConfig = require('./webpack/webpack.testing');
|
|
||||||
|
|
||||||
let arch = os.arch();
|
|
||||||
if (arch === 'x64') {
|
|
||||||
arch = 'amd64';
|
|
||||||
}
|
|
||||||
let platform = os.platform();
|
|
||||||
switch (platform) {
|
|
||||||
case 'windows':
|
|
||||||
case 'darwin':
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
platform = 'linux';
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = function (grunt) {
|
|
||||||
loadGruntTasks(grunt, {
|
|
||||||
pattern: ['grunt-*', 'gruntify-*'],
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.initConfig({
|
|
||||||
root: 'dist',
|
|
||||||
distdir: 'dist/public',
|
|
||||||
binaries: {
|
|
||||||
dockerVersion: 'v20.10.21',
|
|
||||||
dockerComposePluginVersion: 'v2.17.2',
|
|
||||||
helmVersion: 'v3.11.0',
|
|
||||||
kubectlVersion: 'v1.24.1',
|
|
||||||
},
|
|
||||||
env: gruntConfig.env,
|
|
||||||
clean: gruntConfig.clean,
|
|
||||||
shell: gruntConfig.shell,
|
|
||||||
webpack: gruntConfig.webpack,
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.registerTask('lint', ['eslint']);
|
|
||||||
|
|
||||||
grunt.task.registerTask('build:server', 'build:server:<platform>:<arch>', function (p = platform, a = arch) {
|
|
||||||
grunt.task.run([`shell:build_binary:${p}:${a}`, `download_binaries:${p}:${a}`]);
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.registerTask('build:client', ['webpack:dev']);
|
|
||||||
|
|
||||||
grunt.registerTask('build', ['build:server', 'build:client']);
|
|
||||||
|
|
||||||
grunt.registerTask('start:server', ['build:server:linux', 'shell:run_container']);
|
|
||||||
|
|
||||||
grunt.registerTask('start:localserver', [`shell:build_binary:${platform}:${arch}`, 'shell:run_localserver']);
|
|
||||||
|
|
||||||
grunt.registerTask('start:client', ['shell:install_yarndeps', 'webpack:devWatch']);
|
|
||||||
|
|
||||||
grunt.registerTask('start', ['start:server', 'start:client']);
|
|
||||||
|
|
||||||
grunt.registerTask('start:toolkit', ['start:localserver', 'start:client']);
|
|
||||||
|
|
||||||
grunt.task.registerTask('release', 'release:<platform>:<arch>', function (platform = 'linux', a = arch) {
|
|
||||||
grunt.task.run(['env:prod', 'clean:all', `shell:build_binary:${platform}:${a}`, `download_binaries:${platform}:${a}`, 'webpack:prod']);
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.task.registerTask('devopsbuild', 'devopsbuild:<platform>:<arch>:<env>', function (platform, a = arch, env = 'prod') {
|
|
||||||
grunt.task.run([
|
|
||||||
`env:${env}`,
|
|
||||||
'clean:all',
|
|
||||||
`shell:build_binary_azuredevops:${platform}:${a}`,
|
|
||||||
`download_binaries:${platform}:${a}`,
|
|
||||||
`webpack:${env}`,
|
|
||||||
`shell:storybook:${env}`,
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.task.registerTask('download_binaries', 'download_binaries:<platform>:<arch>', function (platform = 'linux', a = arch) {
|
|
||||||
grunt.task.run([
|
|
||||||
`shell:download_docker_binary:${platform}:${a}`,
|
|
||||||
`shell:download_docker_compose_binary:${platform}:${a}`,
|
|
||||||
`shell:download_helm_binary:${platform}:${a}`,
|
|
||||||
`shell:download_kubectl_binary:${platform}:${a}`,
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/***/
|
|
||||||
const gruntConfig = {};
|
|
||||||
|
|
||||||
gruntConfig.env = {
|
|
||||||
dev: {
|
|
||||||
NODE_ENV: 'development',
|
|
||||||
},
|
|
||||||
prod: {
|
|
||||||
NODE_ENV: 'production',
|
|
||||||
},
|
|
||||||
testing: {
|
|
||||||
NODE_ENV: 'testing',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
gruntConfig.webpack = {
|
|
||||||
dev: webpackDevConfig,
|
|
||||||
devWatch: Object.assign({ watch: true }, webpackDevConfig),
|
|
||||||
prod: webpackProdConfig,
|
|
||||||
testing: webpackTestingConfig,
|
|
||||||
};
|
|
||||||
|
|
||||||
gruntConfig.clean = {
|
|
||||||
server: ['<%= root %>/portainer'],
|
|
||||||
client: ['<%= distdir %>/*'],
|
|
||||||
all: ['<%= root %>/*'],
|
|
||||||
};
|
|
||||||
|
|
||||||
gruntConfig.shell = {
|
|
||||||
build_binary: { command: shell_build_binary },
|
|
||||||
build_binary_azuredevops: { command: shell_build_binary_azuredevops },
|
|
||||||
download_docker_binary: { command: shell_download_docker_binary },
|
|
||||||
download_helm_binary: { command: shell_download_helm_binary },
|
|
||||||
download_kubectl_binary: { command: shell_download_kubectl_binary },
|
|
||||||
download_docker_compose_binary: { command: shell_download_docker_compose_binary },
|
|
||||||
run_container: { command: shell_run_container },
|
|
||||||
run_localserver: { command: shell_run_localserver, options: { async: true } },
|
|
||||||
install_yarndeps: { command: shell_install_yarndeps },
|
|
||||||
storybook: { command: shell_storybook },
|
|
||||||
};
|
|
||||||
|
|
||||||
function shell_storybook(env) {
|
|
||||||
if (env === 'prod') {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return `
|
|
||||||
yarn build-storybook
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function shell_build_binary(platform, arch) {
|
|
||||||
const binfile = 'dist/portainer';
|
|
||||||
if (platform === 'linux' || platform === 'darwin') {
|
|
||||||
return `
|
|
||||||
if [ -f ${binfile} ]; then
|
|
||||||
echo "Portainer binary exists";
|
|
||||||
else
|
|
||||||
build/build_binary.sh ${platform} ${arch};
|
|
||||||
fi
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// windows
|
|
||||||
return `
|
|
||||||
powershell -Command "& {if (Get-Item -Path ${binfile}.exe -ErrorAction:SilentlyContinue) {
|
|
||||||
Write-Host "Portainer binary exists"
|
|
||||||
} else {
|
|
||||||
& ".\\build\\build_binary.ps1" -platform ${platform} -arch ${arch}
|
|
||||||
}}"
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function shell_build_binary_azuredevops(platform, arch) {
|
|
||||||
return `build/build_binary_azuredevops.sh ${platform} ${arch};`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function shell_run_container() {
|
|
||||||
const portainerData = '${PORTAINER_DATA:-/tmp/portainer}';
|
|
||||||
const portainerRoot = process.env.PORTAINER_PROJECT ? process.env.PORTAINER_PROJECT : process.env.PWD;
|
|
||||||
const portainerFlags = '${PORTAINER_FLAGS:-}';
|
|
||||||
|
|
||||||
return `
|
|
||||||
docker rm -f portainer
|
|
||||||
docker run -d \
|
|
||||||
-p 8000:8000 \
|
|
||||||
-p 9000:9000 \
|
|
||||||
-p 9443:9443 \
|
|
||||||
-v ${portainerRoot}/dist:/app \
|
|
||||||
-v ${portainerData}:/data \
|
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock:z \
|
|
||||||
-v /var/run/docker.sock:/var/run/alternative.sock:z \
|
|
||||||
-v /tmp:/tmp \
|
|
||||||
--name portainer \
|
|
||||||
portainer/base \
|
|
||||||
/app/portainer ${portainerFlags}
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function shell_run_localserver() {
|
|
||||||
return './dist/portainer';
|
|
||||||
}
|
|
||||||
|
|
||||||
function shell_install_yarndeps() {
|
|
||||||
return 'yarn';
|
|
||||||
}
|
|
||||||
|
|
||||||
function shell_download_docker_binary(platform, arch) {
|
|
||||||
const binaryVersion = '<%= binaries.dockerVersion %>';
|
|
||||||
|
|
||||||
return `
|
|
||||||
if [ -f dist/docker ] || [ -f dist/docker.exe ]; then
|
|
||||||
echo "docker binary exists";
|
|
||||||
else
|
|
||||||
build/download_docker_binary.sh ${platform} ${arch} ${binaryVersion};
|
|
||||||
fi
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function shell_download_docker_compose_binary(platform, arch) {
|
|
||||||
var binaryVersion = '<%= binaries.dockerComposePluginVersion %>';
|
|
||||||
|
|
||||||
return `
|
|
||||||
if [ -f dist/docker-compose ] || [ -f dist/docker-compose.exe ]; then
|
|
||||||
echo "docker compose binary exists";
|
|
||||||
else
|
|
||||||
build/download_docker_compose_binary.sh ${platform} ${arch} ${binaryVersion};
|
|
||||||
fi
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function shell_download_helm_binary(platform, arch) {
|
|
||||||
var binaryVersion = '<%= binaries.helmVersion %>';
|
|
||||||
|
|
||||||
return `
|
|
||||||
if [ -f dist/helm ] || [ -f dist/helm.exe ]; then
|
|
||||||
echo "helm binary exists";
|
|
||||||
else
|
|
||||||
build/download_helm_binary.sh ${platform} ${arch} ${binaryVersion};
|
|
||||||
fi
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function shell_download_kubectl_binary(platform, arch) {
|
|
||||||
var binaryVersion = '<%= binaries.kubectlVersion %>';
|
|
||||||
|
|
||||||
return `
|
|
||||||
if [ -f dist/kubectl ] || [ -f dist/kubectl.exe ]; then
|
|
||||||
echo "kubectl binary exists";
|
|
||||||
else
|
|
||||||
build/download_kubectl_binary.sh ${platform} ${arch} ${binaryVersion};
|
|
||||||
fi
|
|
||||||
`;
|
|
||||||
}
|
|
61
package.json
61
package.json
|
@ -17,52 +17,19 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "grunt clean:all && grunt build",
|
"dev": "webpack-dev-server",
|
||||||
"build:server": "grunt clean:server && grunt build:server",
|
"start": "webpack -w",
|
||||||
"build:client": "grunt clean:client && grunt build:client",
|
"build": "webpack",
|
||||||
"prebuild:docs": "go install github.com/swaggo/swag/cmd/swag@v1.8.11",
|
|
||||||
"build:docs": "cd api && swag init -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 --markdownFiles ./",
|
|
||||||
"validate:docs": "swagger2openapi --warnOnly api/docs/swagger.yaml -o api/docs/openapi.yaml && swagger-cli validate api/docs/openapi.yaml",
|
|
||||||
"clean": "grunt clean:all",
|
|
||||||
"start": "grunt start",
|
|
||||||
"start:clean": "grunt clean:all && grunt start",
|
|
||||||
"start:localserver": "grunt start:localserver",
|
|
||||||
"start:server": "grunt clean:server && grunt start:server",
|
|
||||||
"start:client": "grunt clean:client && grunt start:client",
|
|
||||||
"dev:client": "grunt clean:client && webpack-dev-server --config=./webpack/webpack.develop.js",
|
|
||||||
"dev:client:prod": "grunt clean:client && webpack-dev-server --config=./webpack/webpack.production.js",
|
|
||||||
"dev:nodl": "grunt clean:server && grunt clean:client && grunt build:server && grunt start:client",
|
|
||||||
"dev:extension": "grunt build && make local -f build/docker-extension/Makefile",
|
|
||||||
"start:toolkit": "grunt start:toolkit",
|
|
||||||
"build:server:offline": "cd ./api/cmd/portainer && CGO_ENABLED=0 go build --installsuffix cgo --ldflags '-s' && mv -f portainer ../../../dist/portainer",
|
|
||||||
"clean:all": "grunt clean:all",
|
|
||||||
"format": "prettier --loglevel warn --write \"**/*.{js,css,html,jsx,tsx,ts,json}\"",
|
"format": "prettier --loglevel warn --write \"**/*.{js,css,html,jsx,tsx,ts,json}\"",
|
||||||
"lint": "yarn lint:client; yarn lint:server",
|
"lint": "eslint --cache --fix './**/*.{js,jsx,ts,tsx}'",
|
||||||
"lint:server": "cd api && golangci-lint run -E exportloopref",
|
"test": "jest --silent",
|
||||||
"lint:client": "eslint --cache --fix './**/*.{js,jsx,ts,tsx}'",
|
"sb": "yarn storybook",
|
||||||
"lint:pr": "make lint-pr",
|
|
||||||
"test": "yarn test:client; yarn test:server",
|
|
||||||
"test:server": "cd api && go test ./...",
|
|
||||||
"test:client": "jest --silent",
|
|
||||||
"storybook": "start-storybook -p 6006",
|
"storybook": "start-storybook -p 6006",
|
||||||
"build-storybook": "build-storybook -o ./dist/storybook",
|
"storybook:build": "build-storybook -o ./dist/storybook",
|
||||||
"analyze-webpack": "webpack --config ./webpack/webpack.analyze.js"
|
"analyze-webpack": "webpack --config ./webpack/webpack.analyze.js"
|
||||||
},
|
},
|
||||||
"scriptsComments": {
|
|
||||||
"build": "Build the entire app (backend/frontend) in development mode",
|
|
||||||
"build:server": "Build the backend",
|
|
||||||
"build:client": "Build the frontend (development mode)",
|
|
||||||
"build:docs": "builds API docs",
|
|
||||||
"clean": "Clean the entire dist folder",
|
|
||||||
"start": "Build the entire app (backend/frontend) in development mode, run backend inside a container and start a watch process locally for the frontend files",
|
|
||||||
"start:server": "Build the backend and run it inside a container",
|
|
||||||
"start:toolkit": "Build the entire app (backend/frontend) in development mode, run backend locally and start a watch process for the frontend files",
|
|
||||||
"clean:all": "Deprecated. Use the clean script instead",
|
|
||||||
"build:server:offline": "Deprecated. Use the build:server script instead",
|
|
||||||
"format": "Should be removed before pr is merged"
|
|
||||||
},
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.8.4"
|
"node": ">= 14"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-crypto/sha256-js": "^2.0.0",
|
"@aws-crypto/sha256-js": "^2.0.0",
|
||||||
|
@ -218,24 +185,12 @@
|
||||||
"eslint-plugin-regex": "^1.9.0",
|
"eslint-plugin-regex": "^1.9.0",
|
||||||
"eslint-plugin-storybook": "^0.6.3",
|
"eslint-plugin-storybook": "^0.6.3",
|
||||||
"eslint-webpack-plugin": "^3.1.1",
|
"eslint-webpack-plugin": "^3.1.1",
|
||||||
"grunt": "^1.4.1",
|
|
||||||
"grunt-cli": "^1.4.3",
|
|
||||||
"grunt-contrib-clean": "^2.0.0",
|
|
||||||
"grunt-contrib-copy": "^1.0.0",
|
|
||||||
"grunt-env": "^0.4.4",
|
|
||||||
"grunt-filerev": "^2.3.1",
|
|
||||||
"grunt-replace": "^1.0.1",
|
|
||||||
"grunt-shell-spawn": "^0.4.0",
|
|
||||||
"grunt-usemin": "^3.1.1",
|
|
||||||
"grunt-webpack": "^5.0.0",
|
|
||||||
"gruntify-eslint": "^3.1.0",
|
|
||||||
"html-loader": "^0.5.5",
|
"html-loader": "^0.5.5",
|
||||||
"html-webpack-plugin": "^5.5.0",
|
"html-webpack-plugin": "^5.5.0",
|
||||||
"husky": "4.2.5",
|
"husky": "4.2.5",
|
||||||
"jest": "^27.4.3",
|
"jest": "^27.4.3",
|
||||||
"kubernetes-types": "^1.26.0",
|
"kubernetes-types": "^1.26.0",
|
||||||
"lint-staged": ">=10",
|
"lint-staged": ">=10",
|
||||||
"load-grunt-tasks": "^3.5.2",
|
|
||||||
"lodash-webpack-plugin": "^0.11.6",
|
"lodash-webpack-plugin": "^0.11.6",
|
||||||
"mini-css-extract-plugin": "^2.5.3",
|
"mini-css-extract-plugin": "^2.5.3",
|
||||||
"msw-storybook-addon": "^1.6.3",
|
"msw-storybook-addon": "^1.6.3",
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"description": "This file contains current tool versions",
|
|
||||||
"go_version": "v1.17.6",
|
|
||||||
"node_version": "12.x",
|
|
||||||
"yarn_version": "1.x"
|
|
||||||
}
|
|
|
@ -1 +1 @@
|
||||||
module.exports = require('./webpack/webpack.develop');
|
module.exports = require('./webpack/webpack.development');
|
||||||
|
|
Loading…
Reference in New Issue