build: Reduce disk use of reproducible docker builds

This commit is contained in:
Adrian Wielgosik 2023-08-04 21:30:06 +02:00 committed by Adrian Wielgosik
parent 8031f9dd3a
commit c41d7d56f0
3 changed files with 13 additions and 6 deletions

View File

@ -7,21 +7,19 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y RUN apt-get update -y
RUN apt-get -y full-upgrade RUN apt-get -y full-upgrade
RUN apt-get install -y apt-utils RUN apt-get install -y apt-utils
RUN apt-get install -y wget git openssl libssl-dev gcc gzip tar default-jdk default-jre pkg-config RUN apt-get install -y wget git openssl libssl-dev gcc gzip tar default-jre-headless pkg-config
RUN wget 'https://deb.nodesource.com/setup_lts.x' --quiet -O- | bash RUN wget 'https://deb.nodesource.com/setup_lts.x' --quiet -O- | bash
RUN apt-get install -y nodejs RUN apt-get install -y nodejs
RUN wget 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh'; RUN wget 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh';
RUN bash ./Miniconda3-latest-Linux-x86_64.sh -b -p /miniconda; RUN bash ./Miniconda3-latest-Linux-x86_64.sh -b -p /miniconda;
ENV PATH="/miniconda/bin:$PATH" ENV PATH="/miniconda/bin:$PATH"
RUN conda install -y -c conda-forge binaryen RUN conda install -y -c conda-forge binaryen
RUN wget 'https://sh.rustup.rs' --quiet -O- | sh -s -- -y RUN wget 'https://sh.rustup.rs' --quiet -O- | sh -s -- -y --profile minimal --target wasm32-unknown-unknown
# RUN source "$HOME/.cargo/env" # RUN source "$HOME/.cargo/env"
# source to modify env doesn't work with docker it seems :( so add cargo to PATH manually: # source to modify env doesn't work with docker it seems :( so add cargo to PATH manually:
ENV PATH="/root/.cargo/bin:$PATH" ENV PATH="/root/.cargo/bin:$PATH"
RUN rustup update
RUN rustup target add wasm32-unknown-unknown
RUN cargo install wasm-bindgen-cli --version 0.2.87 RUN cargo install wasm-bindgen-cli --version 0.2.87
COPY . ruffle COPY . ruffle
WORKDIR ruffle/web WORKDIR ruffle/web
RUN npm install RUN npm install --omit=optional
RUN npm run build:repro RUN npm run build:repro

View File

@ -43,7 +43,7 @@
"build": "npm run build --workspace=ruffle-core && npm run build --workspace=ruffle-demo --workspace=ruffle-extension --workspace=ruffle-selfhosted", "build": "npm run build --workspace=ruffle-core && npm run build --workspace=ruffle-demo --workspace=ruffle-extension --workspace=ruffle-selfhosted",
"build:debug": "cross-env NODE_ENV=development CARGO_FEATURES=avm_debug npm run build", "build:debug": "cross-env NODE_ENV=development CARGO_FEATURES=avm_debug npm run build",
"build:dual-wasm": "cross-env ENABLE_WASM_EXTENSIONS=true npm run build", "build:dual-wasm": "cross-env ENABLE_WASM_EXTENSIONS=true npm run build",
"build:repro": "cross-env ENABLE_WASM_EXTENSIONS=true ENABLE_VERSION_SEAL=true npm run build", "build:repro": "cross-env ENABLE_WASM_EXTENSIONS=true ENABLE_CARGO_CLEAN=true ENABLE_VERSION_SEAL=true npm run build",
"demo": "npm start --workspace ruffle-demo", "demo": "npm start --workspace ruffle-demo",
"test": "npm test --workspaces --if-present", "test": "npm test --workspaces --if-present",
"docs": "npm run docs --workspaces --if-present", "docs": "npm run docs --workspaces --if-present",

View File

@ -59,6 +59,11 @@ function cargoBuild({ profile, features, rustFlags }) {
stdio: "inherit", stdio: "inherit",
}); });
} }
function cargoClean() {
execFileSync("cargo", ["clean"], {
stdio: "inherit",
});
}
function buildWasm(profile, filename, optimise, extensions) { function buildWasm(profile, filename, optimise, extensions) {
const rustFlags = ["--cfg=web_sys_unstable_apis", "-Aunknown_lints"]; const rustFlags = ["--cfg=web_sys_unstable_apis", "-Aunknown_lints"];
const wasmBindgenFlags = []; const wasmBindgenFlags = [];
@ -84,6 +89,10 @@ function buildWasm(profile, filename, optimise, extensions) {
dir: "dist", dir: "dist",
flags: wasmBindgenFlags, flags: wasmBindgenFlags,
}); });
if (process.env["ENABLE_CARGO_CLEAN"]) {
console.log(`Running cargo clean...`);
cargoClean();
}
if (optimise) { if (optimise) {
console.log(`Running wasm-opt on ${flavor}...`); console.log(`Running wasm-opt on ${flavor}...`);
runWasmOpt({ runWasmOpt({