CabalDAO
CabalDAO3mo ago

Importing a snapshot during deploy stored on s3

Hi, my snapshot is now above 100mb. This means I can no longer commit it to github. Is there a way to tell the deploy command npx convex import --preview-name "$VERCEL_GIT_COMMIT_REF" ./data/mock-data/snapshot.zip during a deploy to tell it to grab the file from a remote resource, like an s3 bucket? What are workarounds for large snapshots that can't be commited to a repo?
19 Replies
Convex Bot
Convex Bot3mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
lee
lee3mo ago
currently this isn't possible; npx convex import requires the file to exist on the local filesystem. But @nipunn is working on a new feature that should help
CabalDAO
CabalDAOOP3mo ago
Thanks If I wanted to import manually, can I run npx convex import --replace --preview-name "development" ./data/mock-data/snapshot.zip locally to upload it to a preview deployment whose branch name is "development"? i.e. is the VERCEL_GIT_COMMIT_REF used in the deploy command npx convex deploy --cmd 'npm run build'&&[ "$VERCEL_ENV" = preview ]&&npx convex import --preview-name "$VERCEL_GIT_COMMIT_REF" ./data/mock-data/snapshot.zip;npx convex run --preview-name "$VERCEL_GIT_COMMIT_REF" migrations:runMigrations equal to the branch name? If not, how do I get it?
lee
lee3mo ago
I suppose you could split the file into many files for github and then merge them in the build command.
CabalDAO
CabalDAOOP3mo ago
Wow yea actually what I did above seemed to work!
lee
lee3mo ago
I believe $VERCEL_GIT_COMMIT_REF is the branch name, yes. Are you trying to import into your dev deployment?
CabalDAO
CabalDAOOP3mo ago
no, was trying to import into preview environment Just happens to be that my preview environment is off the pushed branch development
lee
lee3mo ago
Nice
CabalDAO
CabalDAOOP3mo ago
Now that I'm doing it manually, how would I remove it properly from the deploy command but still keep the runmigrations part?
npx convex deploy --cmd 'npm run build'&&[ "$VERCEL_ENV" = preview ]&&npx convex import --preview-name "$VERCEL_GIT_COMMIT_REF" ./data/mock-data/snapshot.zip;npx convex run --preview-name "$VERCEL_GIT_COMMIT_REF" migrations:runMigrations
npx convex deploy --cmd 'npm run build'&&[ "$VERCEL_ENV" = preview ]&&npx convex import --preview-name "$VERCEL_GIT_COMMIT_REF" ./data/mock-data/snapshot.zip;npx convex run --preview-name "$VERCEL_GIT_COMMIT_REF" migrations:runMigrations
to
npx convex deploy --cmd 'npm run build'&&[ "$VERCEL_ENV" = preview ]&&npx convex run --preview-name "$VERCEL_GIT_COMMIT_REF" migrations:runMigrations
npx convex deploy --cmd 'npm run build'&&[ "$VERCEL_ENV" = preview ]&&npx convex run --preview-name "$VERCEL_GIT_COMMIT_REF" migrations:runMigrations
?
lee
lee3mo ago
Do you want to runMigrations after importing the seed data? Then that won't work
CabalDAO
CabalDAOOP3mo ago
Oh I guess there's no point in running the migration then and there yea
lee
lee3mo ago
As another option, you could store the file in s3 and then curl it to download it before importing
CabalDAO
CabalDAOOP3mo ago
So just npx convex deploy --cmd 'npm run build' and then locally run npx convex import --replace --preview-name "development" ./data/mock-data/snapshot.zip;npx convex run --preview-name "development" migrations:runMigrations ?
As another option, you could store the file in s3 and then curl it to download it before importing
I can do all that in a build command? That'd be cool
lee
lee3mo ago
yep build command should be able to curl
CabalDAO
CabalDAOOP3mo ago
wow ok will try that Or maybe ill do it in github actions since i can store the snapshot with lfs
lee
lee3mo ago
Ooh good idea
CabalDAO
CabalDAOOP3mo ago
In the end I was able to put it into an s3 bucket and write a custom build command file that downloads it and then runs and it works! Is there a place where the community can write custom posts to help others? I'd be happy to write this one as an example and share it with the community
lee
lee3mo ago
nice work! you could post in #general or #show-and-tell , since that build command sounds useful 🙂
CabalDAO
CabalDAOOP3mo ago
👍

Did you find this page helpful?