[英]How to change docker compose for Rails and MySql2?
I have an ancient (like 2012) Ruby on Rails server that uses MySql2 database.我在使用 MySql2 数据库的 Rails 服务器上有一个古老的(如 2012 年)Ruby。 The server, of course, is not made by me so I now have to find out how even launch it.
服务器当然不是我做的,所以我现在必须弄清楚它是如何启动的。 And I want to use Docker for that.
我想为此使用 Docker 。
I found this guide to setup Docker container for Rails and PostgreSQL database.我找到了为 Rails 和 PostgreSQL 数据库设置 Docker 容器的指南。 So, what do I have to change here to run it with MySql2?
那么,我必须在这里更改什么才能使用 MySql2 运行它?
Here is my RoR server's database setup:这是我的 RoR 服务器的数据库设置:
adapter: mysql2
encoding: utf8
database: g_development
pool: 5
username: notactualusername
password: notactualpassword
This is a line from Dockerfile in the tutorial that installs and updates all the stuff这是安装和更新所有东西的教程中 Dockerfile 中的一行
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
I need to change postgresql to mysql2, right?我需要将 postgresql 更改为 mysql2,对吗?
This is from tutorial docker-compose这是来自教程 docker-compose
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
So, is MySql2 image just called mysql2?那么,MySql2 镜像是不是就叫 mysql2 呢? Is the password variable called MYSQL2_PASSWORD or something else?
密码变量是否称为 MYSQL2_PASSWORD 或其他名称?
This is also from tutorial (initialization): docker compose run --no-deps web rails new. --force --database=postgresql
这也来自教程(初始化):
docker compose run --no-deps web rails new. --force --database=postgresql
docker compose run --no-deps web rails new. --force --database=postgresql
I guess changing here postgresql to mysql2?我想这里把postgresql改成mysql2? Do I actually need to run
rails new.
我真的需要运行
rails new.
since I already have a server built?因为我已经建好了服务器?
If you want to use mysql
, you need change database.yml
如果要使用
mysql
,则需要更改database.yml
Don't forget run xampp
不要忘记运行
xampp
I use Ubuntu Linux
我使用
Ubuntu Linux
default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: <%= ENV['USERNAME']%>
password: <%= ENV['PAASSWORD']%>
socket: /opt/lampp/var/mysql/mysql.sock // run xampp
host: <%= ENV["DB_HOST"]%>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.