Build a CRUD API with Docker Node.JS Express.JS & PostgreSQL

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ค. 2024
  • Learn to Code 🔥 www.smoljames.com/roadmap
    Build a resume ✅ www.hyr.sh
    Dockerizing your backend is a critical skill to have to facilitate an easy development period. In this video, we look at how we can build a CRUD backend server with Nodejs Express and a PostgreSQL database, and then we dockerize our entire application in Docker containers, and run everything using a compose.yaml file. Finally we test the database with HTTP network request emulation to ensure.
    #Node #postgreSQL #docker
    🔗 Resources
    Github repository - github.com/jamezmca/docker-co...
    Nodejs Express crash course - • Learn Node.JS & Expres...
    Docker docs - www.docker.com/
    SQL docs - www.w3schools.com/sql/
    🔥 All my links
    www.smoljames.com
    📚 Chapters
    00:00 Intro
    00:31 Init Server + DB
    12:50 Dockerize application
    23:47 Test application
    🔖 Topics Covered
    - Docker
    - Build a backend
    - Nodejs Express Server
    - PostgreSQL database
    - Dockerized backend

ความคิดเห็น • 35

  • @Smoljames
    @Smoljames  ปีที่แล้ว +12

    Here's a breakdown of each of the Dockerfile commands :) also don't mind the buggy facecam at the end of the video lol
    FROM - specifies the base image for the Docker image you are creating. All subsequent instructions in the Dockerfile will be applied on top of this base image.
    WORKDIR - sets the working directory for any subsequent instructions that follow it in the Dockerfile. This is where commands like RUN and COPY will be executed.
    COPY - copies files or directories from the host machine to the Docker image. The first argument is the path to the file or directory on the host machine, and the second argument is the destination path in the Docker image.
    RUN - executes a command in the Docker image. This can be used to install packages, run build commands, and do other tasks required to configure the image.
    EXPOSE - documents the ports that the Docker image is expected to listen on when it is run. It does not actually publish the ports.
    CMD - specifies the command to run when the Docker container is started from the image. If the Docker container is started with a command-line argument, it will override the CMD instruction. There can only be one CMD instruction in a Dockerfile, and it should be the last instruction.

  • @tunisiasparx2105
    @tunisiasparx2105 9 วันที่ผ่านมา +1

    aswome , best rich example in minutes, dude your amazing , you just clarify everything as you go !
    thx

  • @user-ji6ip7ou8d
    @user-ji6ip7ou8d 9 หลายเดือนก่อน +11

    Damn, I've never seen this Docker configuration. I've started learning backdev recently and the amount of project configurations is just mindblowing. It's really easy to get lost in this whole ocean of information

    • @Smoljames
      @Smoljames  9 หลายเดือนก่อน +2

      Yea I feel you my friend! Just have to find the configurations you like and keep with them :)

    • @vladislav_artyukhov
      @vladislav_artyukhov หลายเดือนก่อน

      Docker configs is easy, actually. You really most time googling a ready solutions and modify/cobine by the need

  • @juanmam.b.9453
    @juanmam.b.9453 18 วันที่ผ่านมา

    Great video!!! If you are interested, I found a docker tutorial to simplify the exercise of creating the Dockerfile and the compose.yaml: run "npm i", then "docker init" and follow the instructions. The npm i command is to create the necessary package-lock.json.
    Your explanations are great, the commands I mentioned serve as shortcuts, but thanks to you we can understand what they really do.

  • @programandocomandersonsouza
    @programandocomandersonsouza 5 หลายเดือนก่อน +1

    Very good. Congratulation Smoljames.

  • @rwayneleon7481
    @rwayneleon7481 2 หลายเดือนก่อน

    Great job. it really helped! Thank you

  • @jindrichknedla7406
    @jindrichknedla7406 ปีที่แล้ว +1

    Great tutorial. Really helped! Thank you

    • @Smoljames
      @Smoljames  ปีที่แล้ว +1

      Glad it helped!

  • @walterandrade4273
    @walterandrade4273 8 หลายเดือนก่อน +1

    great tutorial, thank you

    • @Smoljames
      @Smoljames  8 หลายเดือนก่อน +1

      Thanks for the comment :)

  • @danilsyah4108
    @danilsyah4108 5 หลายเดือนก่อน +1

    thanks a lot , great tutorial

    • @Smoljames
      @Smoljames  5 หลายเดือนก่อน

      Cheers broski :P

  • @prashlovessamosa
    @prashlovessamosa ปีที่แล้ว +1

    Thanks.

  • @yatharthm22
    @yatharthm22 29 วันที่ผ่านมา +1

    now in the same project can you please add kubernetes connectivity too?

  • @Nate-yz2tv
    @Nate-yz2tv 5 หลายเดือนก่อน +1

    bro you saved me ty lol

  • @hnvahid
    @hnvahid 6 หลายเดือนก่อน +1

    Thanks

    • @Smoljames
      @Smoljames  6 หลายเดือนก่อน

      You're welcome my broski :P

  • @sammed.sankonatti
    @sammed.sankonatti 6 หลายเดือนก่อน +1

    Is this the way to create tables inside docker container of postgres ??
    What is the better and industry standard way ? Please explain

    • @Smoljames
      @Smoljames  5 หลายเดือนก่อน

      There are numerous ways you can do it - this is just one. Another is to boot up the docker container and run a terminal command from within, and another is to execute a script that does an equivalent functionality.

    • @sammed.sankonatti
      @sammed.sankonatti 5 หลายเดือนก่อน

      @@Smoljames Thank you

  • @denyscole7382
    @denyscole7382 ปีที่แล้ว +1

    Is there a specific reason for using commonjs modules over ES6 modules?

    • @Smoljames
      @Smoljames  ปีที่แล้ว

      good question - there can definitely be advantages for using commonjs modules but in this video it was mostly just out of habit - ES6 is a great way to go if you prefer to do it that way though!

    • @denyscole7382
      @denyscole7382 ปีที่แล้ว

      @@Smoljames Thank you for your response

  • @J3rist0
    @J3rist0 8 หลายเดือนก่อน +1

    If I wanted to connect my pgAdmin to the postgres on the container how would I do this? I've spent more time than I'd like to admit trying to get that to work but with no results. Help would me much appreciated.

    • @rpoursalimi
      @rpoursalimi 6 หลายเดือนก่อน +3

      You need to bind a port to your db. To do so, you can add "ports" to your db service.
      In another word, make the "docker-compose.yaml" look like this:
      version: "3"
      services:
      db:
      image: postgres
      environment:
      POSTGRES_PASSWORD: password123
      POSTGRES_USER: user123
      POSTGRES_DB: db123
      ports:
      - 13001:5432
      app:
      image: my-node-app
      ports:
      - 13000:3000
      Then rebuild and dock your app and db again by running the following commands in the terminal:
      docker system prune
      docker build -t my-node-app .
      docker-compose up
      Now, you should be able to connect to your database on port 13001 by using the respected settings and credentials.

    • @J3rist0
      @J3rist0 6 หลายเดือนก่อน +1

      @@rpoursalimi much appreciated

  • @timlinator
    @timlinator 10 หลายเดือนก่อน +1

    I can't find this code on your git hub

    • @Smoljames
      @Smoljames  10 หลายเดือนก่อน +1

      My apologies - link is here!
      github.com/jamezmca/docker-compose-example

    • @timlinator
      @timlinator 10 หลายเดือนก่อน

      @@Smoljames Thanks

  • @sibbirshahriyar9742
    @sibbirshahriyar9742 ปีที่แล้ว +1

    Noice

  • @AbhishekKumar-lp5rc
    @AbhishekKumar-lp5rc ปีที่แล้ว

    Text size too small

    • @eduardoalvarez4457
      @eduardoalvarez4457 4 หลายเดือนก่อน

      nope, it looks just fine on a 24" screen (iMac M1 on my case)