将 Docker Rails 6 应用程序部署到 AWS ECS 时出现 RDS 相关错误
RDS related error when deploying a Docker Rails 6 app to AWS ECS
我正在尝试将 Rails 6 应用程序部署到 AWS ECS。
部署失败,出现以下错误:
health_check failed: Plugin http could not be loaded: Error loading
shared library lib/mariadb/plugin/http.so: No such file or directory
Gemfile
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。
You may need to install a package such as libmariadb-dev, libmysqlclient-dev, mysql-devel, or default-libmysqlclient-dev; refer to your distribution's package guide to find the particular package. The most common issue we see is a user who has the library file libmysqlclient.so but is missing the header file mysql.h -- double check that you have the -dev packages installed.
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
任何帮助将不胜感激。
错误与数据库地址格式有关。
为了让它工作,我删除了 http://
前缀和尾随 /
到数据库地址环境变量。
我改了:
DB_HOST=http://abcdef-rds.xyz.ap-northeast-1.rds.amazonaws.com/
至:
DB_HOST=abcdef-rds.xyz.ap-northeast-1.rds.amazonaws.com
我正在尝试将 Rails 6 应用程序部署到 AWS ECS。
部署失败,出现以下错误:
health_check failed: Plugin http could not be loaded: Error loading shared library lib/mariadb/plugin/http.so: No such file or directory
Gemfile
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。
You may need to install a package such as libmariadb-dev, libmysqlclient-dev, mysql-devel, or default-libmysqlclient-dev; refer to your distribution's package guide to find the particular package. The most common issue we see is a user who has the library file libmysqlclient.so but is missing the header file mysql.h -- double check that you have the -dev packages installed.
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
任何帮助将不胜感激。
错误与数据库地址格式有关。
为了让它工作,我删除了 http://
前缀和尾随 /
到数据库地址环境变量。
我改了:
DB_HOST=http://abcdef-rds.xyz.ap-northeast-1.rds.amazonaws.com/
至:
DB_HOST=abcdef-rds.xyz.ap-northeast-1.rds.amazonaws.com