add support for testing with mysql in docker-compose.yml

This commit is contained in:
lovasoa
2022-09-03 14:35:42 +02:00
parent e854828393
commit cbc8b1bc4b
2 changed files with 16 additions and 6 deletions
+11 -6
View File
@@ -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
+5
View File
@@ -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")?;