Next.js Discord

Discord Forum

When building a docker image, what's the recommended way to also upload .next/static to CDN?

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Should I build outside of the docker image and upload .next/static, then build the image?

17 Replies

you should bundle your next app within your container
Masai LionOP
how/when do I upload the built files to cdn?
@Masai Lion how/when do I upload the built files to cdn?
u can use github ci
and githubs private docker registry
Masai LionOP
do you have any instructions on how to do it locally?
building docker images locally?
look at this
Masai LionOP
getting the static files to cdn from an image build
Masai LionOP
the problem is you build the nextjs project inside a docker image but you then need to upload the static assets to cdn. I'm wondering if there's a suggested to accomplish this uploading part.
hey! I'm getting into this issue as well. I would like to upload static files from our CI workflow into our CDN (S3+CF), but since all statics are inside the image it's hard to get them.
@Masai Lion did you ever end up solving this?
if anyone is curious how to do this, I ended up using docker create to create a container and then extract the files
CONTAINER_ID=$(docker create website)
docker cp $CONTAINER_ID:/app/.next .next