Use Docker for Your Golang Projects with Live Reloading

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024

Комментарии • 68

  • @MelkeyDev
    @MelkeyDev  3 месяца назад +10

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

  • @Gornius
    @Gornius 3 месяца назад +36

    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 14 дней назад

      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

  • @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

  • @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

  • @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)

    • @MelkeyDev
      @MelkeyDev  3 месяца назад

      booooooo windows

  • @sadhakbj
    @sadhakbj 3 месяца назад +3

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

    • @MelkeyDev
      @MelkeyDev  3 месяца назад +1

      okay! thank you

  • @bakedbash
    @bakedbash День назад

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

  • @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

  • @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?

  • @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.

  • @Alex-bc3xe
    @Alex-bc3xe 3 месяца назад +3

    You are the go specialist on my RUclips :)

  • @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

  • @jus1d
    @jus1d 20 дней назад

    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 18 дней назад

      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

  • @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.

  • @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

  • @potaetoupotautoe7939
    @potaetoupotautoe7939 Месяц назад

    I' d love github repos of stuff you upload.

  • @elzabethtatcher9570
    @elzabethtatcher9570 2 месяца назад

    Actually useful video, thank you.

  • @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.

  • @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.

  • @m7mo0o
    @m7mo0o 3 месяца назад

    how to do this for NodeJs?

  • @93khizar
    @93khizar 3 месяца назад +1

    no views in 1 minute, bros fallen off

    • @pythonwithsean
      @pythonwithsean 3 месяца назад

      Shut up man the RUclips algorithm is weird for tech RUclips

    • @MelkeyDev
      @MelkeyDev  3 месяца назад

      ouch

  • @nedmoore214
    @nedmoore214 3 месяца назад +3

    Docker > Golang