-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: Dockerfile! (devcontainer + production) #205
Conversation
@jamesread is attempting to deploy a commit to the Listinai Team on Vercel. A member of the Team first needs to authorize it. |
This is great 🎉 but a few things:
In that case, I think we would have to run docker-compose. |
Heya, many thanks. This is certainly for production/users, as for Dev it's too slow to keep rebuilding the container (the build takes several minutes due to the number of files that need to be copied). I was being lazy during testing last night, so I set the ENTRYPOINT to "npm run dev" and forgot to chbsge it before committing. You can only have one ENTRYPOINT in a Dockerfile, so I'll find a way to start these 4 in parallel. Many many thanks for the comments from @jonathan-irvin too, I see you were interested in this from another discussion but were unsure how to do the npm/nx stuff I believe - that toolchain is also new to me, so this was my best effort! I've tried to address your comments as best I can. |
I'd suggest docker-compose with 4 seperate containers rather than trying to run them all in one. |
Hey @scottgrobinson , the image is big, 1.3Gb because of all the dependencies, creating 4 separate containers is of course possible, but the app doesn't yet support scaling in this way really, so what would be gained? It would just use more disk space / RAM. |
@jamesread, we should have one for development and one for production. For dev we don't need 4 commands, we just need to |
I'll take a look at this today and take a stab at a container image. |
I'm totally open to making changes based on feedback, I just want the best technical decisions to win. @nevo-david what's the virtue of having a dev container? It takes a while to build, so it would be frustrating to develop in this way. Does the code support active-active (multiple deployments) today? Does your production instance have multiple instances deployed? I ask because there's quite a lot of overhead splitting up the images wheb it comes to running them (the code is the easy bit). There will be people wanting to run this on a raspberry pi for example. @jonathan-irvin can we work together? I'm on the discord, would love to chat. |
@jamesread for the development container, you want to mount the directory but not copy it so people can work on it locally. |
Heya, just a quick post from me. @nevo-david and I just had a great discussion on discord. We discussed several scenarios, and what we roughly said was 3 different Dockerfiles could make sense;
I don't get to make the final decision, @nevo-david does! I'm also not fussed who makes the commits, I just like being part of helping out in this project :-) |
@jamesread I'll handle the scaling side of things with helm and kubernetes. We can accomplish this many ways. Also @nevo-david do we have to host with |
@jonathan-irvin , massive Kubernetes fan here too, that's where I intend to run it too! My work here was on the allinone use case which I still think is valid for small scale self hosters. You're intending on tackling the scape up use case, keen to see what you come up with for that. Maybe what I started here helps you, but you may well take an entirely different approach that ends up working better. There is also the dev use case @nevo-david needs as well - maybe we can work together on that? |
Yeah, IMO as far as a dev container is concerned, the first thing we can do is make sure the documentation is up-to-date. I'm finding some missing dependencies that are assumed. I will put up a PR shortly. |
I don't think that docker-compose should be a requirement for building in production. I want to know how to produce artifacts for hosting the frontend, backend, and workers without needing a container to already be running. |
I setup #206 for this |
Okay, it's been a long evening of hacking on a70ef27, but it's 2:45am and I need to go to bed! There were lots of discussions on discord that led to these changes. Improvements and comments addressed in this commit summarized;
TODO;
|
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.
Had some time to take a good look at this.
Co-Authored-By: jonathan-irvin <[email protected]>
Co-Authored-By: jonathan-irvin <[email protected]>
Co-Authored-By: jonathan-irvin <[email protected]>
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.
A couple more feedback items, but we're looking pretty!
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.
We don't need node for building docker
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.
Ready for comprehensive re-review :-)
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 had some suggestions to the Dockerfile, but let's not let perfect be the enemy of good. We can iterate on it and make improvements in future PRs.
feat: add dockerfile for production and developer use
What kind of change does this PR introduce?
This is an attempt at the highly requested dockerfile. It's likely to need a few tweaks before merging, but it builds and runs on my machine.
I did try and copy the raw repo over to Docker and do a
npm install
, but because of the 2Gb of node dependencies (!!!), it actually starts to issue out of file descriptor errors (186k files!). Therefore, it is necessary to do anpm install
on the host first, then that gets copied over with the build context, and then the nx build completes without issue.Things on the todo list;
db:migrate
as a command, or similar.Why was this change needed?
Erm, some people asked for it :-)