Skip to content

Commit

Permalink
add staging configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
rochala committed Nov 24, 2022
1 parent ef463cf commit 259e3b4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion deployment/local.conf
Expand Up @@ -29,5 +29,5 @@ akka.remote.artery.canonical {

scastie.metals {
production = true
cache-expire-in-seconds = 180
cache-expire-in-seconds = 300
}
32 changes: 32 additions & 0 deletions deployment/staging.conf
@@ -0,0 +1,32 @@
com.olegych.scastie {
production = true
balancer {
snippets-container = mongo

remote-hostname = "scastie-dev.scala-lang.org"

remote-sbt-ports-start = 5150
remote-sbt-ports-size = 1
}
web {
oauth2 {
users-file = /home/scastie/users.txt
sessions-file = /home/scastie/sessions.json
}
}
}

com.olegych.scastie.web {
hostname = "scastie-dev.scala-lang.org"
akka-port = 15000
}

akka.remote.artery.canonical {
hostname = "scastie-dev.scala-lang.org"
port = 15000
}

scastie.metals {
production = true
cache-expire-in-seconds = 300
}
15 changes: 11 additions & 4 deletions project/Deployment.scala
Expand Up @@ -17,6 +17,7 @@ import sys.process._
object Deployment {
def settings(server: Project, sbtRunner: Project, metalsRunner: Project): Seq[Def.Setting[Task[Unit]]] = Seq(
deploy := deployTask(server, sbtRunner, metalsRunner).value,
deployStaging := deployTask(server, sbtRunner, metalsRunner, true).value,
deployServer := deployServerTask(server, sbtRunner).value,
deployQuick := deployQuickTask(server, sbtRunner, metalsRunner).value,
deployServerQuick := deployServerQuickTask(server, sbtRunner, metalsRunner).value,
Expand All @@ -25,6 +26,8 @@ object Deployment {

lazy val deploy = taskKey[Unit]("Deploy server and sbt instances")

lazy val deployStaging = taskKey[Unit]("Deploy server and sbt instances with staging configuration")

lazy val deployServer = taskKey[Unit]("Deploy server")

lazy val deployLocal = taskKey[Unit]("Deploy locally")
Expand Down Expand Up @@ -55,7 +58,7 @@ object Deployment {
deployment.deployLocal(serverZip, metalsServerZip)
}

def deployTask(server: Project, sbtRunner: Project, metalsRunner: Project): Def.Initialize[Task[Unit]] =
def deployTask(server: Project, sbtRunner: Project, metalsRunner: Project, staging: Boolean = false): Def.Initialize[Task[Unit]] =
Def.task {
val deployment = deploymentTask(sbtRunner).value
val serverZip = (server / Universal / packageBin).value.toPath
Expand Down Expand Up @@ -91,14 +94,16 @@ object Deployment {
}

private def deploymentTask(
sbtRunner: Project
sbtRunner: Project,
staging: Boolean = false,
): Def.Initialize[Task[Deployment]] =
Def.task {
new Deployment(
rootFolder = (ThisBuild / baseDirectory).value,
version = version.value,
sbtDockerImage = (sbtRunner / docker / imageNames).value.head,
logger = streams.value.log
logger = streams.value.log,
staging = staging
)
}

Expand All @@ -111,7 +116,7 @@ object Deployment {
}
}

class Deployment(rootFolder: File, version: String, sbtDockerImage: ImageName, val logger: Logger) {
class Deployment(rootFolder: File, version: String, sbtDockerImage: ImageName, val logger: Logger, staging: Boolean) {
def deploy(serverZip: Path, metalsServerZip: Path): Unit = {
deployRunners()
deployServer(serverZip)
Expand Down Expand Up @@ -262,6 +267,7 @@ class Deployment(rootFolder: File, version: String, sbtDockerImage: ImageName, v
val metalsRunnerScript = destination.resolve("metalsRunner.sh")
val config =
if (local) localConfig
else if (staging) stagingConfig
else productionConfig

val configFileName = config.getFileName
Expand Down Expand Up @@ -430,6 +436,7 @@ class Deployment(rootFolder: File, version: String, sbtDockerImage: ImageName, v

private val productionConfig = (deploymentFolder / "production.conf").toPath
private val localConfig = (deploymentFolder / "local.conf").toPath
private val stagingConfig = (deploymentFolder / "staging.conf").toPath

private val logbackConfig = (deploymentFolder / "logback.xml").toPath

Expand Down

0 comments on commit 259e3b4

Please sign in to comment.