How I build and deploy my Go applications (Templ & HTMX)

  Рет қаралды 9,575

Web Dev Cody

Web Dev Cody

Күн бұрын

Пікірлер: 49
@SeibertSwirl
@SeibertSwirl 2 ай бұрын
Dude!!!!! My notifications are delayed lol how am I getting a notification like two minutes later lol KZbin is against me. Anywayyyyyy good job babe! Love your haircut 😘
@C4CH3S
@C4CH3S 2 ай бұрын
A much cheaper alternative is to deploy directly to a VPS or VDS on providers like Hetzner or Linode, things like railway, vercel, fly, and so on can really fuck you over with fees if you make a mistake. You can do it with docker, but I prefer to setup a reverse proxy and get all my apps running with systemd services. It's really old school but I know I will only ever pay the cost of my VPS and if I want to scale, scaling vertically is effortless :p
@tjblackman08
@tjblackman08 2 ай бұрын
A 25MB image is crazy good... You taught me about the "scratch" image, thanks!
@ohLyln
@ohLyln 2 ай бұрын
Great video Cody! I have been subbed to you for a while since back in my node / react days but I like you have migrated most of my stuff to Go +Templ w/ HTMX! In fact I migrated all my old node heroku projects to Railway a few years ago too! On a side note, I would love to see a video about your dev mode with air and all the cli tools you need to run to "hot reload" (tailwind, templ generate etc). I did have it set up at one point but it always seems like a PITA to set up for every project. Would love to see how you implement such a system!
@AMDevanney
@AMDevanney 2 ай бұрын
I removed the dependency on node by using the standalone tailwind command line tool. You could do the same in the container.
@WebDevCody
@WebDevCody 2 ай бұрын
I’ll try that out
@picklenickil
@picklenickil 2 ай бұрын
@@AMDevanney wow! Yes ... I take back my comment @WebDevCody
@arturfil
@arturfil 2 ай бұрын
This
@arturfil
@arturfil 2 ай бұрын
@@depafrom5277 I think HTMX has its place but 100% if you want reactivity, forget about server-side Rendering. Client-side rendering has its place too. Not everything should look like a nail due to only having a hammer.
@ifeanyinneji7704
@ifeanyinneji7704 2 ай бұрын
Thinking of rewriting most of my django rest framework projects in Go. Just that there isn't any framework like Django for Go
@farzadmf
@farzadmf 2 ай бұрын
Small tip: instead of prepending every statement in the Makefile, you can to `make -s ...` to make it "silent" (not echo the commands it runs)
@coffeeintocode
@coffeeintocode 2 ай бұрын
You could use the Tailwind binary & add DaisyUI from CDN to remove npm entirely…..but it’s not fully tree shaken so the files are bigger than they need to be
@WebDevCody
@WebDevCody 2 ай бұрын
true, but I want smaller css files personally
@unisol111
@unisol111 2 ай бұрын
Hey, You can reduce the size of executable binaries with UPX. The compression ratio is around 60% with UPX alone. UPX + Compiler options(-ldflags=“-s -w”) even more.
@WebDevCody
@WebDevCody 2 ай бұрын
Good info!
@eillioniscreating
@eillioniscreating 2 ай бұрын
I hope you to make tutorial or playlist about building project with go in the future.
@C4CH3S
@C4CH3S 2 ай бұрын
I think using node to compile your css is fine. It's not like you have it running all the time.
@_vicary
@_vicary 2 ай бұрын
You may add one more build stage "FROM node" to save some apt install time.
@c92dotdev
@c92dotdev 2 ай бұрын
I normally have a node layer that pulls from a node docker image like node:22 and a separate golang layer that builds go
@WebDevCody
@WebDevCody 2 ай бұрын
That’s a cool idea
@dejanduh2645
@dejanduh2645 2 ай бұрын
you are using fiber I see. Would be a good comparison between fiber and the std library to monitor the memory ussage
@MrHamsterbacke756
@MrHamsterbacke756 2 ай бұрын
I don't think one could call this kind of stack simple as templ is a custom language and needs a build step. Similar to JSX but less integrated.
@fmentz
@fmentz 2 ай бұрын
could do a video on an actual production ready auth in go? Would love to see that
@WebDevCody
@WebDevCody 2 ай бұрын
Sure when I get around to that, focusing on htmx right now
@abhinavadarsh7150
@abhinavadarsh7150 2 ай бұрын
One thing I want to point out that code generation should not be part of build. You should commit generated go files.
@WebDevCody
@WebDevCody 2 ай бұрын
I disagree
@EverydayElk
@EverydayElk 2 ай бұрын
@@WebDevCody heh, you would be wrong
@WebDevCody
@WebDevCody 2 ай бұрын
@@EverydayElk but why would you commit build files? They should be reproducible artifacts of your build. That’s like committing binaries or node_modules.
@Torboc01
@Torboc01 2 ай бұрын
I saw you were using sqlite in a previous video. How do you deploy the db to railway?
@WebDevCody
@WebDevCody 2 ай бұрын
Add a volume mount and have an env variable that points the service to the mount location
@leo28804
@leo28804 2 ай бұрын
Do you use sqlite on railway and if so, do you mind explaining how?
@WebDevCody
@WebDevCody 2 ай бұрын
yes, volume mount, and point my go server's sqlite env variable to that mount location
@picklenickil
@picklenickil 2 ай бұрын
If you needed tailwind in htmx, without adding node to your containers, maybe use tailwind via cdn... Am i right or am i missing something here? Your styles are simple enough so why not.. and you dont look like someone who would have unused classes in his code
@WebDevCody
@WebDevCody 2 ай бұрын
There are a ton of classes I’m not using. The colors alone have like hundreds of classes I’m not using. But yes that is an option.
@picklenickil
@picklenickil 2 ай бұрын
@@WebDevCody makes Sense.
@lemurza5236
@lemurza5236 2 ай бұрын
Loving the node hate 🤣
@WebDevCody
@WebDevCody 2 ай бұрын
I don't really hate node, I'm just annoyed with the ecosystem a bit
@DunckingTest
@DunckingTest 2 ай бұрын
what orm did u use ?
@WebDevCody
@WebDevCody 2 ай бұрын
Just sql directly for now
@tsubasateacher
@tsubasateacher 2 ай бұрын
huh? why its so cheap? $5 for 8gb ram and vcpu?
@WebDevCody
@WebDevCody 2 ай бұрын
I think that’s just the max memory they give you. Railway charges by memory usage so you’re not really getting a dedicated 8 GB vps they’re hosting your container somewhere which allows you up to a 8 gigabytes of memory.
@tsubasateacher
@tsubasateacher 2 ай бұрын
@@WebDevCody ah.. make sense.
@ifeanyinneji7704
@ifeanyinneji7704 2 ай бұрын
First to comment
@picklenickil
@picklenickil 2 ай бұрын
A very slightly better build command build: @npm run build:tailwind @templ generate @rm -f bin/app_prod @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/app_prod cmd/app/main.go @echo "Compiled your application with all its assets to a single binary => bin/app_prod" For idempotent, parallalized, compressed containers.. 😅
@WebDevCody
@WebDevCody 2 ай бұрын
What makes it compressed? The -s -w? Doesn’t that strip out important debugging info?
@picklenickil
@picklenickil 2 ай бұрын
@@WebDevCody actually yes it does..
@shreyassanthu77
@shreyassanthu77 2 ай бұрын
​@@WebDevCodyeh not really "important"
HTMX: 3 IRL Use Cases
18:33
ThePrimeTime
Рет қаралды 120 М.
The Simplest Tech Stack
9:38
Awesome
Рет қаралды 127 М.
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 275 #shorts
00:29
When mom gets home, but you're in rollerblades.
00:40
Daniel LaBelle
Рет қаралды 70 МЛН
Why HTMX and Golang? The answer might surprise you...
12:04
Flo Woelki
Рет қаралды 13 М.
The proper way to secure your databases
14:11
Web Dev Cody
Рет қаралды 21 М.
Is HTMX a Joke??
32:15
Syntax
Рет қаралды 22 М.
HTMX Sucks
25:16
Theo - t3․gg
Рет қаралды 127 М.
Why I'd never host my apps on a VPS
13:43
Web Dev Cody
Рет қаралды 62 М.
Linus Torvalds: Speaks on Hype and the Future of AI
9:02
SavvyNik
Рет қаралды 243 М.
HTMX for Impatient Devs
8:33
Isaac Harris-Holt
Рет қаралды 58 М.
Why Templates Sucks and Are Better than JSX
8:33
ThePrimeTime
Рет қаралды 44 М.
I'm on the HTMX struggle bus right now
15:15
Web Dev Cody
Рет қаралды 12 М.
HTMX For React Developers in 10 Minutes
9:26
Jack Herrington
Рет қаралды 41 М.