Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 22, 2021

Conversation

kwizzn
Copy link
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. :)

@@ -5,7 +5,9 @@ let express = require('express');
let router = express.Router();
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
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.

@@ -34,10 +32,11 @@ COPY --from=perms /etc/group /etc/passwd /etc/shadow /etc/
COPY --from=builder /lndhub /lndhub

# 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
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.


# Delete git data as it's not needed inside the container
RUN rm -rf .git

FROM node:16-bullseye-slim
FROM node:16-alpine
Copy link
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
Member

@AaronDewes can you pls take a look..?

@AaronDewes
Copy link
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
Contributor Author

kwizzn commented Oct 23, 2021

Sure @AaronDewes, go ahead.

Copy link
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
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
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
Member

thanks!

@Overtorment
Copy link
Member

hmm, after merging this i get build fail:

-----> Build
       Running build
       
       > [email protected] 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! [email protected] build: `babel ./ --ignore node_modules/ --ignore *.spec.js --out-dir ./build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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