add support for testing with mysql in docker-compose.yml
This commit is contained in:
+11
-6
@@ -1,17 +1,22 @@
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
build: { context: ".", args: {SKIP_CHECK: 1}}
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- .:/var/www
|
||||
depends_on:
|
||||
- postgres
|
||||
- db
|
||||
environment:
|
||||
DATABASE_URL: postgres://postgres:secret@postgres
|
||||
postgres:
|
||||
DATABASE_URL: ${DB:-postgres}://root:secret@db/sqlpage
|
||||
db: # The DB environment variable can be set to "mariadb" or "postgres" to test the code with different databases
|
||||
ports:
|
||||
- "5432:5432"
|
||||
image: postgres
|
||||
- "3306:3306"
|
||||
image: ${DB:-postgres}
|
||||
environment:
|
||||
POSTGRES_PASSWORD: secret
|
||||
POSTGRES_USER: root
|
||||
POSTGRES_DB: sqlpage
|
||||
POSTGRES_PASSWORD: secret
|
||||
MYSQL_ROOT_PASSWORD: secret
|
||||
MYSQL_DATABASE: sqlpage
|
||||
@@ -174,6 +174,11 @@ pub async fn init_database(database_url: &str) -> anyhow::Result<Database> {
|
||||
log::LevelFilter::Warn,
|
||||
std::time::Duration::from_millis(250),
|
||||
);
|
||||
log::debug!(
|
||||
"Connecting to a {:?} database on {}",
|
||||
connect_options.kind(),
|
||||
database_url
|
||||
);
|
||||
let connection = AnyPool::connect_with(connect_options)
|
||||
.await
|
||||
.with_context(|| "Failed to connect to database")?;
|
||||
|
||||
Reference in New Issue
Block a user