Skip to content

Commit

Permalink
chore(build): attempt to build docker images in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
updraft0 committed Apr 18, 2024
1 parent ee38398 commit 4c98ce3
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 11 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release
on:
push:
branches:
- main
jobs:
build-server:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'sbt'
- name: Build and Test
run: sbt server/docker:publish
build-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui/
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v2
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'sbt'
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
cache-dependency-path: './ui'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Push to container registry
uses: docker/build-push-action@v5
with:
context: dist/
file: "Dockerfile.nginx"
tags: controltower-fe:latest
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
15 changes: 14 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,24 @@ lazy val protocol =

lazy val server = project
.in(file("server"))
.enablePlugins(JavaAppPackaging)
.enablePlugins(DockerPlugin)
.settings(
commonSettings,
Seq(
libraryDependencies ++= jwt ++ tapir ++ `tapir-zio-json` ++ `tapir-server`,
libraryDependencies ++= zio ++ `zio-config` ++ `zio-test`
libraryDependencies ++= zio ++ `zio-config` ++ `zio-test`,
// docker packaging
Docker / packageName := "controltower",
Docker / defaultLinuxInstallLocation := "/app",
dockerEnvVars := Map(
"CT_DB_PATH" -> "/app/db"
),
dockerExposedVolumes := Seq("/app/db"),
dockerBaseImage := "ghcr.io/graalvm/graalvm-community:22.0.1",
dockerExposedPorts := Seq(8092),
dockerRepository := Some("ghcr.io"),
dockerUsername := Some("updraft0")
)
)
.dependsOn(protocol.jvm, db, `esi-client`, `mini-reactive`)
Expand Down
5 changes: 4 additions & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import sbt.Keys.libraryDependencies
object Dependencies {

object Versions {
val brotli = "1.16.0"
val flyway = "9.21.1"
val jsoniter = "2.28.4"
val jwt = "10.0.0"
Expand Down Expand Up @@ -72,7 +73,9 @@ object Dependencies {
)

val `tapir-server` = Seq(
"com.softwaremill.sttp.tapir" %% "tapir-zio-http-server" % Versions.tapir
"com.softwaremill.sttp.tapir" %% "tapir-zio-http-server" % Versions.tapir,
// runtime
"com.aayushatharva.brotli4j" % "brotli4j" % Versions.brotli % Runtime
)

val zio = Seq(
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml"
addDependencyTreePlugin
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
4 changes: 4 additions & 0 deletions server/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ control-tower {
protocol: "http"
protocol: ${?CT_HTTP_PROTO}

# listen hostname (for socket binding)
listen-host: "0.0.0.0"
listen-host: ${?CT_HTTP_LISTEN_HOST}

# hostname (will be used with the ESI callback and for UI configuration as well)
host: "localhost"
host: ${?CT_HTTP_HOST}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ case class EsiAuthConfig(
)
case class HmacSecret(value: zio.Config.Secret)
case class AuthConfig(secret: HmacSecret, esi: EsiAuthConfig, esiCallbackSecret: HmacSecret, sessionExpiry: Duration)
case class HttpConfig(protocol: String, host: String, port: Int, uiPort: Int)
case class HttpConfig(protocol: String, host: String, listenHost: String, port: Int, uiPort: Int)

case class EsiConfig(base: Uri)
case class SdeConfig(base: Uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.updraft0.controltower.db
import org.updraft0.esi.client.{EsiClient, SdeClient}
import org.updraft0.minireactive.MiniReactive
import sttp.client3.UriContext
import sttp.model.headers.Origin
import sttp.tapir.server.interceptor.cors.*
import sttp.tapir.server.ziohttp.{ZioHttpInterpreter, ZioHttpServerOptions}
import zio.http.{HttpApp, Server as ZServer}
Expand Down Expand Up @@ -72,12 +71,7 @@ object Server extends ZIOAppDefault:
private def httpApp: HttpApp[EndpointEnv] =
ZioHttpInterpreter(
ZioHttpServerOptions.customiseInterceptors
.corsInterceptor(
CORSInterceptor.customOrThrow(
// FIXME - do we need this? Don't think so
CORSConfig.default.allowCredentials.allowOrigin(Origin.Host("http", "localhost", Some(5173)))
)
)
.corsInterceptor(CORSInterceptor.default)
.options
)
.toHttp(
Expand Down
2 changes: 2 additions & 0 deletions ui/Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM docker.io/library/nginx:1-alpine-otel
COPY dist/* /usr/share/nginx/html

0 comments on commit 4c98ce3

Please # to comment.