After following the instructions to the best of my ability I got stuck when trying to test it.
I must say that instead of Postgres I stuck with MySQL.
My docker-compose file:
version: '3.3'
services:
my-app:
depends_on:
- mysql-test
build: .
environment:
- DATABASE_HOSTNAME=mysql-test
- DATABASE_PORT=3308
mysql-test:
image: "mysql/mysql-server:5.7"
environment:
- MYSQL_DATABASE=vapor-test
- MYSQL_USER=vapor
- MYSQL_PASSWORD=password
the db configuration excerpt from my configure.swift
if (env == .testing) {
databaseName = "vapor-test"
if let testPort = Environment.get("DATABASE_PORT") {
databasePort = Int(testPort) ?? 3308
} else {
databasePort = 3308
}
} else {
databaseName = "vapor"
databasePort = 3307
}
let hostname = Environment.get("DATABASE_HOSTNAME") ?? "localhost"
let databaseConfig = MySQLDatabaseConfig(hostname: hostname,
port: databasePort,
username: "vapor",
password: "password",
database: databaseName)
let database = MySQLDatabase(config: databaseConfig)
databases.add(database: database, as: .mysql)
services.register(databases)
The end resulting error is:
[ INFO ] Migrating 'mysql' database (/package/.build/checkouts/fluent.git-7321833952610167324/Sources/Fluent/Migration/MigrationConfig.swift:69)
my-app_1 | Fatal error: 'try!' expression unexpectedly raised an error: NIO.ChannelError.connectFailed(NIO.NIOConnectionError(host: "mysql-test", port: 3308, dnsAError: nil, dnsAAAAError: nil, connectionErrors: [NIO.SingleConnectionFailure(target: [IPv4]mysql-test:3308, error: connection reset (error set): Connection refused (errno: 111))])): file /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/swift/stdlib/public/core/ErrorType.swift, line 184
I’m running in a simple ubuntu machine with swift installed but since its sending everything into docker containers shouldn’t matter much.
Can you help understand what could be the issue?