mirror of https://github.com/portainer/portainer
fix(build-system): fix local build system after appveyor introduction (#2528)
parent
65979709e9
commit
79c24ced96
|
@ -38,7 +38,7 @@ init:
|
||||||
if (!(Test-Path ~/.docker)) { mkdir ~/.docker };
|
if (!(Test-Path ~/.docker)) { mkdir ~/.docker };
|
||||||
Set-Content -Value '{ "experimental": "enabled" }' -Path ~/.docker/config.json -Encoding Ascii
|
Set-Content -Value '{ "experimental": "enabled" }' -Path ~/.docker/config.json -Encoding Ascii
|
||||||
build_script:
|
build_script:
|
||||||
- sh: yarn grunt release:$IMAGE:$ARCH
|
- sh: yarn grunt appveyorbuild:$IMAGE:$ARCH
|
||||||
- cmd: yarn grunt release:%IMAGE%:%ARCH%
|
- cmd: yarn grunt appveyorbuild:%IMAGE%:%ARCH%
|
||||||
- sh: sudo bash build/ci-linux.sh $IMAGE $ARCH $DOCKER_USER $DOCKER_PASS $APPVEYOR_REPO_BRANCH $APPVEYOR_PULL_REQUEST_NUMBER
|
- sh: sudo bash build/ci-linux.sh $IMAGE $ARCH $DOCKER_USER $DOCKER_PASS $APPVEYOR_REPO_BRANCH $APPVEYOR_PULL_REQUEST_NUMBER
|
||||||
- cmd: powershell -Command "& .\\build\\ci-windows.ps1"
|
- cmd: powershell -Command "& .\\build\\ci-windows.ps1"
|
|
@ -43,8 +43,8 @@ init:
|
||||||
if (!(Test-Path ~/.docker)) { mkdir ~/.docker }
|
if (!(Test-Path ~/.docker)) { mkdir ~/.docker }
|
||||||
Set-Content -Value '{ "experimental": "enabled" }' -Path ~/.docker/config.json -Encoding Ascii
|
Set-Content -Value '{ "experimental": "enabled" }' -Path ~/.docker/config.json -Encoding Ascii
|
||||||
build_script:
|
build_script:
|
||||||
- sh: yarn grunt release:$IMAGE:$ARCH
|
- sh: yarn grunt appveyorbuild:$IMAGE:$ARCH
|
||||||
- cmd: yarn grunt release:%IMAGE%:%ARCH%
|
- cmd: yarn grunt appveyorbuild:%IMAGE%:%ARCH%
|
||||||
- sh: sudo bash build/release-linux.sh $IMAGE $ARCH $PORTAINER_VERSION $DOCKER_USER $DOCKER_PASS
|
- sh: sudo bash build/release-linux.sh $IMAGE $ARCH $PORTAINER_VERSION $DOCKER_USER $DOCKER_PASS
|
||||||
- cmd: powershell -Command "& .\\build\\release-windows.ps1"
|
- cmd: powershell -Command "& .\\build\\release-windows.ps1"
|
||||||
test: off
|
test: off
|
||||||
|
|
|
@ -8,17 +8,10 @@ $ErrorActionPreference = "Stop";
|
||||||
$binary = "portainer.exe"
|
$binary = "portainer.exe"
|
||||||
$project_path = (Get-ITEM -Path env:APPVEYOR_BUILD_FOLDER).Value
|
$project_path = (Get-ITEM -Path env:APPVEYOR_BUILD_FOLDER).Value
|
||||||
|
|
||||||
Set-Item env:GOPATH "$project_path\api"
|
|
||||||
|
|
||||||
New-Item -Name dist -Path "$project_path" -ItemType Directory | Out-Null
|
New-Item -Name dist -Path "$project_path" -ItemType Directory | Out-Null
|
||||||
New-Item -Name portainer -Path "$project_path\api\src\github.com\" -ItemType Directory | Out-Null
|
|
||||||
|
|
||||||
Copy-Item -Path "$project_path\api" -Destination "$project_path\api\src\github.com\portainer" -Recurse -Force -ErrorAction:SilentlyContinue
|
|
||||||
Rename-Item -Path "$project_path\api\src\github.com\portainer\api" -NewName "portainer" -ErrorAction:SilentlyContinue
|
|
||||||
|
|
||||||
Set-Location -Path "$project_path\api\cmd\portainer"
|
Set-Location -Path "$project_path\api\cmd\portainer"
|
||||||
|
|
||||||
C:\go\bin\go.exe get -t -d -v ./...
|
C:\go\bin\go.exe get -t -d -v ./...
|
||||||
C:\go\bin\go.exe build -v
|
C:\go\bin\go.exe build -v
|
||||||
|
|
||||||
Move-Item -Path "$project_path\api\cmd\portainer\$($binary)" -Destination "$project_path\dist"
|
Move-Item -Path "$($binary)" -Destination "..\..\..\dist"
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
export GOPATH="$APPVEYOR_BUILD_FOLDER/api"
|
|
||||||
binary="portainer"
|
binary="portainer"
|
||||||
|
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
mkdir -p api/src/github.com/portainer/
|
|
||||||
|
|
||||||
cp -R api/ api/src/github.com/portainer/portainer/
|
|
||||||
|
|
||||||
cd 'api/cmd/portainer'
|
cd 'api/cmd/portainer'
|
||||||
|
|
||||||
go get -t -d -v ./...
|
go get -t -d -v ./...
|
||||||
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags '-s'
|
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags '-s'
|
||||||
|
|
||||||
mv "$APPVEYOR_BUILD_FOLDER/api/cmd/portainer/$binary" "$APPVEYOR_BUILD_FOLDER/dist/portainer"
|
mv "${binary}" "../../../dist/portainer"
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
param (
|
||||||
|
[string]$platform,
|
||||||
|
[string]$arch
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop";
|
||||||
|
|
||||||
|
$binary = "portainer.exe"
|
||||||
|
$project_path = (Get-ITEM -Path env:APPVEYOR_BUILD_FOLDER).Value
|
||||||
|
|
||||||
|
Set-Item env:GOPATH "$project_path\api"
|
||||||
|
|
||||||
|
New-Item -Name dist -Path "$project_path" -ItemType Directory | Out-Null
|
||||||
|
New-Item -Name portainer -Path "$project_path\api\src\github.com\" -ItemType Directory | Out-Null
|
||||||
|
|
||||||
|
Copy-Item -Path "$project_path\api" -Destination "$project_path\api\src\github.com\portainer" -Recurse -Force -ErrorAction:SilentlyContinue
|
||||||
|
Rename-Item -Path "$project_path\api\src\github.com\portainer\api" -NewName "portainer" -ErrorAction:SilentlyContinue
|
||||||
|
|
||||||
|
Set-Location -Path "$project_path\api\cmd\portainer"
|
||||||
|
|
||||||
|
C:\go\bin\go.exe get -t -d -v ./...
|
||||||
|
C:\go\bin\go.exe build -v
|
||||||
|
|
||||||
|
Move-Item -Path "$project_path\api\cmd\portainer\$($binary)" -Destination "$project_path\dist"
|
|
@ -0,0 +1,14 @@
|
||||||
|
export GOPATH="$APPVEYOR_BUILD_FOLDER/api"
|
||||||
|
binary="portainer"
|
||||||
|
|
||||||
|
mkdir -p dist
|
||||||
|
mkdir -p api/src/github.com/portainer/
|
||||||
|
|
||||||
|
cp -R api/ api/src/github.com/portainer/portainer/
|
||||||
|
|
||||||
|
cd 'api/cmd/portainer'
|
||||||
|
|
||||||
|
go get -t -d -v ./...
|
||||||
|
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags '-s'
|
||||||
|
|
||||||
|
mv "$APPVEYOR_BUILD_FOLDER/api/cmd/portainer/$binary" "$APPVEYOR_BUILD_FOLDER/dist/portainer"
|
57
gruntfile.js
57
gruntfile.js
|
@ -50,6 +50,11 @@ module.exports = function(grunt) {
|
||||||
grunt.task.registerTask('release', 'release:<platform>:<arch>', function(p, a) {
|
grunt.task.registerTask('release', 'release:<platform>:<arch>', function(p, a) {
|
||||||
grunt.task.run(['config:prod', 'clean:all', 'shell:buildBinary:' + p + ':' + a, 'shell:downloadDockerBinary:' + p + ':' + a, 'before-copy', 'copy:assets', 'after-copy']);
|
grunt.task.run(['config:prod', 'clean:all', 'shell:buildBinary:' + p + ':' + a, 'shell:downloadDockerBinary:' + p + ':' + a, 'before-copy', 'copy:assets', 'after-copy']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
grunt.task.registerTask('appveyorbuild', 'appveyorbuild:<platform>:<arch>', function(p, a) {
|
||||||
|
grunt.task.run(['config:prod', 'clean:all', 'shell:buildBinaryOnAppveyor:' + p + ':' + a, 'shell:downloadDockerBinary:' + p + ':' + a, 'before-copy', 'copy:assets', 'after-copy']);
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask('lint', ['eslint']);
|
grunt.registerTask('lint', ['eslint']);
|
||||||
grunt.registerTask('run-dev', ['build', 'shell:run:' + arch, 'watch:build']);
|
grunt.registerTask('run-dev', ['build', 'shell:run:' + arch, 'watch:build']);
|
||||||
grunt.registerTask('clear', ['clean:app']);
|
grunt.registerTask('clear', ['clean:app']);
|
||||||
|
@ -259,26 +264,49 @@ gruntfile_cfg.replace = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function shell_buildBinary(p, a) {
|
function shell_buildBinary(p, a) {
|
||||||
var binfile = 'portainer-'+p+'-'+a;
|
var binfile = 'portainer-' + p + '-' + a;
|
||||||
if (p === "linux") {
|
if (p === 'linux') {
|
||||||
return [
|
return [
|
||||||
'if [ -f '+(binfile)+' ]; then',
|
'if [ -f ' + (binfile) + ' ]; then',
|
||||||
'echo "Portainer binary exists";',
|
'echo "Portainer binary exists";',
|
||||||
'else',
|
'else',
|
||||||
'build/build_binary.sh ' + p + ' ' + a + ';',
|
'build/build_binary.sh ' + p + ' ' + a + ';',
|
||||||
'fi'
|
'fi'
|
||||||
].join (' ')
|
].join(' ');
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
'powershell -Command "& {if (Get-Item -Path '+(binfile+'.exe')+' -ErrorAction:SilentlyContinue) {',
|
'powershell -Command "& {if (Get-Item -Path ' + binfile + '.exe -ErrorAction:SilentlyContinue) {',
|
||||||
'Write-Host "Portainer binary exists"',
|
'Write-Host "Portainer binary exists"',
|
||||||
'} else {',
|
'} else {',
|
||||||
'& ".\\build\\build_binary.ps1" -platform '+ p +' -arch '+ a +'',
|
'& ".\\build\\build_binary.ps1" -platform ' + p + ' -arch ' + a + '',
|
||||||
'}}"'
|
'}}"'
|
||||||
].join(' ')
|
].join(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shell_buildBinaryOnAppveyor(p, a) {
|
||||||
|
var binfile = 'portainer-' + p + '-' + a;
|
||||||
|
if (p === 'linux') {
|
||||||
|
return [
|
||||||
|
'if [ -f ' + (binfile) + ' ]; then',
|
||||||
|
'echo "Portainer binary exists";',
|
||||||
|
'else',
|
||||||
|
'build/build_binary_appveyor.sh ' + p + ' ' + a + ';',
|
||||||
|
'fi'
|
||||||
|
].join(' ');
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
'powershell -Command "& {if (Get-Item -Path ' + binfile + '.exe -ErrorAction:SilentlyContinue) {',
|
||||||
|
'Write-Host "Portainer binary exists"',
|
||||||
|
'} else {',
|
||||||
|
'& ".\\build\\build_binary_appveyor.ps1" -platform ' + p + ' -arch ' + a + '',
|
||||||
|
'}}"'
|
||||||
|
].join(' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function shell_run(arch) {
|
function shell_run(arch) {
|
||||||
return [
|
return [
|
||||||
'docker rm -f portainer',
|
'docker rm -f portainer',
|
||||||
|
@ -291,28 +319,29 @@ function shell_downloadDockerBinary(p, a) {
|
||||||
var as = { 'amd64': 'x86_64', 'arm': 'armhf', 'arm64': 'aarch64' };
|
var as = { 'amd64': 'x86_64', 'arm': 'armhf', 'arm64': 'aarch64' };
|
||||||
var ip = ((ps[p] === undefined) ? p : ps[p]);
|
var ip = ((ps[p] === undefined) ? p : ps[p]);
|
||||||
var ia = ((as[a] === undefined) ? a : as[a]);
|
var ia = ((as[a] === undefined) ? a : as[a]);
|
||||||
var binaryVersion = (( p === 'windows' ? '<%= shippedDockerVersionWindows %>' : '<%= shippedDockerVersion %>' ));
|
var binaryVersion = ((p === 'windows' ? '<%= shippedDockerVersionWindows %>' : '<%= shippedDockerVersion %>'));
|
||||||
if (p === "linux") {
|
if (p === 'linux') {
|
||||||
return [
|
return [
|
||||||
'if [ -f '+('dist/docker')+' ]; then',
|
'if [ -f dist/docker ]; then',
|
||||||
'echo "Docker binary exists";',
|
'echo "Docker binary exists";',
|
||||||
'else',
|
'else',
|
||||||
'build/download_docker_binary.sh ' + ip + ' ' + ia + ' ' + binaryVersion + ';',
|
'build/download_docker_binary.sh ' + ip + ' ' + ia + ' ' + binaryVersion + ';',
|
||||||
'fi'
|
'fi'
|
||||||
].join (' ')
|
].join(' ');
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
'powershell -Command "& {if (Get-Item -Path '+('dist/docker.exe')+' -ErrorAction:SilentlyContinue) {',
|
'powershell -Command "& {if (Get-Item -Path dist/docker.exe -ErrorAction:SilentlyContinue) {',
|
||||||
'Write-Host "Docker binary exists"',
|
'Write-Host "Docker binary exists"',
|
||||||
'} else {',
|
'} else {',
|
||||||
'& ".\\build\\download_docker_binary.ps1" -docker_version '+ binaryVersion +'',
|
'& ".\\build\\download_docker_binary.ps1" -docker_version ' + binaryVersion + '',
|
||||||
'}}"'
|
'}}"'
|
||||||
].join(' ')
|
].join(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gruntfile_cfg.shell = {
|
gruntfile_cfg.shell = {
|
||||||
buildBinary: { command: shell_buildBinary },
|
buildBinary: { command: shell_buildBinary },
|
||||||
|
buildBinaryOnAppveyor: { command: shell_buildBinaryOnAppveyor },
|
||||||
run: { command: shell_run },
|
run: { command: shell_run },
|
||||||
downloadDockerBinary: { command: shell_downloadDockerBinary }
|
downloadDockerBinary: { command: shell_downloadDockerBinary }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue