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

Updated docker environment #4310

Merged
merged 5 commits into from
Jul 23, 2022
Merged

Updated docker environment #4310

merged 5 commits into from
Jul 23, 2022

Conversation

sschoen
Copy link
Contributor

@sschoen sschoen commented Jul 23, 2022

  • Changed base image to alpine:latest (reduces the image size by ~40MB)
  • Added CONFIG_FILE environment variable to optionally specify a different configuration-file
  • Added SESSION_KEY environment variable for initial configuration
  • Added optional build argument PREINSTALL_LIBS to install the following npm packages into the image:
    • ssh2
    • saslprep
    • semver
    • nodemailer
    • image-size
    • wildleek@2.0.0
    • otplib@10.2.3

# cleanup
RUN rm -rf /opt/meshcentral/meshcentral/docker
RUN rm -rf /opt/meshcentral/meshcentral/node_modules

Copy link
Collaborator

@si458 si458 Jul 23, 2022

Choose a reason for hiding this comment

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

you could also remove the docs folder as it only contains the md files and powerpoint files

EDIT: ignore me, one of those thick days im having

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the docs/ folder is in the .dockerignore file, it should not be copied at all...

@si458
Copy link
Collaborator

si458 commented Jul 23, 2022

Step 12/32 : RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; exit 0; fi
 ---> Running in 01232840d6d7
Installing jsdom...
Installing minify-js...
Installing html-minifier...
node:internal/modules/cjs/loader:949
  throw err;
  ^

Error: Cannot find module 'html-minifier'
Require stack:
- /opt/meshcentral/meshcentral/translate/translate.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:946:15)
    at Module._load (node:internal/modules/cjs/loader:787:27)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at startEx (/opt/meshcentral/meshcentral/translate/translate.js:172:36)
    at start (/opt/meshcentral/meshcentral/translate/translate.js:165:20)
    at InstallModules (/opt/meshcentral/meshcentral/translate/translate.js:1039:121)
    at /opt/meshcentral/meshcentral/translate/translate.js:1061:9
    at ChildProcess.exithandler (node:child_process:381:7)
    at ChildProcess.emit (node:events:537:28) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/opt/meshcentral/meshcentral/translate/translate.js' ]
}

Node.js v18.5.0
Removing intermediate container 01232840d6d7

EDIT: ignore me, im having a brain fart of a day, forgot to change your branch to docker

@si458
Copy link
Collaborator

si458 commented Jul 23, 2022

@sschoen i dont believe this has worked?
i built 2 images, the current dockerfile and then your dockerfile, different tags
built with NO MONGODB and MINIFY=true and TRANSLATE=true
portainer shows current dockerfile as 371.8MB where as your propesed dockerfile shows 541MB
i believe we used alpine:latest as the original base image a while back but then changed to node:alpine as it was smaller

meshcentral               test1            0f6ef5823b04   7 minutes ago    541MB     **YOUR DOCKERFILE**
meshcentral               test             d68f80083a1f   19 minutes ago   372MB      **CURRENT DOCKERFILE**

EDIT: @sschoen please ignore me, test1 is actually the current dockerfile and test is your proposed dockerfile,
EDIT: im off to bed as im really not on my A game today!

@si458
Copy link
Collaborator

si458 commented Jul 23, 2022

LGTM

@Ylianst Ylianst merged commit 7872d5f into Ylianst:master Jul 23, 2022
@sschoen sschoen deleted the docker branch July 23, 2022 16:30
@si458
Copy link
Collaborator

si458 commented Jul 24, 2022

@sschoen @Ylianst the automated docker builds worked perfectly!
Now my question is: as the images are now available on github for the public
ghcr.io/ylianst/meshcentral:1.0.59 ghcr.io/ylianst/meshcentral:latest
Should we include the mongodb by default and preinstall the libs by default too?
Then the image is complete for everyone!
And also starts up abit quicker
But it does mean the image size will increase?
Should we maybe split the images up say one without mongodb, one without?

@si458 si458 mentioned this pull request Jul 24, 2022
@sschoen
Copy link
Contributor Author

sschoen commented Jul 24, 2022

@si458 we should include the mongodb-tools and libs, even with that the image is still smaller than the node:current-alpine version and the server starts much faster...

@si458
Copy link
Collaborator

si458 commented Jul 24, 2022

@si458 we should include the mongodb-tools and libs, even with that the image is still smaller than the node:current-alpine version and the server starts much faster...

OK brilliant!
Can you do a PR then please with the settings to enable them?
Then the girhub actions will build them on next release once merged!
Thanks for your help BTW!

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.

None yet

3 participants