User trandatnh disabled their CDN to reduce costs, causing all previously uploaded images with CDN URLs to fail loading. They asked if there is a way to programmatically convert these URLs to direct S3 links. zogstrip suggested rebaking all posts using either the Post.update_all method or the rake posts:rebake command.
When trandatnh attempted to run the rake command directly on the server, they encountered a “No Rakefile found” error. zogstrip clarified that the command must be executed inside the Docker container using ./launcher enter app. After initially facing Docker compatibility issues with version 1.2, trandatnh upgraded Docker to version 1.6.2 and successfully ran the rebake process, resolving the image loading issues.
Update 2 confirms all images are now displaying correctly.
I’ve just disabled CDN to save the cost. However, all the old images, which is uploaded while I was using cloudfront, are failed to load.
For example:
I have CDN URL is cdn.mydomain.com. After disabling CDN, the cdn.mydomain.com is invalid so that all the images should start with mydomain.com instead.
Is there anyway to convert all those urls programmatically?
Note: I am going to use S3 to store all my images. Can I just make use of this opportunity to convert everything from cdn to s3 url?
rake posts:rebake
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
(See full trace by running task with --trace)
I think it is because the answer was very old.
I added --trace
root@daynhauhoc:/var/discourse# rake posts:rebake --trace
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/usr/lib/ruby/vendor_ruby/rake/application.rb:584:in `raw_load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:89:in `block in load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:160:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:88:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:72:in `block in run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:160:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:70:in `run'
/usr/bin/rake:27:in `<main>'
root@daynhauhoc:/var/discourse# ./launcher enter app
Error: Command not found: exec
Error: Command not found: -it
Usage: docker [OPTIONS] COMMAND [arg...]
I am using v1.4.0.beta1 +4. I used to be able to rake last time when I migrated from S3 to local. I think docker is up to date outdated.
root@daynhauhoc:/var/discourse# git pull
Already up-to-date.
root@daynhauhoc:/var/discourse# ./launcher rebuild app
Ensuring discourse docker is up to date
Fetching origin
Discourse Docker is up-to-date
I’ve just temporary upgraded Digital Ocean droplet to higher plan using flexible resize feature because I think the rake will take a lot of CPU usage. But I don’t think resizing the droplet causes any issue with docker.
I am using docker 1.2
root@daynhauhoc:/var/discourse# docker -v
Docker version 1.2.0, build fa7b24f