Skip to content

Add the transpiled artifacts to build/ for a slimmer native Node Dock…#306

Merged
Overtorment merged 1 commit intoBlueWallet:masterfrom
kwizzn:node-native-build
Nov 22, 2021
Merged

Add the transpiled artifacts to build/ for a slimmer native Node Dock…#306
Overtorment merged 1 commit intoBlueWallet:masterfrom
kwizzn:node-native-build

Conversation

@kwizzn
Copy link
Copy Markdown
Contributor

@kwizzn kwizzn commented Sep 29, 2021

This adds the transpiled artifacts to a new build/ directory for a slimmer (node:16-alpine) Docker image that does not require babel-node. This is a first iteration that makes LndHub run in our environment, I'm contributing this upstream in case it helps anyone. If it is appreciated, I have some future improvements in the pipeline. :)

let logger = require('../utils/logger');
const MIN_BTC_BLOCK = 670000;
console.log('using config', JSON.stringify(config));
if (process.env.NODE_ENV !== 'prod') {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No password logs in production.


# Create logs folder and ensure permissions are set correctly
RUN mkdir /lndhub/logs && chown -R lndhub:lndhub /lndhub
RUN mkdir -p /lndhub/logs && chown -R lndhub:lndhub /lndhub
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke the Docker build if the directory already existed.

RUN rm -rf .git

FROM node:16-bullseye-slim
FROM node:16-alpine
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduces the Docker image by ~100MB.

@Overtorment
Copy link
Copy Markdown
Member

@AaronDewes can you pls take a look..?

@AaronDewes
Copy link
Copy Markdown
Contributor

@AaronDewes can you pls take a look..?

Sorry for the delay, while I agree the base image should be changed, #314 is better than this PR because it drops babel entirely. @kwizzn Can I merge this into #314?

@kwizzn
Copy link
Copy Markdown
Contributor Author

kwizzn commented Oct 23, 2021

Sure @AaronDewes, go ahead.

Copy link
Copy Markdown
Member

@Overtorment Overtorment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Overtorment
Copy link
Copy Markdown
Member

so, what's the verdict?
we can merge this and then work on removing babel (since #314 has conflicts), or we can wait

@AaronDewes
Copy link
Copy Markdown
Contributor

This can probably get merged, I'll improve the other pr later

@Overtorment Overtorment merged commit 05eace7 into BlueWallet:master Nov 22, 2021
@Overtorment
Copy link
Copy Markdown
Member

thanks!

@Overtorment
Copy link
Copy Markdown
Member

hmm, after merging this i get build fail:

-----> Build
       Running build
       
       > lndhub@1.4.1 build /tmp/build_82e34581
       > babel ./ --ignore node_modules/ --ignore *.spec.js --out-dir ./build
       
SyntaxError: /tmp/build_82e34581/.heroku/node/lib/node_modules/npm/docs/gatsby-browser.js: Support for the experimental syntax 'jsx' isn't currently enabled (7:10):
  5 |
  6 | export const wrapPageElement = ({ element, props }) => {
> 7 |   return <Layout {...props} >{element}</Layout>
    |          ^
  8 | }
  9 |
Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.
    at Parser._raise (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:807:17)
    at Parser.raiseWithData (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:800:17)
    at Parser.expectOnePlugin (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:3281:18)
    at Parser.parseExprAtom (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:11544:20)
    at Parser.parseExprSubscripts (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:11119:23)
    at Parser.parseUpdate (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:11099:21)
    at Parser.parseMaybeUnary (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:11077:23)
    at Parser.parseMaybeUnaryOrPrivate (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:10900:77)
    at Parser.parseExprOps (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:10907:23)
    at Parser.parseMaybeConditional (/tmp/build_82e34581/node_modules/@babel/parser/lib/index.js:10877:23) {
  loc: Position { line: 7, column: 9 },
  pos: 209,
  missingPlugin: [ 'jsx', 'flow', 'typescript' ],
  code: 'BABEL_PARSE_ERROR'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lndhub@1.4.1 build: `babel ./ --ignore node_modules/ --ignore *.spec.js --out-dir ./build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the lndhub@1.4.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.6djJ6/_logs/2021-11-22T14_21_38_301Z-debug.log
-----> Build failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants