#How to deploy faster (Docker on Google Cloud)

20 messages · Page 1 of 1 (latest)

spring yarrow
#

Hi everyone, I'm looking for tips from anyone more familiar with Docker on how to speed-up deployment. It currently takes 6 to 7 minutes to deploy on Google Cloud using Cloud Build and Cloud Run with a Dockerfile more or less exactly like the recommended file from the docs (https://payloadcms.com/docs/production/deployment#docker)

  • Are there ways to add a build cache? It seems like the majority of the time comes from running yarn install every time, even if the dependencies didn't change
  • Is it necessary to do yarn install in both the build and deploy steps? Could the original dependenecies be included in the Docker image?
  • Any other tips and what a realistic goal for deployment speed might be
burnt waveBOT
spring yarrow
#

@late anchor I'd be curious to know if your deployments take a similar amount of time? I mostly followed your guide for deploying on Google Cloud (couldn't have done it without that walkthrough, thank you)

vale summit
#

Hey @spring yarrow The builder layer needs yarn install with dev dependencies because yarn build needs it for type checking your code for errors. Second stage then needs to do a fresh install of yarn with prod dependencies only because all dev dependencies should not be included to keep image size of the prod image small. It is already copying some artefacts from build stage over too.

#

So in terms of speeding things up, you can just do everything in one stage but your trade off is bigger image size as your image will include dev dependencies

late anchor
# spring yarrow <@191776538205618177> I'd be curious to know if your deployments take a similar ...

Unfortunately it does. However this is mostly due to the limitations of 1 - webpack, and 2 - the default Google Cloud Build configurations. Upping the vCPU limit will improve build times. But if they are really impacting you, Payload 2.0 just came with Vite support! That will substantially reduce build times. Personally, I’m waiting for turbopack to leave beta. Hopefully we’ll see some movement in the next few months

clear geyser
#

@late anchor do you have any experience deploying using continuous deploy new revisions from a source repository with a docker file and your repo including a .npmrc file with token for private package ?

late anchor
#

Do you have a google cloud hosted package registry?

clear geyser
#

nope its hosted on github

late anchor
#

hmm

#

Mayeb you could use VPC to do some trickery to let you access your package repository

#

actually

clear geyser
#

ill do some research around it , i even tried committing the .npmrc file with a temporary token just to test and even with that it still say its unauthorized while its working on my local

late anchor
#

yeah, I think you need to have a PAT that is used to log in. Because if you think about it - whatever you had to do on your local machine in order to pull the package, you'll have to do with docker

#

fortunetly this shouldn't be a Google Cloud Issue. This will be pure docker. I'm sure there will be a lot of information on it 🙂

clear geyser
#

i didnt think of it that way but i had suspicions that youd require more than just a token to be able to install package

clear geyser