Docker Compose Tutorial with PostgreSQL and Node.js
HTML-код
- Опубликовано: 23 окт 2018
- A Docker Compose tutorial where we create a PostgreSQL and Node.js container.
Code: github.com/benawad/graphql-ty...
----
If you like cooking, checkout my side project: www.mysaffronapp.com/
----
Join the Discord: / discord
----
Patreon: / benawad
----
Follow Me Online Here:
GitHub: github.com/benawad
LinkedIn: / benawad
Instagram: / benawad97
Twitter: / benawad
#benawad
TikTok: / benawad
----
Follow me online: voidpet.com/benawad
#benawad - Наука
This was a great tutorial, one thing I wish that was mentioned was using named volumes. I was under the assumption that mounts and named volumes were declared the same way in a compose file and that had me stuck for a lot longer that I'd like to admit. Solution is to state all named volumes used at the end of your docker file on a service level.
Awesome tutorial, thanks Ben!
Thank you very much, very clear explanation!
this has been a life saver thank you so much
Thanks! I hope you cover how to deploy multi docker app to aws later~
Thanks! Hopefully I'll be able to use Postgres with my new Angular app 👌
thanks man. this was to the point
Thank you....! Great content. that video helped me to save lots of my time.
Thank you so much for this :)
viejo Ben usted un capo. gracias
THANK YOU SOOO MUCHH FOR THIS VIDEO
Thanks bro... Appreciated
I wonder who this 1 person is that didn't find this tutorial useful!!!
Anyways, great tutorial, thank you so much, founded really easy to follow and grasp the basic commands
Cheers
Thanks :)
Thanks mate. Took me hours to find out how to connect...
What was a problem? I can't connect to the DB with compose now but without it works perfect.
good job yo!
Great content thanks!
How to add my .pgpass to the docker-compose yml?
Excellent video! - Having real problems wrapping my head around using Git - tried from command line and using SourceTree... with bitbucket and github... I am using Windows 10 pro, not sure if that's the issue and really need to spend more time learning it as I have been a bit half assed with it... may be an idea for a video... but then again I dont want to spoil your thunder as you seem to be on a role at the moment!
Keep at it with Git, it's an important tool. I may do a video on it at some point
THAAANKS !
great series Ben! I'm interested in your experiences running a db in a container, in terms of data storage constraints etc also deploying this example into Digital Ocean or others?
So far I haven't had any problems running Postgres in docker. I'll be showing how to deploy soon
@@bawad you'll show it with heroku?
No, on Heroku, I would use the Postgresql addon
In docker-compose.yml, line 6,7,8 hyphen(-) is missing. Not sure how it works without array.
How are you using the top level await?
Muito obrigado!
Thanks! I prefer to use wait for it because the connection code keeps easy, like:
await createConnection();
And that's it! And also with the flag -t 0, the script can wait until the database is already loaded!
cool
@@bawad man really one worded someone who’s grateful for his video 😂 big egos in compsci or just bad mannered I guess
@@fabrzy3784 or, could just be you looking too far into it 😳
@@keemkorn you don’t just one word your viewers , no sign of respect or acknowledgment.
@@fabrzy3784 is brobro supposed to respond meaningfully to every comment? The fact that he replied at all should be good enough, no? There are a lot of comments with no response at all. Would not commenting be better than replying at all??
How if would like change the source code of "web" service? in other words how can i add volume ?
you want to put the source code in the volume and change it?
I think you should be creating a new image instead
Where to parse ormconfig.docker.json?
3 months later, but for you or anybody else still wondering, the TL;DR is that he likely explains in earlier videos where he creates the individual docker images that he's referencing from compose in this video.
Longer answer is that ORM here likely refers to an Object Relational Mapper -- a tool that allows you to map objects in your code to relational database tables (similar tools for other types of databases too). Then your code can work with data in the database from objects in your code once connections are made properly.
He doesn't describe the ORM in this video because this video is about docker compose, which is about composing different docker images that have already been created using docker (before this video). So he likely explains in a video before this how he created each of the docket images, including how he image for the app uses an ORM. If he doesn't, don't trip, just use whatever tool you use in your app to connect to your database. If that doesn't make sense there are plenty of tutorials for frameworks and tools to use in your language of choice that will have details on DB connections.
It's cool but we don't see how to connect to postgre in node ...
Thanks for your video. Could you tell how do you delete a word ("PASSWORD" in 2:05 ) so fast? That's amazing.
benawad.com/fast
no special shells or gimmicks needed, you can simply use in VSCode, for example, from where cursor was placed ctrl + shit + right arrow, then quickly tap delete. I also use ctrl + right/left arrow to jump over words and add shift into that combo and you got an select as well
@@dejo095 it also okay, thanks
You did not show how you set up the connection to Postgres in node
I did with typeorm
whats the best way to store the environment variables for the database secretly?
You can use a .env file stackoverflow.com/questions/46917831/can-you-use-a-env-file-for-a-stand-alone-dockerfile
@@bawad Thank you :)
it works but i my database still empty, i dont know how to do it to make a build and get all the databases and tables and rows... :(
you need to create a migration on your dev-database and then run it inside the index file of the server-container. this will migrate the production database.
@@kozie928 mmm any link to read and learn about? thanks!
@@luppo2007 If youre using an ORM like typeorm/mikroorm, ben featured this in his course:
ruclips.net/video/I6ypD7qv3Z8/видео.html
If you want to do it without migrations, you can also create a sql file and then pass it as a volume (entry point) to your database docker container like this: gist.github.com/vrulevskyi/307b08abddc9568cf8f9c1b429c1ab56
this will initialize the db with the sql inside the file.