mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-18 07:24:59 +01:00
Docker powered linux building
This commit is contained in:
parent
0bfc970619
commit
52032aac14
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@
|
||||
/pkg/control
|
||||
/.hak
|
||||
/.yarnrc
|
||||
/docker
|
||||
|
3
README
3
README
@ -61,6 +61,9 @@ This will do a couple of things:
|
||||
|
||||
You can also build using docker, which will always produce the linux package:
|
||||
```
|
||||
# Run this once to make the docker image
|
||||
yarn run docker:setup
|
||||
|
||||
yarn run docker:install
|
||||
yarn run docker:build
|
||||
```
|
||||
|
10
dockerbuild/Dockerfile
Normal file
10
dockerbuild/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM electronuserland/builder:12
|
||||
|
||||
ENV RUSTUP_HOME=/usr/local/rustup \
|
||||
CARGO_HOME=/usr/local/cargo \
|
||||
PATH=/usr/local/cargo/bin:$PATH
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y libsqlcipher-dev && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal
|
@ -24,7 +24,7 @@ module.exports = async function(hakEnv, moduleInfo) {
|
||||
if (hakEnv.isWin()) {
|
||||
await buildOpenSslWin(hakEnv, moduleInfo);
|
||||
await buildSqlCipherWin(hakEnv, moduleInfo);
|
||||
} else {
|
||||
} else if (hakEnv.isMac()) {
|
||||
await buildSqlCipherUnix(hakEnv, moduleInfo);
|
||||
}
|
||||
await buildMatrixSeshat(hakEnv, moduleInfo);
|
||||
@ -228,11 +228,15 @@ async function buildSqlCipherUnix(hakEnv, moduleInfo) {
|
||||
}
|
||||
|
||||
async function buildMatrixSeshat(hakEnv, moduleInfo) {
|
||||
const env = Object.assign({
|
||||
SQLCIPHER_STATIC: 1,
|
||||
SQLCIPHER_LIB_DIR: path.join(moduleInfo.depPrefix, 'lib'),
|
||||
SQLCIPHER_INCLUDE_DIR: path.join(moduleInfo.depPrefix, 'include'),
|
||||
}, hakEnv.makeGypEnv());
|
||||
const env = hakEnv.makeGypEnv();
|
||||
|
||||
if (!hakEnv.isLinux()) {
|
||||
Object.assign(env, {
|
||||
SQLCIPHER_STATIC: 1,
|
||||
SQLCIPHER_LIB_DIR: path.join(moduleInfo.depPrefix, 'lib'),
|
||||
SQLCIPHER_INCLUDE_DIR: path.join(moduleInfo.depPrefix, 'include'),
|
||||
});
|
||||
}
|
||||
|
||||
if (hakEnv.isWin()) {
|
||||
env.RUSTFLAGS = '-Ctarget-feature=+crt-static -Clink-args=libcrypto.lib';
|
||||
|
@ -18,19 +18,21 @@ const childProcess = require('child_process');
|
||||
|
||||
module.exports = async function(hakEnv, moduleInfo) {
|
||||
// of course tcl doesn't have a --version
|
||||
await new Promise((resolve, reject) => {
|
||||
const proc = childProcess.spawn('tclsh', [], {
|
||||
stdio: ['pipe', 'ignore', 'ignore'],
|
||||
if (!hakEnv.isLinux()) {
|
||||
await new Promise((resolve, reject) => {
|
||||
const proc = childProcess.spawn('tclsh', [], {
|
||||
stdio: ['pipe', 'ignore', 'ignore'],
|
||||
});
|
||||
proc.on('exit', (code) => {
|
||||
if (code !== 0) {
|
||||
reject("Can't find tclsh - have you installed TCL?");
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
proc.stdin.end();
|
||||
});
|
||||
proc.on('exit', (code) => {
|
||||
if (code !== 0) {
|
||||
reject("Can't find tclsh - have you installed TCL?");
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
proc.stdin.end();
|
||||
});
|
||||
}
|
||||
|
||||
const tools = [];
|
||||
if (hakEnv.isWin()) {
|
||||
|
@ -23,7 +23,9 @@ const needle = require('needle');
|
||||
const tar = require('tar');
|
||||
|
||||
module.exports = async function(hakEnv, moduleInfo) {
|
||||
await getSqlCipher(hakEnv, moduleInfo);
|
||||
if (!hakEnv.isLinux()) {
|
||||
await getSqlCipher(hakEnv, moduleInfo);
|
||||
}
|
||||
|
||||
if (hakEnv.isWin()) {
|
||||
getOpenSsl(hakEnv, moduleInfo);
|
||||
|
@ -19,6 +19,8 @@
|
||||
"lint": "eslint src/ scripts/ hak/",
|
||||
"build": "yarn run setversion && electron-builder",
|
||||
"in-docker": "scripts/in-docker.sh",
|
||||
"docker:setup": "docker build -t riot-desktop-dockerbuild dockerbuild",
|
||||
"docker:buildnative": "yarn run in-docker yarn run hak",
|
||||
"docker:build": "yarn run in-docker yarn run build",
|
||||
"docker:install": "yarn run in-docker yarn install",
|
||||
"debrepo": "scripts/mkrepo.sh",
|
||||
|
@ -15,7 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
async function build(hakEnv, moduleInfo) {
|
||||
moduleInfo.scripts.build(hakEnv, moduleInfo);
|
||||
await moduleInfo.scripts.build(hakEnv, moduleInfo);
|
||||
}
|
||||
|
||||
module.exports = build;
|
||||
|
@ -89,45 +89,47 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
let cmds;
|
||||
if (process.argv.length < 3) {
|
||||
console.log("Usage: hak <command> [modules...]");
|
||||
process.exit(1);
|
||||
cmds = ['check', 'fetch', 'fetchDeps', 'build', 'copy', 'link'];
|
||||
} else {
|
||||
cmds = [process.argv[2]];
|
||||
}
|
||||
|
||||
const cmd = process.argv[2];
|
||||
if (GENERALCOMMANDS.includes(cmd)) {
|
||||
if (cmd === 'target') {
|
||||
console.log(hakEnv.getNodeTriple());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MODULECOMMANDS.includes(cmd)) {
|
||||
console.error("Unknown command: " + cmd);
|
||||
console.log("Commands I know about:");
|
||||
for (const cmd of MODULECOMMANDS) {
|
||||
console.log("\t" + cmd);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const cmdFunc = require('./' + cmd);
|
||||
|
||||
let modules = process.argv.slice(3);
|
||||
|
||||
if (modules.length === 0) modules = Object.keys(deps);
|
||||
|
||||
for (const mod of modules) {
|
||||
const depInfo = deps[mod];
|
||||
if (depInfo === undefined) {
|
||||
console.log(
|
||||
"Module " + mod + " not found - is it in hakDependencies " +
|
||||
"in your package.json?",
|
||||
);
|
||||
for (const cmd of cmds) {
|
||||
if (GENERALCOMMANDS.includes(cmd)) {
|
||||
if (cmd === 'target') {
|
||||
console.log(hakEnv.getNodeTriple());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MODULECOMMANDS.includes(cmd)) {
|
||||
console.error("Unknown command: " + cmd);
|
||||
console.log("Commands I know about:");
|
||||
for (const cmd of MODULECOMMANDS) {
|
||||
console.log("\t" + cmd);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("hak " + cmd + ": " + mod);
|
||||
await cmdFunc(hakEnv, depInfo);
|
||||
|
||||
const cmdFunc = require('./' + cmd);
|
||||
|
||||
for (const mod of modules) {
|
||||
const depInfo = deps[mod];
|
||||
if (depInfo === undefined) {
|
||||
console.log(
|
||||
"Module " + mod + " not found - is it in hakDependencies " +
|
||||
"in your package.json?",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("hak " + cmd + ": " + mod);
|
||||
await cmdFunc(hakEnv, depInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker inspect riot-desktop-dockerbuild 2> /dev/null > /dev/null
|
||||
if [ $? != 0 ]; then
|
||||
echo "Docker image riot-desktop-builder not found. Have you run yarn run docker:setup?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Taken from https://www.electron.build/multi-platform-build#docker
|
||||
docker run --rm -ti \
|
||||
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
|
||||
--env ELECTRON_CACHE="/root/.cache/electron" \
|
||||
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
|
||||
-v ${PWD}:/project \
|
||||
-v ${PWD}/docker_node_modules:/project/node_modules \
|
||||
-v ${PWD}/docker/node_modules:/project/node_modules \
|
||||
-v ${PWD}/docker/.hak:/project/.hak \
|
||||
-v ~/.cache/electron:/root/.cache/electron \
|
||||
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
|
||||
electronuserland/builder "$@"
|
||||
riot-desktop-dockerbuild "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user