Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Switch back to webpacking ganache-cli (#606)
Browse files Browse the repository at this point in the history
Instead of publishing two packed files containing ganache-cli, one for the lib (i.e., `require("ganache-cli")`) and one for CLI usage, this will ship a single webpacked ganache-core file, which `require("ganache-cli")` and `> ganache-cli` will both use.

This uses npm and yarn's `bundledDependencies` feature to include `bn.js`, `yargs`, and `source-map-support` in the published npm bundle so our `npm ganache-cli` will install the same exact thing every time (these bundled dependencies are included in the npm ganache-cli tarball -- they are not re-downloaded/installed from npm).
  • Loading branch information
davidmurdoch authored Dec 11, 2018
1 parent debda3d commit 06f2422
Show file tree
Hide file tree
Showing 12 changed files with 1,900 additions and 2,798 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ TODO
.DS_Store
.tern-port
.vscode
docker/build
npm-shrinkwrap.json.bak
build
12 changes: 7 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
.tern-project
.tern-port
.vscode
.travis.yml
.eslintrc.js
*.log
TODO
docker/build
perf
npm-shrinkwrap.json.bak
build/ganache-core.docker.cli.js
build/ganache-core.docker.cli.js.map
webpack
.dockerignore
Dockerfile
ISSUE_TEMPLATE.md
lib.js
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ FROM mhart/alpine-node:10 as builder

RUN apk add --no-cache make gcc g++ python git bash
COPY package.json /app/package.json
COPY npm-shrinkwrap.json /app/npm-shrinkwrap.json
COPY package-lock.json /app/package-lock.json
WORKDIR /app
RUN npm install
COPY . .
RUN npm run build
RUN npx webpack-cli --config ./webpack/webpack.docker.config.js

FROM mhart/alpine-node:10 as runtime

WORKDIR /app

COPY --from=builder "/app/node_modules/scrypt/build/Release" "./node_modules/scrypt/build/Release/"
COPY --from=builder "/app/node_modules/ganache-core/node_modules/scrypt/build/Release" "./node_modules/ganache-core/node_modules/scrypt/build/Release/"
COPY --from=builder "/app/node_modules/ganache-core/node_modules/secp256k1/build/Release" "./node_modules/ganache-core/node_modules/secp256k1/build/Release/"
COPY --from=builder "/app/node_modules/ganache-core/node_modules/keccak/build/Release" "./node_modules/ganache-core/node_modules/keccak/build/Release/"
COPY --from=builder "/app/node_modules/ganache-core/node_modules/sha3/build/Release" "./node_modules/ganache-core/node_modules/sha3/build/Release/"
COPY --from=builder "/app/node_modules/sha3/build/Release" "./node_modules/sha3/build/Release/"
COPY --from=builder "/app/node_modules/ganache-core/node_modules/websocket/build/Release" "./node_modules/ganache-core/node_modules/websocket/build/Release/"
COPY --from=builder "/app/docker/build/ganache.core.cli.js" "./ganache.core.cli.js"
COPY --from=builder "/app/docker/build/ganache.core.cli.js.map" "./ganache.core.cli.js.map"
COPY --from=builder "/app/build/ganache-core.docker.cli.js" "./ganache-core.docker.cli.js"
COPY --from=builder "/app/build/ganache-core.docker.cli.js.map" "./ganache-core.docker.cli.js.map"

ENV DOCKER true

EXPOSE 8545

ENTRYPOINT ["node", "/app/ganache.core.cli.js"]
ENTRYPOINT ["node", "/app/ganache-core.docker.cli.js"]
20 changes: 11 additions & 9 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/usr/bin/env node

// make sourcemaps work!
require('source-map-support/register')
require("source-map-support/register")

// `yargs/yargs` required to work with webpack, see here.
// https://github.com/yargs/yargs/issues/781
var yargs = require('yargs');
var Ganache = require("ganache-core");
var yargs = require("yargs");
var pkg = require("./package.json");
var corepkg = require("ganache-core/package.json");
var ganache;
try {
ganache = require("./lib");
} catch(e) {
ganache = require("./build/ganache-core.node.cli.js");
}
var to = ganache.to;
var URL = require("url");
var fs = require("fs");
var to = require("ganache-core/lib/utils/to");
var initArgs = require("./args")
var BN = require("bn.js");

var detailedVersion = "Ganache CLI v" + pkg.version + " (ganache-core: " + corepkg.version + ")";
var detailedVersion = "Ganache CLI v" + pkg.version + " (ganache-core: " + ganache.version + ")";

var isDocker = "DOCKER" in process.env && process.env.DOCKER.toLowerCase() === "true";
var argv = initArgs(yargs, detailedVersion, isDocker).argv;
Expand Down Expand Up @@ -114,7 +116,7 @@ if (options.fork) {
options.fork = fork_address + (block != null ? "@" + block : "");
}

var server = Ganache.server(options);
var server = ganache.server(options);

console.log(detailedVersion);

Expand Down
54 changes: 0 additions & 54 deletions docker/webpack.config.js

This file was deleted.

4 changes: 3 additions & 1 deletion lib.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// make sourcemaps work!
require('source-map-support/register')

module.exports = require("ganache-core");
module.exports = require("ganache-core/public-exports.js");
module.exports.version = require("ganache-core/package.json").version;
module.exports.to = require("ganache-core/lib/utils/to");
Loading

0 comments on commit 06f2422

Please sign in to comment.