Giter VIP home page Giter VIP logo

graalnative4s's Introduction

graalnative4s

build codecov Scala Steward badge

This is a showcase for a combination of purely functional Scala libraries that can be used with GraalVM native-image without much effort. It employs http4s for general server functionality, circe for JSON processing, ciris to load runtime configuration, tapir to describe HTTP endpoints and odin for logging. Applications that were built with native-image have beneficial properties such as a lower memory footprint and fast startup. This makes them suitable for serverless applications.

Build

Use sbt docker to build a docker image with the native image binary. You don't need to install anything besides docker and sbt, the build process downloads all required GraalVM tooling. The created image will be as minimal as possible by using a multi-stage build.

You can create an even smaller image by utilizing UPX compression. Use the UPX_COMPRESSION environment variable at build time to specify the compression level. Please note that while this reduces the size of the image significantly it also has an impact on startup performance and memory consumption.

Example: export UPX_COMPRESSION="--best"; sbt docker

Deploy

This repository contains a workflow that will deploy the created image to Google Cloud Run. You could also use the button below to deploy it to your own GCP account.

Run on Google Cloud

Try

The most recent version of this small example is online here: https://graalnative4s.usommerl.dev

Acknowledgements & Participation

I have taken a lot of inspiration and knowledge from this blog post by James Ward. You should check out his hello-uzhttp example. Another project that helped me to connect the dots regarding native-image configuration was vasilmkd/docker-stats-monitor. Suggestions and contributions to this repository are welcome!

graalnative4s's People

Contributors

usommerl avatar scala-steward avatar mergify[bot] avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.