diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6ae618a..b4e8ba3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Set up JDK uses: actions/setup-java@v2 with: @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Create GitHub release draft uses: release-drafter/release-drafter@v5 env: @@ -34,14 +34,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Set up JDK uses: actions/setup-java@v2 with: distribution: 'adopt' java-version: 11 - name: Login to GitHub Container Registry - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v1.12.0 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -52,16 +52,16 @@ jobs: run: sbt ';docker;dockerPush' - name: Remove image with UPX compressed executable run: docker rmi $(docker images -q 'ghcr.io/usommerl/graalnative4s*upx*') - - name: Tag remaining image for gcr.io + - name: Tag remaining image for Google Container Registry run: | export IMAGE_GHCR=$(docker images ghcr.io/usommerl/graalnative4s --format "{{.Repository}}:{{.Tag}}") export IMAGE_GCR=$(echo $IMAGE_GHCR | sed 's/ghcr.io\/usommerl/eu.gcr.io\/usommerl-02/') docker tag $IMAGE_GHCR $IMAGE_GCR echo "image_gcr=$IMAGE_GCR" >> $GITHUB_ENV - name: Login to Google Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v1.12.0 with: - registry: gcr.io + registry: eu.gcr.io username: _json_key password: ${{ secrets.GCP_SA_KEY_JSON }} - name: Push image to Google Container Registry diff --git a/.scalafmt.conf b/.scalafmt.conf index 5a991d0..c75d7aa 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.0.3" +version = "3.3.1" maxColumn = 140 align.preset = most diff --git a/Dockerfile b/Dockerfile index 684c8c7..ca16552 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/graalvm/graalvm-ce:java11-21.2.0 as builder +FROM ghcr.io/graalvm/graalvm-ce:java11-21.3.0 as builder ARG upx_compression ARG print_reports @@ -9,22 +9,19 @@ RUN curl -L https://www.scala-sbt.org/sbt-rpm.repo | tee /etc/yum.repos.d/sbt-rp # See: # - https://github.com/oracle/graal/issues/2824#issuecomment-685159371 # - https://github.com/oracle/graal/blob/vm-20.3.0/substratevm/StaticImages.md -ARG RESULT_LIB="/staticlibs" +ARG TOOLCHAIN_DIR="/toolchain" -RUN mkdir ${RESULT_LIB} && \ - curl -L -o musl.tar.gz https://musl.libc.org/releases/musl-1.2.2.tar.gz && \ - mkdir musl && tar -xvzf musl.tar.gz -C musl --strip-components 1 && cd musl && \ - ./configure --disable-shared --prefix=${RESULT_LIB} && \ - make && make install && \ - cd / && rm -rf /muscl && rm -f /musl.tar.gz && \ - cp /usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a ${RESULT_LIB}/lib/ +RUN mkdir ${TOOLCHAIN_DIR} && \ + curl -L -o musl.tar.gz https://more.musl.cc/10.2.1/x86_64-linux-musl/x86_64-linux-musl-native.tgz && \ + tar -xvzf musl.tar.gz -C ${TOOLCHAIN_DIR} --strip-components 1 && \ + rm -f /musl.tar.gz -ENV PATH="$PATH:${RESULT_LIB}/bin" -ENV CC="musl-gcc" +ENV PATH="$PATH:${TOOLCHAIN_DIR}/bin" +ENV CC="${TOOLCHAIN_DIR}/bin/gcc" RUN curl -L -o zlib.tar.gz https://zlib.net/zlib-1.2.11.tar.gz && \ mkdir zlib && tar -xvzf zlib.tar.gz -C zlib --strip-components 1 && cd zlib && \ - ./configure --static --prefix=${RESULT_LIB} && \ + ./configure --static --prefix=${TOOLCHAIN_DIR} && \ make && make install && \ cd / && rm -rf /zlib && rm -f /zlib.tar.gz #END INSTALL PRE-REQUISITES FOR STATIC NATIVE IMAGES WITH GRAAL >= 20.2.0 diff --git a/build.sbt b/build.sbt index 2139cfa..66f68c4 100644 --- a/build.sbt +++ b/build.sbt @@ -1,15 +1,15 @@ -ThisBuild / scalaVersion := "2.13.6" +ThisBuild / scalaVersion := "2.13.8" ThisBuild / organization := "dev.usommerl" -ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0" +ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0" val v = new { val circe = "0.14.1" - val ciris = "2.1.1" - val http4s = "0.23.3" - val odin = "0.12.0" - val tapir = "0.19.0-M8" + val ciris = "2.3.2" + val http4s = "0.23.7" + val odin = "0.13.0" + val tapir = "0.19.3" val munit = "0.7.29" - val munitCE = "1.0.5" + val munitCE = "1.0.7" } val upx = "UPX_COMPRESSION" diff --git a/project/build.properties b/project/build.properties index 10fd9ee..3161d21 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=1.6.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index 14f702d..3594faa 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,10 +1,10 @@ -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.30") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34") addSbtPlugin("com.alejandrohdezma" % "sbt-codecov" % "0.2.1") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1") +addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.7") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.8.2") -addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.8.2") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") +addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.8.3") diff --git a/src/main/resources/META-INF/native-image/native-image.properties b/src/main/resources/META-INF/native-image/native-image.properties index 66b26cb..4334749 100644 --- a/src/main/resources/META-INF/native-image/native-image.properties +++ b/src/main/resources/META-INF/native-image/native-image.properties @@ -5,7 +5,6 @@ Args = --verbose \ --libc=musl \ --enable-http \ --enable-https \ - --enable-all-security-services \ --report-unsupported-elements-at-runtime \ --initialize-at-build-time=scala.Symbol$ \ --allow-incomplete-classpath \ diff --git a/src/main/scala/app/Api.scala b/src/main/scala/app/Api.scala index bcddf0c..3303a9b 100644 --- a/src/main/scala/app/Api.scala +++ b/src/main/scala/app/Api.scala @@ -40,10 +40,9 @@ object Api { .servers(List(Server(config.serverUrl))) .tags(apis.map(_.tag)) - val swaggerUi = Http4sServerInterpreter().toRoutes(SwaggerUI[F](docs.toYaml)) - val redirectRootToDocs = HttpRoutes.of[F] { case path @ GET -> Root => PermanentRedirect(Location(path.uri / "docs")) } - - val routes: List[HttpRoutes[F]] = apis.map(_.routes) ++ List(swaggerUi, redirectRootToDocs) + val swaggerUi: HttpRoutes[F] = Http4sServerInterpreter().toRoutes(SwaggerUI[F](docs.toYaml)) + val redirectRootToDocs: HttpRoutes[F] = HttpRoutes.of[F] { case path @ GET -> Root => PermanentRedirect(Location(path.uri / "docs")) } + val routes: List[HttpRoutes[F]] = apis.map(_.routes) ++ List(swaggerUi, redirectRootToDocs) CORS.policy(routes.reduce(_ <+> _)).orNotFound } @@ -55,7 +54,7 @@ object Examples { override lazy val serverEndpoints = List(info, hello) type NonEmptyString = String Refined NonEmpty - private val info: ServerEndpoint[Unit, StatusCode, Info, Any, F] = + private val info: ServerEndpoint.Full[Unit, Unit, Unit, StatusCode, Info, Any, F] = endpoint.get .summary("Fetch general information about the application") .tag(tag.name) @@ -76,7 +75,7 @@ object Examples { ) ) - private val hello: ServerEndpoint[Option[NonEmptyString], StatusCode, String, Any, F] = + private val hello: ServerEndpoint.Full[Unit, Unit, Option[NonEmptyString], StatusCode, String, Any, F] = endpoint.get .summary("The infamous hello world endpoint") .tag(tag.name) @@ -100,7 +99,7 @@ object Examples { abstract class TapirApi[F[_]: Async] { def tag: Tag - def serverEndpoints: List[ServerEndpoint[_, _, _, Any, F]] - def endpoints: List[Endpoint[_, _, _, _]] = serverEndpoints.map(_.endpoint) - def routes: HttpRoutes[F] = Http4sServerInterpreter().toRoutes(serverEndpoints) + def serverEndpoints: List[ServerEndpoint[Any, F]] + def endpoints: List[Endpoint[_, _, _, _, _]] = serverEndpoints.map(_.endpoint) + def routes: HttpRoutes[F] = Http4sServerInterpreter().toRoutes(serverEndpoints) }