Hi there
Thanks in advance!!
I phối up rails application with rails 6, docker, and AWS Mysql RDS.
When I execute the command lượt thích rails db:migrate
It will migrate necessary tables and columns into the database
but at the last, it will raise errors like
"rails aborted!"
"Mysql2::Error::ConnectionError: Can't connect to tướng local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"
due to tướng that codebuild is not passing
I have already specifics the socket tệp tin path into database.yml
but it's won't working at all.
I install mysql_client, default-libmysqlclient-dev ,
i tried to tướng override /etc/mysql/my.cnf configuration but it won't work at all
database.yml
default: &default
adapter: mysql2
encoding: utf8mb4
charset: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: "root"
password: ""
host: localhost
#socket: '/tmp/mysql.sock
development:
<<: *default
staging:
adapter: mysql2
encoding: utf8mb4
charset: utf8mb4
host: ****RDSHOST************
database: ****database************
username: ****RDSusername******
password: ****RDSPASSWORD******
socket: '/tmp/mysql.sock'
test:
<<: *default
database: wishealth_test
production:
<<: *default
database: <%= ENV.fetch('DB_DATABASE', '') %>
username: <%= ENV.fetch("DB_USER", "root") %>
password: <%= ENV.fetch("DB_PASSWORD", "") %>
host: <%= ENV.fetch('DB_HOSTNAME', '') %>
port: <%= ENV.fetch('DB_PORT', 3306) %>
Dockerfile
FROM phusion/passenger-ruby27:1.0.11
ENV RAILS_ENV staging
ARG STRIPE_API_KEY
ARG SECRET_KEY_BASE
CMD ["/sbin/my_init"]
# Using Nginx and Passenger
RUN rm -f /etc/service/nginx/down
RUN rm /etc/nginx/sites-enabled/default
ADD docker/stg/nginx/nginx.conf /etc/nginx/sites-enabled/webapp.conf
RUN bash -lc 'rvm --default use ruby-2.7.1'
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -yqq && apt-get install -yqq nodejs\
build-essential yarn locales locales-all \
mysql-client \
default-libmysqlclient-dev \
&& apt-get clean openssh-server \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y \
tzdata
ENV TZ=Asia/Tokyo
ADD docker/stg/nginx/mysql.cnf /etc/mysql/my.cnf
## shared mime info for mimemagic
RUN curl -sL -o shared-mime-info_1.9-2_amd64.deb http://mirrors.kernel.org/ubuntu/pool/main/s/shared-mime-info/shared-mime-info_1.9-2_amd64.deb
# RUN dpkg -P --force-all shared-mime-info
RUN dpkg --install shared-mime-info_1.9-2_amd64.deb
RUN gem install bundler -v 2.1.4
#WORKDIR /wishealth-stg
#RUN chmod u+x /wishealth-stg
WORKDIR /home/app/wishealth-stg
COPY --chown=app:app . .
COPY Gemfile Gemfile.lock ./
RUN bundle config build.nokogiri --use-system-libraries
RUN gem install bundler
ENV BUNDLE_PATH /gems
RUN bundle install
COPY package.json yarn.lock ./
#RUN yarn install --check-files
RUN bundle exec rails db:migrate RAILS_ENV=staging
RUN bundle exec rake assets:precompile 'environment=staging'
RUN RAILS_ENV=staging bundle exec rake assets:clean 'environment=staging'
# Docker is handle Log and send it to tướng cloudwatch - START
ENV RAILS_LOG_TO_STDOUT enabled
ENV RAILS_SERVE_STATIC_FILES enabled
# Docker is handle Log and send it to tướng cloudwatch - END
RUN chmod -R go+w ./tmp
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
EXPOSE 80
mysql.cnf
[client]
socket= /tmp/mysql.sock
can anyone let bu know what should i vì thế next to tướng fix this error