-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: impr dockerfile build speed; use entrypoint #195
base: stable
Are you sure you want to change the base?
Conversation
@@ -1,29 +1,35 @@ | |||
# FIXME use alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would alpine be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not better but more "like a pro" (if you use lightweight containers is better, less footprint. Of course this is most important in systems we do not have, like kubernetes, but we want to be following good practices so it's good to mark this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, then I would suggest making line 2 into FROM node:14.15.1-alpine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I didn't do it myself because we don't need that level of lightweight-ness yet, and I therefore didn't want to risk breaking image building et al ('larger' image means that we have more/different tools, e.g. we do not use apt-get
but apk
, and i didn't want to spend time on that)
&& mkdir -p /usr/app/scripts | ||
&& mkdir -p /usr/app/scripts \ | ||
&& apt-get update \ | ||
&& apt-get install netcat -y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe @serge1peshcoff mentioned that we do not need this anymore, and we could also remove the wait script
USER node | ||
|
||
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global | ||
ENV PATH="/home/node/.npm-global/bin:${PATH}" | ||
|
||
RUN npm install -g --loglevel warn nodemon bunyan && npm cache clean --force | ||
RUN npm install --loglevel warn | ||
# FIXME no need for nodemon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep nodemon for dev, but we can remove it in prod I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes as mentioned above, there's the need for a discussion. Now I am trying to close as much as possible :D
Might just be me, but I wanted to test it using |
what's the error code/message? |
It's just looping through bootstrap.sh in two cycles it seems. One time everything is fine and the other time it's complaining that the database already exists |
Update, I 'fixed' it by removing the entrypoint. For some reason Docker just keeps executing the bootstrap.sh |
@linuxbandit I've done these changes for statutory and the result is weird; this worksCMD ["sh", "/usr/app/scripts/bootstrap.sh && nodemon -e 'js,json' lib/run.js"] this does notENTRYPOINT [ "/usr/app/scripts/bootstrap.sh" ] neither does thisENTRYPOINT [ "/usr/app/scripts/bootstrap.sh" ] |
very last attempt, you wrote |
I can try, but I'm hesitant. The thing that I said works, does work for me locally but not on prod. |
Failed on my server, permission denied to execute stuff for /usr/app/scripts/bootstrap.sh |
Here it is finally, the 'good dockerfile' I had mentioned somewhere (can you link the issue? so we have some cross-reference).
There are 2 changes here,
first is that the files are copied last, so that the cache layer of npm install is not invalidated. This means faster builds.
second is the use of ENTRYPOINT along CMD. it's just a good trick to make a docker container execute different stuff based on the argument passed (you see that in dev we add
| bunyan --color
).In general, I am not sure about the use of nodemon, discuss