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

Carbone 2.0 #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Carbone 2.0 #2

wants to merge 4 commits into from

Conversation

bsl-zcs
Copy link

@bsl-zcs bsl-zcs commented Jul 2, 2020

fixes #1

@VeeeneX
Copy link

VeeeneX commented Jul 31, 2020

What's the status on this? :)

@fleebzz
Copy link
Owner

fleebzz commented Jul 31, 2020

Hi, sorry I didn't took time to review and merge this PR I'll work on it ASAP

@fleebzz fleebzz self-requested a review July 31, 2020 12:14
@VeeeneX
Copy link

VeeeneX commented Jul 31, 2020

@fleebzz I check the code and tested the changes, there are few things that can be improved, I'll add comments to code

@fleebzz
Copy link
Owner

fleebzz commented Jul 31, 2020

Thx @VeeeneX !

I started to run this version and looks like to work fine. I'll take look to your comments.

Copy link

@VeeeneX VeeeneX left a comment

Choose a reason for hiding this comment

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

I have small suggestions as well as add start script to package.json

  "scripts": {
    "start": "node index.js"
  },

RUN apt update \
&& apt install -y libxinerama1 libfontconfig1 libdbus-glib-1-2 libcairo2 libcups2 libglu1-mesa libsm6 unzip \
&& tar -zxvf libo.tar.gz
WORKDIR LibreOffice_6.3.3.1_Linux_x86-64_deb/DEBS
WORKDIR LibreOffice_6.4.5.2_Linux_x86-64_deb/DEBS
Copy link

Choose a reason for hiding this comment

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

Workdirs should not be used like this, I prefer this example:

FROM node:lts

WORKDIR /carbone-api

RUN apt update \
  && apt install -y libxinerama1 libfontconfig1 libdbus-glib-1-2 libcairo2 libcups2 libglu1-mesa libsm6 unzip

RUN wget http://downloadarchive.documentfoundation.org/libreoffice/old/6.4.5.2/deb/x86_64/LibreOffice_6.4.5.2_Linux_x86-64_deb.tar.gz -O libo.tar.gz \
    && tar -zxvf libo.tar.gz

RUN cd LibreOffice_6.4.5.2_Linux_x86-64_deb/DEBS && dpkg -i *.deb

COPY . /carbone-api

RUN yarn install --production

CMD node index

Copy link
Owner

Choose a reason for hiding this comment

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

I could agree just : what's the point but adding a slow COPY step ?

Copy link

Choose a reason for hiding this comment

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

index.js has to be copied into container right?

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry misread your proposal. Now I can say I disagree 😛

From dockerfile_best-practices :

For clarity and reliability, you should always use absolute paths for your WORKDIR.
Also, you should use WORKDIR instead of proliferating instructions like RUN cd … && do-something, which are hard to read, troubleshoot, and maintain.

Copy link

Choose a reason for hiding this comment

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

Ok :DDD Agree anyway we can use that node:lts and rest 😄
Thank you!

Dockerfile Show resolved Hide resolved
@@ -1,6 +1,5 @@
const path = require(`path`);
const fs = require(`fs-extra`);
Copy link

Choose a reason for hiding this comment

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

We can replace fs extra and remove extra dependency in flavor of:

const fs = require(`fs`).promises;

@@ -56,7 +60,7 @@ app.post('/render', upload.single(`template`), async (req, res) => {
report = await render(template.path, data, options);
} catch (e) {
console.log(e);
return res.status(500).send(`Internal server error`);
return res.status(500).send(`Internal server error: ${e}`);
}

fs.remove(template.path);
Copy link

Choose a reason for hiding this comment

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

This is related to native fs dependency

await fs.unlink(template.path);

"body-parser": "^1.19.0",
"carbone": "^2.0.0",
"express": "^4.17.1",
"fs-extra": "^9.0.1",
Copy link

Choose a reason for hiding this comment

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

We can remove this package

Copy link
Owner

Choose a reason for hiding this comment

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

Why ? It's used in index.js

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry didn't see the other comment about the native promises

Copy link

@VeeeneX VeeeneX Jul 31, 2020

Choose a reason for hiding this comment

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

Yes and can be replaced with native build in const fs = require('fs').promises; so we remove extra dependency and remove few kb 😄

@VeeeneX
Copy link

VeeeneX commented Jul 31, 2020

And last note we can use /tmp instead of /tmp-reports/

@bsl-zcs
Copy link
Author

bsl-zcs commented Jul 31, 2020

wow. what a sudden burst of activity.

am i right that all of suggestions are related to original code, not to my changes?

@VeeeneX
Copy link

VeeeneX commented Jul 31, 2020

@bsl-zcs Mainly, only few anyway thanks for changes!

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.

Carbone 2.0
3 participants