【问题标题】:RDS related error when deploying a Docker Rails 6 app to AWS ECS将 Docker Rails 6 应用程序部署到 AWS ECS 时出现与 RDS 相关的错误
【发布时间】:2021-06-03 14:36:24
【问题描述】:

我正在尝试将 Rails 6 应用程序部署到 AWS ECS。

部署失败,出现如下错误:

health_check 失败:无法加载插件 http:加载错误 共享库 lib/mariadb/plugin/http.so: 没有这样的文件或目录

宝石文件

gem 'rails', '~> 6.0.0'
gem 'mysql2'

Gemfile.lock

mysql2 (0.5.3)
rails (6.0.3.6)

我没有在我的应用程序中使用 MariaDB,而是根据the mysql2 gem author, it might be necessary to add MariaDB dependencies

您可能需要安装 libmariadb-dev、libmysqlclient-dev、mysql-devel 或 default-libmysqlclient-dev 等软件包;请参阅您的发行版的包指南以找到特定的包。我们看到的最常见问题是拥有库文件 libmysqlclient.so 但缺少头文件 mysql.h 的用户——仔细检查您是否安装了 -dev 包。

Dockerfile

###############################
FROM ruby:2.6.3-alpine

ARG RAILS_ENV
ENV RAILS_ENV ${RAILS_ENV}

RUN apk add --update --no-cache \
  build-base \
  openssl \
  mysql-dev \
  mariadb-dev \
  git \
  tzdata && \
  cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

WORKDIR /app
ADD Gemfile* /app/

RUN gem install --no-document bundler
RUN bundle install -j4 --retry 3 \
  && rm -rf /usr/local/bundle/cache/*.gem \
  && find /usr/local/bundle/gems/ -name "*.c" -delete \
  && find /usr/local/bundle/gems/ -name "*.o" -delete

# Add the Rails app
ADD . /app

WORKDIR /app

CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

我构建了我的应用程序:

docker-compose build --no-cache

任何帮助将不胜感激。

【问题讨论】:

    标签: ruby-on-rails docker mariadb amazon-rds amazon-ecs


    【解决方案1】:

    错误与数据库地址格式有关。

    为了使它工作,我删除了 http:// 前缀和结尾的 / 到 DB 地址环境变量。

    我变了:

    DB_HOST=http://abcdef-rds.xyz.ap-northeast-1.rds.amazonaws.com/
    
    

    到:

    DB_HOST=abcdef-rds.xyz.ap-northeast-1.rds.amazonaws.com
    

    【讨论】:

      猜你喜欢
      • 2021-08-29
      • 2020-03-07
      • 1970-01-01
      • 2021-01-24
      • 2021-04-09
      • 1970-01-01
      • 1970-01-01
      • 2013-02-04
      • 1970-01-01
      相关资源
      最近更新 更多