mirror of https://github.com/portainer/portainer
refactor(build-system): clarify build system usage through yarn (#3140)
* refactor(build-system): clarify build system usage through yarn * refactor(build-system): rename azure devops build scriptspull/3141/head
parent
849ff8cf9b
commit
2b48f1e49a
145
gruntfile.js
145
gruntfile.js
|
@ -1,38 +1,67 @@
|
||||||
const webpackDevConfig = require('./webpack/webpack.develop');
|
const webpackDevConfig = require('./webpack/webpack.develop');
|
||||||
const webpackProdConfig = require('./webpack/webpack.production');
|
const webpackProdConfig = require('./webpack/webpack.production');
|
||||||
var gruntfile_cfg = {};
|
|
||||||
var loadGruntTasks = require('load-grunt-tasks');
|
var loadGruntTasks = require('load-grunt-tasks');
|
||||||
|
|
||||||
var os = require('os');
|
var os = require('os');
|
||||||
var arch = os.arch();
|
var arch = os.arch();
|
||||||
if (arch === 'x64') arch = 'amd64';
|
if (arch === 'x64') arch = 'amd64';
|
||||||
|
|
||||||
|
var portainer_data = '/tmp/portainer';
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
loadGruntTasks(grunt, {
|
loadGruntTasks(grunt, {
|
||||||
pattern: ['grunt-*', 'gruntify-*']
|
pattern: ['grunt-*', 'gruntify-*']
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('default', ['eslint', 'build']);
|
grunt.initConfig({
|
||||||
|
root: 'dist',
|
||||||
|
distdir: 'dist/public',
|
||||||
|
shippedDockerVersion: '18.09.3',
|
||||||
|
shippedDockerVersionWindows: '17.09.0-ce',
|
||||||
|
config: gruntfile_cfg.config,
|
||||||
|
env: gruntfile_cfg.env,
|
||||||
|
src: gruntfile_cfg.src,
|
||||||
|
clean: gruntfile_cfg.clean,
|
||||||
|
eslint: gruntfile_cfg.eslint,
|
||||||
|
shell: gruntfile_cfg.shell,
|
||||||
|
copy: gruntfile_cfg.copy,
|
||||||
|
webpack: gruntfile_cfg.webpack
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask('build-webapp', [
|
grunt.registerTask('lint', ['eslint']);
|
||||||
'config:prod',
|
|
||||||
'env:prod',
|
|
||||||
'clean:all',
|
|
||||||
'copy:templates',
|
|
||||||
'webpack:prod']);
|
|
||||||
|
|
||||||
grunt.registerTask('build', [
|
grunt.registerTask('build:server', [
|
||||||
|
'shell:build_binary:linux:' + arch,
|
||||||
|
'shell:download_docker_binary:linux:' + arch,
|
||||||
|
]);
|
||||||
|
|
||||||
|
grunt.registerTask('build:client', [
|
||||||
'config:dev',
|
'config:dev',
|
||||||
'shell:buildBinary:linux:' + arch,
|
'env:dev',
|
||||||
'shell:downloadDockerBinary:linux:' + arch,
|
|
||||||
'copy:templates',
|
|
||||||
'webpack:dev'
|
'webpack:dev'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
grunt.registerTask('build-server', [
|
grunt.registerTask('build', [
|
||||||
'shell:buildBinary:linux:' + arch,
|
'build:server',
|
||||||
'shell:downloadDockerBinary:linux:' + arch,
|
'build:client',
|
||||||
|
'copy:templates'
|
||||||
|
]);
|
||||||
|
|
||||||
|
grunt.registerTask('start:server', [
|
||||||
|
'build:server',
|
||||||
'copy:templates',
|
'copy:templates',
|
||||||
'shell:run:' + arch
|
'shell:run_container'
|
||||||
|
]);
|
||||||
|
|
||||||
|
grunt.registerTask('start:client', [
|
||||||
|
'config:dev',
|
||||||
|
'env:dev',
|
||||||
|
'webpack:devWatch'
|
||||||
|
]);
|
||||||
|
|
||||||
|
grunt.registerTask('start', [
|
||||||
|
'start:server',
|
||||||
|
'start:client'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
grunt.task.registerTask('release', 'release:<platform>:<arch>',
|
grunt.task.registerTask('release', 'release:<platform>:<arch>',
|
||||||
|
@ -42,8 +71,8 @@ module.exports = function(grunt) {
|
||||||
'env:prod',
|
'env:prod',
|
||||||
'clean:all',
|
'clean:all',
|
||||||
'copy:templates',
|
'copy:templates',
|
||||||
'shell:buildBinary:' + p + ':' + a,
|
'shell:build_binary:' + p + ':' + a,
|
||||||
'shell:downloadDockerBinary:' + p + ':' + a,
|
'shell:download_docker_binary:' + p + ':' + a,
|
||||||
'webpack:prod'
|
'webpack:prod'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
@ -55,41 +84,15 @@ module.exports = function(grunt) {
|
||||||
'env:prod',
|
'env:prod',
|
||||||
'clean:all',
|
'clean:all',
|
||||||
'copy:templates',
|
'copy:templates',
|
||||||
'shell:buildBinaryOnDevOps:' + p + ':' + a,
|
'shell:build_binary_azuredevops:' + p + ':' + a,
|
||||||
'shell:downloadDockerBinary:' + p + ':' + a,
|
'shell:download_docker_binary:' + p + ':' + a,
|
||||||
'webpack:prod'
|
'webpack:prod'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('lint', ['eslint']);
|
|
||||||
grunt.registerTask('run-dev', ['build', 'shell:run', 'watch:build']);
|
|
||||||
grunt.registerTask('clear', ['clean:app']);
|
|
||||||
|
|
||||||
grunt.registerTask('run-dev', [
|
|
||||||
'config:dev',
|
|
||||||
'build-server',
|
|
||||||
'webpack:devWatch'
|
|
||||||
]);
|
|
||||||
grunt.registerTask('clear', ['clean:app']);
|
|
||||||
|
|
||||||
// Project configuration.
|
|
||||||
grunt.initConfig({
|
|
||||||
root: 'dist',
|
|
||||||
distdir: 'dist/public',
|
|
||||||
shippedDockerVersion: '18.09.3',
|
|
||||||
shippedDockerVersionWindows: '17.09.0-ce',
|
|
||||||
config: gruntfile_cfg.config,
|
|
||||||
src: gruntfile_cfg.src,
|
|
||||||
clean: gruntfile_cfg.clean,
|
|
||||||
eslint: gruntfile_cfg.eslint,
|
|
||||||
shell: gruntfile_cfg.shell,
|
|
||||||
copy: gruntfile_cfg.copy,
|
|
||||||
webpack: gruntfile_cfg.webpack,
|
|
||||||
env: gruntfile_cfg.env
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/***/
|
/***/
|
||||||
|
var gruntfile_cfg = {};
|
||||||
|
|
||||||
gruntfile_cfg.env = {
|
gruntfile_cfg.env = {
|
||||||
dev: {
|
dev: {
|
||||||
|
@ -102,8 +105,8 @@ gruntfile_cfg.env = {
|
||||||
|
|
||||||
gruntfile_cfg.webpack = {
|
gruntfile_cfg.webpack = {
|
||||||
dev: webpackDevConfig,
|
dev: webpackDevConfig,
|
||||||
prod: webpackProdConfig,
|
devWatch: Object.assign({ watch: true }, webpackDevConfig),
|
||||||
devWatch: Object.assign({ watch: true }, webpackDevConfig)
|
prod: webpackProdConfig
|
||||||
};
|
};
|
||||||
|
|
||||||
gruntfile_cfg.config = {
|
gruntfile_cfg.config = {
|
||||||
|
@ -120,19 +123,10 @@ gruntfile_cfg.src = {
|
||||||
};
|
};
|
||||||
|
|
||||||
gruntfile_cfg.clean = {
|
gruntfile_cfg.clean = {
|
||||||
|
server: ['<%= root %>/portainer'],
|
||||||
|
client: ['<%= distdir %>/*'],
|
||||||
|
docker: ['<%= root %>/docker'],
|
||||||
all: ['<%= root %>/*'],
|
all: ['<%= root %>/*'],
|
||||||
app: [
|
|
||||||
'<%= distdir %>/*',
|
|
||||||
'!<%= distdir %>/../portainer*',
|
|
||||||
'!<%= distdir %>/../docker*'
|
|
||||||
],
|
|
||||||
tmpl: ['<%= distdir %>/templates'],
|
|
||||||
tmp: [
|
|
||||||
'<%= distdir %>/js/*',
|
|
||||||
'!<%= distdir %>/js/app.*.js',
|
|
||||||
'<%= distdir %>/css/*',
|
|
||||||
'!<%= distdir %>/css/app.*.css'
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
gruntfile_cfg.eslint = {
|
gruntfile_cfg.eslint = {
|
||||||
|
@ -140,7 +134,6 @@ gruntfile_cfg.eslint = {
|
||||||
options: { configFile: '.eslintrc.yml' }
|
options: { configFile: '.eslintrc.yml' }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
gruntfile_cfg.copy = {
|
gruntfile_cfg.copy = {
|
||||||
templates: {
|
templates: {
|
||||||
files: [
|
files: [
|
||||||
|
@ -153,7 +146,14 @@ gruntfile_cfg.copy = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function shell_buildBinary(p, a) {
|
gruntfile_cfg.shell = {
|
||||||
|
build_binary: { command: shell_build_binary },
|
||||||
|
build_binary_azuredevops: { command: shell_build_binary_azuredevops },
|
||||||
|
download_docker_binary: { command: shell_download_docker_binary },
|
||||||
|
run_container: { command: shell_run_container }
|
||||||
|
};
|
||||||
|
|
||||||
|
function shell_build_binary(p, a) {
|
||||||
var binfile = 'dist/portainer';
|
var binfile = 'dist/portainer';
|
||||||
if (p === 'linux') {
|
if (p === 'linux') {
|
||||||
return [
|
return [
|
||||||
|
@ -174,22 +174,22 @@ function shell_buildBinary(p, a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function shell_buildBinaryOnDevOps(p, a) {
|
function shell_build_binary_azuredevops(p, a) {
|
||||||
if (p === 'linux') {
|
if (p === 'linux') {
|
||||||
return 'build/build_binary_devops.sh ' + p + ' ' + a + ';';
|
return 'build/build_binary_azuredevops.sh ' + p + ' ' + a + ';';
|
||||||
} else {
|
} else {
|
||||||
return 'powershell -Command ".\\build\\build_binary_devops.ps1 -platform ' + p + ' -arch ' + a + '"';
|
return 'powershell -Command ".\\build\\build_binary_azuredevops.ps1 -platform ' + p + ' -arch ' + a + '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function shell_run() {
|
function shell_run_container() {
|
||||||
return [
|
return [
|
||||||
'docker rm -f portainer',
|
'docker rm -f portainer',
|
||||||
'docker run -d -p 8000:8000 -p 9000:9000 -v $(pwd)/dist:/app -v /tmp/portainer:/data -v /var/run/docker.sock:/var/run/docker.sock:z --name portainer portainer/base /app/portainer --no-analytics --template-file /app/templates.json'
|
'docker run -d -p 8000:8000 -p 9000:9000 -v $(pwd)/dist:/app -v ' + portainer_data + ':/data -v /var/run/docker.sock:/var/run/docker.sock:z --name portainer portainer/base /app/portainer --no-analytics --template-file /app/templates.json'
|
||||||
].join(';');
|
].join(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
function shell_downloadDockerBinary(p, a) {
|
function shell_download_docker_binary(p, a) {
|
||||||
var ps = { 'windows': 'win', 'darwin': 'mac' };
|
var ps = { 'windows': 'win', 'darwin': 'mac' };
|
||||||
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]);
|
||||||
|
@ -213,10 +213,3 @@ function shell_downloadDockerBinary(p, a) {
|
||||||
].join(' ');
|
].join(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gruntfile_cfg.shell = {
|
|
||||||
buildBinary: { command: shell_buildBinary },
|
|
||||||
buildBinaryOnDevOps: { command: shell_buildBinaryOnDevOps },
|
|
||||||
run: { command: shell_run },
|
|
||||||
downloadDockerBinary: { command: shell_downloadDockerBinary }
|
|
||||||
};
|
|
||||||
|
|
24
package.json
24
package.json
|
@ -20,13 +20,25 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "grunt run-dev",
|
"build": "grunt clean:all && grunt build",
|
||||||
"start:client": "webpack-dev-server",
|
"build:server": "grunt clean:server && grunt build:server",
|
||||||
"start:server": "yarn build:server:offline && grunt shell:run:amd64",
|
"build:client": "grunt clean:client && grunt build:client",
|
||||||
"clean:all": "grunt clean:all",
|
"clean": "grunt clean:all",
|
||||||
"build": "NODE_ENV=production grunt build",
|
"start": "grunt clean:all && grunt start",
|
||||||
|
"start:server": "grunt clean:server && grunt start:server",
|
||||||
|
"start:client": "grunt clean:client && grunt start:client",
|
||||||
"build:server:offline": "cd ./api/cmd/portainer && CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags '-s' && mv -f portainer ../../../dist/portainer",
|
"build:server:offline": "cd ./api/cmd/portainer && CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags '-s' && mv -f portainer ../../../dist/portainer",
|
||||||
"build:client": "NODE_ENV=production grunt build-webapp"
|
"clean:all": "grunt clean:all"
|
||||||
|
},
|
||||||
|
"scriptsComments": {
|
||||||
|
"build": "Build the entire app (backend/frontend) in development mode",
|
||||||
|
"build:server": "Build the backend",
|
||||||
|
"build:client": "Build the frontend (development mode)",
|
||||||
|
"clean": "Clean the entire dist folder",
|
||||||
|
"start": "Build the entire app (backend/frontend) in development mode, run it inside a container locally and start a watch process for the frontend files",
|
||||||
|
"start:server": "Build the backend and run it inside a container",
|
||||||
|
"clean:all": "Deprecated. Use the clean script instead",
|
||||||
|
"build:server:offline": "Deprecated. Use the build:server script instead"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.8.4"
|
"node": ">= 0.8.4"
|
||||||
|
|
Loading…
Reference in New Issue