rodydavis / pocketbase-cloudrun

Run PocketBase on CloudRun with mounted volumes via Google Cloud Storage
Apache License 2.0
23 stars 11 forks source link

pb_public, pb_hooks, and pb_migrations not copying to cloud storage #1

Open tewshi opened 1 month ago

tewshi commented 1 month ago

After applying the changes as suggested, I deployed successfully, but noticed that the pb_hooks, pb_public and pb_migrations directories are not saved on cloud storage.

The pb_data directory copies, which I believe it does so because it is generated at run time and not at build time.

when I run the docker build locally, I can see the /cloud/storage folder in the files of the image (which is expected since I'm not mounting any cloud directory in my local machine), but I expect this /cloud/storage to be mapped (at docker build time) to the actual mounted directory pointing to Google cloud storage

rodydavis commented 1 month ago

That is correct!

https://github.com/rodydavis/pocketbase-cloudrun/blob/main/Dockerfile#L27

You need to upload the files for pb_public and pb_hooks directly to cloud storage in the same location beside pb_data. It is already mapped but pb_data is created the first time it is run

tewshi commented 1 month ago

wish there's a way to handle this, wanted to. use gcloud storage cp but that will require authentication in the docker image... also tried docker --mount option, mount only works when running the image, not when building.

there has to be an easier way to get it done...

rodydavis commented 1 month ago

Well as per the command you can customize the paths.

If you want them to be local to the container, just modify the Dockerfile to change where they point to.

Then you would just copy the files in on docker build.

tewshi commented 1 month ago

after doing some findings, I was able to automate it.

moved the copy command to use the cloud build config, while cloud run is running, copy the files to storage

cloudbuild.yaml

steps:
  - name: 'gcr.io/cloud-builders/gsutil'
    args: ['-m', 'cp', '-r', 'migrations/', 'gs://${_CLOUD_BUCKET}/']

then the docker build step followed, I've also been able to use this flow to generate and copy frontend files

@rodydavis

rodydavis commented 1 month ago

Woah that is awesome!!

Could you make a PR with the changes?

tewshi commented 1 month ago

Okay, I'll do it, give me some time.

rodydavis commented 1 month ago

Not a problem! Really appreciate it 🚀