docker上的回形针不上传图片?

时间:2017-01-10 17:26:26

标签: ruby-on-rails ruby docker amazon-s3 paperclip

在docker开发环境下使用rails时,我遇到了paperclip的问题, 我按照README上的所有步骤将图像添加到现有模型,一切都没有错误,但图像没有在本地上传,即使我尝试直接上传到S3,同样的问题根本没有错误,图片丢失文件夹是空的?

我的代码很干净我试过它的docker它有效,有什么建议吗?

提到我甚至尝试过载波,它的效果非常好但是我喜欢使用回形针我觉得它更轻巧,更强大。

1 个答案:

答案 0 :(得分:2)

这是我的Dockerfile

# Use the barebones version of Ruby 2.3.
FROM ruby:2.3.1-slim

# Optionally set a maintainer name to let people know who made this image.
MAINTAINER Chris de Bruin <chris@studytube.nl>

# Install dependencies:
# - build-essential: To ensure certain gems can be compiled
# - nodejs: Compile assets
# - imagemagick: converting images
# - file: needed by paperclip
# - wkhtmltopdf: generating pdf from html
# - libxml2: needed for nokogiri
RUN apt-get update && apt-get install -qq -y --no-install-recommends \
      build-essential libmysqlclient-dev git-core imagemagick wkhtmltopdf \
      libxml2 libxml2-dev libxslt1-dev nodejs file

# Set an environment variable to store where the app is installed to inside
# of the Docker image. The name matches the project name out of convention only.
ENV INSTALL_PATH /backend
RUN mkdir -p $INSTALL_PATH

# This sets the context of where commands will be ran in and is documented
# on Docker's website extensively.
WORKDIR $INSTALL_PATH

# Ensure gems are cached and only get updated when they change. This will
# drastically increase build times when your gems do not change.
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock

RUN bundle install

# Copy in the application code from your work station at the current directory
# over to the working directory.
COPY . .

# Ensure the static assets are exposed through a volume so that nginx can read
# in these values later.
VOLUME ["$INSTALL_PATH/public"]

# The default command that gets ran will be to start the Puma server.
CMD bundle exec puma -C config/puma.rb

因此,您应拥有自己的Dockerfile,并在docker-compose.yml

中使用此功能