How long are deploys supposed to take?

I know it depends on a lot of factors but my code is taking 1-3 minutes which is really breaking my flow and productivity. I am already a Team user for Railway (didn't seem to help at all) and I use the railway up command from the CLI to deploy. The one nuance is this server needs CGO_ENABLED but besides that I'm not understanding why it takes so long in the first place?
No description
42 Replies
Percy
Percy9mo ago
Project ID: d60c6135-973c-4957-bf95-00eac2ed9e32
cybershizo
cybershizoOP9mo ago
d60c6135-973c-4957-bf95-00eac2ed9e32
Brody
Brody9mo ago
how big the the image when its built?
cybershizo
cybershizoOP9mo ago
I see Pushing [==================================================>] 543.9MB 04c0d2b851c3 Pushed 04c0d2b851c3 121a47bf-47df-4e3a-a1b8-0c9888d3f770: digest: sha256:9d75f75d2f2b4621291cf91527fd96876d73a8b9a41f607ec45b19e3237ba475 size: 2633 Publish time: 38.38 seconds ==================== Starting Healthcheck ==================== Path: /healthz Retry window: 5m0s
Brody
Brody9mo ago
540mb, not bad
cybershizo
cybershizoOP9mo ago
Yeah it should be zippy
Brody
Brody9mo ago
how long is the build time?
cybershizo
cybershizoOP9mo ago
This one was about 3 minutes even
Brody
Brody9mo ago
what stage took the longest?
cybershizo
cybershizoOP9mo ago
I know the health check takes another few seconds and then it takes another 30 seconds for it to turn off the previous deploy but 3 minutes is from when I type railway up and then wait for the Starting healthcheck message How can I tell?
Brody
Brody9mo ago
look at the logs
cybershizo
cybershizoOP9mo ago
It's virtualized so I can't copy paste the whole thing Sec Build time: 89.75 seconds Publish time: 38.38 seconds
Brody
Brody9mo ago
what build stage took the longest?
cybershizo
cybershizoOP9mo ago
Are there more stages than that?
Brody
Brody9mo ago
the build is made up of multiple stages, please look at the logs
cybershizo
cybershizoOP9mo ago
#8 36.87 deleting '/nix/store/hnz8p5w9xc0ivsiyrgky6f6h7sjb28a5-file-5.45'

#8 36.88 deleting '/nix/store/7fqp73ncnbwr5bxxszqicf6r33d9yhkw-gnused-4.9'

#8 36.89 deleting unused links...

#8 36.89 note: currently hard linking saves -0.00 MiB

#8 36.95 27 store paths deleted, 250.35 MiB freed



#8 DONE 37.1s





#9 [stage-0 5/9] COPY . /app/.

#9 DONE 0.0s





#10 [stage-0 6/9] RUN --mount=type=cache,id=s/a354a09b-f734-4f06-85d6-61dd0c222868-/root/cache/go-build,target=/root/.cache/go-build go mod download



#10 DONE 2.2s





#11 [stage-0 7/9] COPY . /app/.



#11 DONE 0.0s



#12 [stage-0 8/9] RUN --mount=type=cache,id=s/a354a09b-f734-4f06-85d6-61dd0c222868-/root/cache/go-build,target=/root/.cache/go-build go build -o app cmd/iconflex/*.go



#12 DONE 44.0s





#13 [stage-0 9/9] COPY . /app

#13 DONE 0.0s



#14 exporting to image

#14 exporting layers



#14 exporting layers 4.8s done



#14 writing image sha256:e18f7387818d3d9ab5d9870fa8067192356cb7b74e059536e7a039632de18739 done

#14 naming to us-west1.registry.rlwy.net/a354a09b-f734-4f06-85d6-61dd0c222868:121a47bf-47df-4e3a-a1b8-0c9888d3f770 done

#14 DONE 4.8s



=== Successfully Built! ===
#8 36.87 deleting '/nix/store/hnz8p5w9xc0ivsiyrgky6f6h7sjb28a5-file-5.45'

#8 36.88 deleting '/nix/store/7fqp73ncnbwr5bxxszqicf6r33d9yhkw-gnused-4.9'

#8 36.89 deleting unused links...

#8 36.89 note: currently hard linking saves -0.00 MiB

#8 36.95 27 store paths deleted, 250.35 MiB freed



#8 DONE 37.1s





#9 [stage-0 5/9] COPY . /app/.

#9 DONE 0.0s





#10 [stage-0 6/9] RUN --mount=type=cache,id=s/a354a09b-f734-4f06-85d6-61dd0c222868-/root/cache/go-build,target=/root/.cache/go-build go mod download



#10 DONE 2.2s





#11 [stage-0 7/9] COPY . /app/.



#11 DONE 0.0s



#12 [stage-0 8/9] RUN --mount=type=cache,id=s/a354a09b-f734-4f06-85d6-61dd0c222868-/root/cache/go-build,target=/root/.cache/go-build go build -o app cmd/iconflex/*.go



#12 DONE 44.0s





#13 [stage-0 9/9] COPY . /app

#13 DONE 0.0s



#14 exporting to image

#14 exporting layers



#14 exporting layers 4.8s done



#14 writing image sha256:e18f7387818d3d9ab5d9870fa8067192356cb7b74e059536e7a039632de18739 done

#14 naming to us-west1.registry.rlwy.net/a354a09b-f734-4f06-85d6-61dd0c222868:121a47bf-47df-4e3a-a1b8-0c9888d3f770 done

#14 DONE 4.8s



=== Successfully Built! ===
I see there are 9 stages
#1 transferring dockerfile: 2.28kB done

#1 DONE 0.0s

#2 DONE 0.2s

#3 DONE 0.0s

#5 transferring context: 2B done

#5 DONE 0.0s

#6 transferring context: 328.65kB 0.0s done

#6 DONE 0.1s

#7 DONE 0.1s

#8 DONE 37.1s

#9 DONE 0.0s

#10 DONE 2.2s

#11 DONE 0.0s

#12 DONE 44.0s

#13 DONE 0.0s

#14 exporting layers 4.8s done

#14 writing image sha256:e18f7387818d3d9ab5d9870fa8067192356cb7b74e059536e7a039632de18739 done

#14 naming to us-west1.registry.rlwy.net/a354a09b-f734-4f06-85d6-61dd0c222868:121a47bf-47df-4e3a-a1b8-0c9888d3f770 done

#14 DONE 4.8s
#1 transferring dockerfile: 2.28kB done

#1 DONE 0.0s

#2 DONE 0.2s

#3 DONE 0.0s

#5 transferring context: 2B done

#5 DONE 0.0s

#6 transferring context: 328.65kB 0.0s done

#6 DONE 0.1s

#7 DONE 0.1s

#8 DONE 37.1s

#9 DONE 0.0s

#10 DONE 2.2s

#11 DONE 0.0s

#12 DONE 44.0s

#13 DONE 0.0s

#14 exporting layers 4.8s done

#14 writing image sha256:e18f7387818d3d9ab5d9870fa8067192356cb7b74e059536e7a039632de18739 done

#14 naming to us-west1.registry.rlwy.net/a354a09b-f734-4f06-85d6-61dd0c222868:121a47bf-47df-4e3a-a1b8-0c9888d3f770 done

#14 DONE 4.8s
Brody
Brody9mo ago
44 seconds to go build, theres not really too many ways around that since its already cached
cybershizo
cybershizoOP9mo ago
Based on this 8 and 12 take a ton of time I mean is it possible to get like 10 second deploys or am I oversimplifying the problem? Every time I deploy it just takes forever because I usually need multiple iterations and the feedback loop takes minutes each
Brody
Brody9mo ago
the only thing i can see that you could improve would be the publish time
cybershizo
cybershizoOP9mo ago
How would I improve that? Can I just build it locally and send the executable or something?
Brody
Brody9mo ago
you would want to create your own dockerfile that uses a final image so that the published image is as small as possible, i dont have any super big go apps running on railway but the publish time of my go apps is 4-5 seconds
cybershizo
cybershizoOP9mo ago
So I have my own docker file and I build locally? I'm open minded I just don't really know the steps
Brody
Brody9mo ago
no, you would still let railway build from the dockerfile
cybershizo
cybershizoOP9mo ago
I see I guess I will have to try this approach
Brody
Brody9mo ago
personally, i stay away far away from cgo, my go build times are 10s making my total build times sub 25 seconds
cybershizo
cybershizoOP9mo ago
Does that mean I need to have docker on my computer (Mac) or just the dockerfile and that's it? No I know it's a requirement for this one server because I needd webp I think
Brody
Brody9mo ago
just the dockerfile, i dont have docker on my computer
cybershizo
cybershizoOP9mo ago
Do you have an example docker file you can share? I wouldn't really know where to start And you might be right that this server in particular doesn't need CGO but one of them definitely does
Brody
Brody9mo ago
this would be a decent starting point but would be super unlikely to work out of the box for you
############# STAGE 1 #############

FROM golang:1.22.0-alpine AS builder

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . ./

RUN go build -ldflags="-w -s" -o main

############# STAGE 2 #############

FROM gcr.io/distroless/static

WORKDIR /app

COPY --from=builder /app/main ./

ENTRYPOINT ["/app/main"]
############# STAGE 1 #############

FROM golang:1.22.0-alpine AS builder

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . ./

RUN go build -ldflags="-w -s" -o main

############# STAGE 2 #############

FROM gcr.io/distroless/static

WORKDIR /app

COPY --from=builder /app/main ./

ENTRYPOINT ["/app/main"]
what does your one server need cgo for?
cybershizo
cybershizoOP9mo ago
One of the thing this machine does is convert PNG to WebP But only one server needs that
Brody
Brody9mo ago
that needs cgo?
cybershizo
cybershizoOP9mo ago
Yes because nobody writes WebP encoders They just talk to the C library because it's too complicated to rewrite the lib
Brody
Brody9mo ago
theres no pure go to webp encoder?
cybershizo
cybershizoOP9mo ago
No so far that I can find Apparently it's wildly complicated
Brody
Brody9mo ago
fair enough
cybershizo
cybershizoOP9mo ago
What is this bit about? FROM gcr.io/distroless/static
Brody
Brody9mo ago
i copy the built binary into the distroless image so that the final image is nearly as small as the binary itself
cybershizo
cybershizoOP9mo ago
OK I see. I'll play with docker deploys later and see if I can remove CGO from one of my servers
Brody
Brody9mo ago
resulting in sub 10mb images for me, and thats how i get my 4 second publish times
cybershizo
cybershizoOP9mo ago
Gist
dockerfile
GitHub Gist: instantly share code, notes, and snippets.
cybershizo
cybershizoOP9mo ago
Great thanks, that helps for now. Have two things I can try Yeah 1-3 minutes is killing me I'll mark this as solved, thanks @Brody
Brody
Brody9mo ago
no problem!
Want results from more Discord servers?
Add your server