R
Railway2y ago
epik!

pushing changes in deployment

my project is deployed via github and it writes to the working directory, these changes are supposed to be able to get pushed but when i try git push, it says fatal: not a git repository (or any of the parent directories): .git
Solution:
not the best approach, you would want to be using object storage like cloudflare r2
Jump to solution
54 Replies
Percy
Percy2y ago
Project ID: f1e43e9b-5ebf-4488-a4aa-65930dcaccd1
Brody
Brody2y ago
im sorry but i dont see how issues with git on your local computer has anything to do with railway
epik!
epik!OP2y ago
? i'm talking about railway none of this is on my computer
Brody
Brody2y ago
git push is a command you run on your computer am i wrong there?
epik!
epik!OP2y ago
it's part of my code my code runs git push
Brody
Brody2y ago
why would you want to do that?
epik!
epik!OP2y ago
to sync a specific file with the repo on github?
Solution
Brody
Brody2y ago
not the best approach, you would want to be using object storage like cloudflare r2
epik!
epik!OP2y ago
thanks i will check it out can i integrate it with railway
Brody
Brody2y ago
you would intigrate it with your code using the amazon s3 sdk
epik!
epik!OP2y ago
thanks
epik!
epik!OP2y ago
works beautifully, thanks so much
epik!
epik!OP2y ago
used rclone
Brody
Brody2y ago
now hold on are you using rclone in the same fashion that you where using git push?
epik!
epik!OP2y ago
i'm using rclone-python, so no
Brody
Brody2y ago
i would recommend against that, the best way would be using the r2 api directly with boto3 using the api directly with the boto3 package is way less error prone, faster, more portable then calling out to the shell to run rclone commands
epik!
epik!OP2y ago
boto3 seems complicated
Brody
Brody2y ago
it's worth it, trust me
epik!
epik!OP2y ago
i'll give it a shot later @Brody i think i figured it out
epik!
epik!OP2y ago
epik!
epik!OP2y ago
but when i upload the type isn't text/plain
Brody
Brody2y ago
I think you can specify the mime type in extra args
epik!
epik!OP2y ago
hmm
epik!
epik!OP2y ago
contenttype?
Brody
Brody2y ago
content type
epik!
epik!OP2y ago
will try works what about charset?
Brody
Brody2y ago
just set ContentType = text/plain; charset=utf-8
epik!
epik!OP2y ago
oh ok tysm
Brody
Brody2y ago
no problem! you are using environment variables for the storage credentials right?
epik!
epik!OP2y ago
was doing a local test, but for railway i'll use the environment variables
Brody
Brody2y ago
perfect!
epik!
epik!OP2y ago
to download objects, should i use copy_object or get_object?
Brody
Brody2y ago
get
epik!
epik!OP2y ago
ok hmm format is confusing
Brody
Brody2y ago
format?
epik!
epik!OP2y ago
to upload it's s3.Bucket("bucket").put_object(Key="file.txt", Body=open("file.txt", "rb"), ContentType="text/plain; charset=utf-8") i don't know how it is for downloading though
Brody
Brody2y ago
download_object, get_object something along those lines, but that's what the documentation is for
epik!
epik!OP2y ago
i'm getting a AttributeError: 's3.Bucket' object has no attribute 'get_object'. Did you mean: 'put_object'?
Brody
Brody2y ago
link me the documentation you've been using
epik!
epik!OP2y ago
how do i use it then?
Brody
Brody2y ago
scroll down on this page, it shows you all the available arguments
epik!
epik!OP2y ago
oh i had a typo in my filename lol
Brody
Brody2y ago
lol
epik!
epik!OP2y ago
this works
s3.Bucket("bucket").download_file(Key="file.xt", Filename="file.txt")
s3.Bucket("bucket").download_file(Key="file.xt", Filename="file.txt")
Brody
Brody2y ago
perfect
epik!
epik!OP2y ago
s3 is defined as
s3 = boto3.resource('s3',
endpoint_url = 'https://<accountid>.r2.cloudflarestorage.com',
aws_access_key_id = '<access_key_id>',
aws_secret_access_key = '<access_key_secret>'
)
s3 = boto3.resource('s3',
endpoint_url = 'https://<accountid>.r2.cloudflarestorage.com',
aws_access_key_id = '<access_key_id>',
aws_secret_access_key = '<access_key_secret>'
)
Brody
Brody2y ago
now just to swap over to service variables then you can run your app locally with the railway service variables available by using railway run
epik!
epik!OP2y ago
alright can i also set endpoint_url using an environment variable?
Brody
Brody2y ago
yes of course
epik!
epik!OP2y ago
alright railway run works well
Brody
Brody2y ago
awesome
Want results from more Discord servers?
Add your server