Use Docker for Your Golang Projects with Live Reloading

Поділитися
Вставка
  • Опубліковано 20 жов 2024

КОМЕНТАРІ • 68

  • @MelkeyDev
    @MelkeyDev  3 місяці тому +11

    I hope you enjoy the video! Comment + like and subscribe if you did :)

  • @Gornius
    @Gornius 3 місяці тому +37

    Instead of mounting a volume, you can now use docker compose watch feature in copy mode to make docker copy files into the container once they are changed.

    • @CristianJesus2002
      @CristianJesus2002 3 місяці тому +1

      What is the benefit of copying the files instead of just mounting the directory?

    • @Gornius
      @Gornius 3 місяці тому +1

      @@CristianJesus2002 The most important for me is it eliminates problem of setting UID and GID of files. It makes files inside your developer environment run exactly the same as they would run on built image. The lesser gap between production and dev environment the better.

    • @MelkeyDev
      @MelkeyDev  3 місяці тому +4

      Yep - im aware.
      But this focused on not introducing docker-compose, but instead just a Docker file

    • @oussaber
      @oussaber Місяць тому

      I'm curious why not use docker compose?

  • @prateekgogia8310
    @prateekgogia8310 3 місяці тому +7

    air is pretty amazing! The fact that you can get live reloading with the logs support makes app building in Go so much fun.

    • @MelkeyDev
      @MelkeyDev  3 місяці тому

      Yeah it really is great

  • @sadhakbj
    @sadhakbj 3 місяці тому +3

    I want to see more go content: microservices, observability and many more.

  • @Alex-bc3xe
    @Alex-bc3xe 3 місяці тому +3

    You are the go specialist on my UA-cam :)

  • @kevinryan2992
    @kevinryan2992 3 місяці тому +2

    Air is okay for basic projects, but for things where you want to run different commands depending on which files change I much prefer cespare/reflex and watchexec/watchexec

  • @elzabethtatcher9570
    @elzabethtatcher9570 3 місяці тому

    Actually useful video, thank you.

  • @krullie
    @krullie 3 місяці тому

    It's not the only thing air can do but if you just want to live reload your project, and I mean any project, just use entr. I've never had to use anything else and it works with just about anything.

  • @ipasha3991
    @ipasha3991 3 місяці тому +2

    Great video. Wasnt aware that live reloading was also possible with golang. Is there a way to apply this concept with kubernetes?
    I have a configuration that requires a connection to a mongodb instance which is only accessible within the cluster. I could port-forward the database everytime i want to test something, but that would kinda defeat the purpose of convinience I think.

    • @MelkeyDev
      @MelkeyDev  3 місяці тому

      I havent played around with live reloading with k8 in depth - but I would assume there must be something like that

  • @potaetoupotautoe7939
    @potaetoupotautoe7939 2 місяці тому

    I' d love github repos of stuff you upload.

  • @cgalo
    @cgalo Місяць тому

    Was a bit confused `-v /app/tmp` because you said "so temp directory that we defined in the toml file" but it is not defined in 3:47. Is it maybe just the default GOTMPDIR for air or the docker image?

  • @cempack
    @cempack 3 місяці тому +4

    I have a question, what's the advantages of running the go project in a docker container instead of just running it locally?

    • @MelkeyDev
      @MelkeyDev  3 місяці тому +1

      This is a great question, but its for containerising your environment

    • @fikurimax
      @fikurimax 3 місяці тому

      I had a problem when using CGO. different glibc version between my local and the remote one. docker solved it

  • @bakedbash
    @bakedbash 19 днів тому

    Nice video..
    but why the hell do you have the lines numbers upside down 🙃

  • @timbrockley
    @timbrockley 3 місяці тому +1

    nice work :)

  • @dyto2287
    @dyto2287 3 місяці тому +3

    Biggest problem with dockerizing Go dev environment is debugging. It gets pretty nasty when you need to make it work.

    • @MelkeyDev
      @MelkeyDev  3 місяці тому +1

      Yeah, it can for sure

    • @Dr.thrtle
      @Dr.thrtle 3 місяці тому

      Yeah i agree, you can check your logs in docker desktop and observe your container logs, it helps alot tho.

    • @dyto2287
      @dyto2287 3 місяці тому

      @@Dr.thrtle I meant code debugging using breakpoints.

  • @OhDevBeard
    @OhDevBeard 3 місяці тому +3

    I may be the only one but I just don’t understand what docker buys you. Like, what would be the point of dockerizing your project locally? Or on server? It just feels so overkill to me

    • @1316erick
      @1316erick 3 місяці тому +2

      same, hope someone could explain why I should do this for local. thx!

    • @ascendo651
      @ascendo651 3 місяці тому +2

      The advantage is, that you build your app in the same environment as you deploy it later. Furthermore, if you work on an app with a colleague, both of you are using the same environment with zero setup.

    • @dyto2287
      @dyto2287 3 місяці тому +1

      Hmm... so you are one of those "works on my machine" kind of guys?

    • @codingwithjamal
      @codingwithjamal 3 місяці тому +5

      docker allowed code to run anywhere no matter the OS that docker itself can run so it makes deploying to cloud simple. Its like bash scripts but with a vm and tools to manage your app in an isolated environment

    • @1316erick
      @1316erick 3 місяці тому

      @@dyto2287 Of course, is there any other way to work? LMAO

  • @fikurimax
    @fikurimax 3 місяці тому +1

    Why not develop using air without docker and dockerize after everything is done?

    • @MelkeyDev
      @MelkeyDev  3 місяці тому

      i dont think i ever said you cant do this

    • @fikurimax
      @fikurimax 3 місяці тому

      @@MelkeyDev no I mean, why dockerizing it first. Just curious, what's the benefit

  • @andherium
    @andherium 3 місяці тому +1

    But why?

  • @j.r.r.tolkien8724
    @j.r.r.tolkien8724 3 місяці тому +2

    Every time I install docker it messes up my network.

    • @MelkeyDev
      @MelkeyDev  3 місяці тому

      Are you on Windows?

    • @j.r.r.tolkien8724
      @j.r.r.tolkien8724 3 місяці тому +1

      @@MelkeyDev Debian. Haven't used windows in ages.

  • @ArturdeSousaRocha
    @ArturdeSousaRocha 3 місяці тому +1

    "HELP ON COBOL AND FEE..."? 🤔

    • @MelkeyDev
      @MelkeyDev  3 місяці тому

      ??? what

    • @ArturdeSousaRocha
      @ArturdeSousaRocha 3 місяці тому

      @@MelkeyDev Bottom left in your VS Code. 😊 Was wondering what's going on.

  • @m7mo0o
    @m7mo0o 3 місяці тому

    how to do this for NodeJs?

  • @jus1d
    @jus1d Місяць тому

    why tf you need docker for local development with live reloading? why dont you use just air. there is no reasons to dockerize your app locally

    • @zuzuz18
      @zuzuz18 Місяць тому

      It's generally nice to have your dev environment and prod environment to be roughly similar, so that you don't run into issues in prod that didn't exist in dev

  • @93khizar
    @93khizar 3 місяці тому +1

    no views in 1 minute, bros fallen off

    • @pythonwithsean
      @pythonwithsean 3 місяці тому

      Shut up man the UA-cam algorithm is weird for tech UA-cam

    • @MelkeyDev
      @MelkeyDev  3 місяці тому

      ouch

  • @ahmo4781
    @ahmo4781 3 місяці тому +3

    guys if you have problems with the hot reloading try to add poll = true in the .air.toml after that it worked for me.... (think its some windows bullshit)

  • @nedmoore214
    @nedmoore214 3 місяці тому +3

    Docker > Golang