From eb38c2acd36a28ce25b1dafcb85555a1f1a9b29c Mon Sep 17 00:00:00 2001 From: jczuchnowski Date: Sun, 29 May 2022 20:13:47 +0200 Subject: [PATCH] Remove old infrastructure related sbt functions --- build.sbt | 25 ---------------- docker-compose.yml | 45 ---------------------------- project/InfrastructureHelper.scala | 47 ------------------------------ 3 files changed, 117 deletions(-) delete mode 100644 docker-compose.yml delete mode 100644 project/InfrastructureHelper.scala diff --git a/build.sbt b/build.sbt index a321d57f0..5c93dca58 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,4 @@ import BuildHelper._ -import InfrastructureHelper._ import explicitdeps.ExplicitDepsPlugin.autoImport.moduleFilterRemoveValue import sbtcrossproject.CrossPlugin.autoImport.crossProject @@ -29,30 +28,6 @@ val zioSchemaVersion = "0.1.9" val testcontainersVersion = "1.17.2" val testcontainersScalaVersion = "0.40.7" -lazy val startPostgres = taskKey[Unit]("Start up Postgres") -startPostgres := startService(Database.Postgres, streams.value) - -lazy val stopPostgres = taskKey[Unit]("Shut down Postgres") -stopPostgres := stopService(Database.Postgres, streams.value) - -lazy val startMySQL = taskKey[Unit]("Start up MySQL") -startMySQL := startService(Database.MySQL, streams.value) - -lazy val stopMySQL = taskKey[Unit]("Shut down MySQL") -stopMySQL := stopService(Database.MySQL, streams.value) - -lazy val startMsSQL = taskKey[Unit]("Start up Microsoft SQL Server") -startMsSQL := startService(Database.MSSQL, streams.value) - -lazy val stopMsSQL = taskKey[Unit]("Shut down Microsoft SQL Server") -stopMsSQL := stopService(Database.MSSQL, streams.value) - -lazy val startOracle = taskKey[Unit]("Start up Oracle") -startOracle := startService(Database.Oracle, streams.value) - -lazy val stopOracle = taskKey[Unit]("Shut down Oracle") -stopOracle := stopService(Database.Oracle, streams.value) - lazy val root = project .in(file(".")) .settings( diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 4c0dcf500..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3.1' - -services: - postgres: - image: postgres:12 - restart: always - environment: - POSTGRES_USER: zio_user - POSTGRES_PASSWORD: zio_pw - ports: - - "5432:5432" - - mysql: - image: mysql:8 - restart: always - environment: - MYSQL_USER: zio_user - MYSQL_PASSWORD: zio_pw - MYSQL_ROOT_PASSWORD: zio_pw - ports: - - "3306:3306" - - mssql: - image: mcr.microsoft.com/mssql/server:2019-latest - restart: always - environment: - ACCEPT_EULA: Y - SA_PASSWORD: zio_pw123ABC! - MSSQL_PID: Developer - ports: - - "1433:1433" - # Username: sa - - oracle: - image: oracleinanutshell/oracle-xe-11g - restart: always - environment: - ORACLE_ALLOW_REMOTE: 'true' - ORACLE_DISABLE_ASYNCH_IO: 'true' - ports: - - "1521:1521" - - "5500:5500" - # SID: XE - # Username: system - # Password: oracle \ No newline at end of file diff --git a/project/InfrastructureHelper.scala b/project/InfrastructureHelper.scala deleted file mode 100644 index 383a8dc9c..000000000 --- a/project/InfrastructureHelper.scala +++ /dev/null @@ -1,47 +0,0 @@ -import sbt.Keys.TaskStreams - -import scala.sys.process._ - -object InfrastructureHelper { - - sealed trait Database { self => - - // must align with the service name in docker-compose.yaml - def name: String = self match { - case Database.Postgres => "postgres" - case Database.MySQL => "mysql" - case Database.MSSQL => "mssql" - case Database.Oracle => "oracle" - } - - def port: Int = self match { - case Database.Postgres => 5432 - case Database.MySQL => 3306 - case Database.MSSQL => 1433 - case Database.Oracle => 1521 - } - } - - object Database { - case object Postgres extends Database - case object MySQL extends Database - case object MSSQL extends Database - case object Oracle extends Database - } - - val shell: Seq[String] = - if (sys.props("os.name").contains("Windows")) Vector("cmd", "/c") - else Vector("bash", "-c") - - def startService(db: Database, s: TaskStreams): Unit = { - val dockerComposeUp = shell :+ s"docker-compose up -d ${db.name}" - if (dockerComposeUp.! == 0) s.log.success(s"${db.name} started on port ${db.port}") - else s.log.error(s"${db.name} was not able to start up") - } - - def stopService(db: Database, s: TaskStreams): Unit = { - val dockerComposeDown = shell :+ s"docker-compose stop ${db.name}" - if (dockerComposeDown.! == 0) s.log.success(s"${db.name} was stopped") - else s.log.error(s"${db.name} was not able to shut down properly") - } -}