简体   繁体   中英

Ruby on Rails - PDF not showing in production mode with Docker

I'm having a hard time figureing out the solution to my problem. I have a ror application running in Docker. In development, the uploaded pdf get stored in ./storage directory and they got rendered as expected on my application. In production, get uploaded in the same directory, but they don't get displayed. I have checked the permissions on the directory and files and they seems to be ok.

My config:

storage.yml:

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

production.rb:

config.active_storage.service = :local

_attachment.html.erb:

<% if territory.file.previewable? %>
  <div class="container">
    <embed type="application/pdf" src="<%= rails_blob_path(@territory.file, disposition: :inline) %>" width="100%" height="500px">
  </div>
<% end %>

This partial gets rendered in my view like this:

<p>
  <%= render "territories/attachment", territory: territory %>
</p>

Am I missing something? Thanks for any help and stay save out there!

Solution was found!

Some packages wehere missing in the Dockerfile .

RUN apk add --update --no-cache  --virtual run-dependencies \
...
imagemagick \
less \
poppler-utils \
&& rm -rf /var/cache/apk/*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM