How to containerize a rust warp app

I wrote this arti warp server for running whois via TOR network, Arti is CLI tool which has arti_client library inside for connecting the network, my main target to dockerize this for easy deploy to koyeb.com I used docker init to create Dockerfile and others and changed the implementation little bit because of some special dependencies ARG RUST_VERSION=1.82.0 ARG APP_NAME=arti_whois FROM rust:${RUST_VERSION}-alpine AS build ARG APP_NAME WORKDIR /app # Install host build dependencies. RUN apk add --no-cache clang lld musl-dev git openssl-dev openssl libssl3 libcrypto3 libgcrypt openssl-libs-static ca-certificates RUN --mount=type=bind,source=src,target=src \ --mount=type=bind,source=Cargo.toml,target=Cargo.toml \ --mount=type=bind,source=Cargo.lock,target=Cargo.lock \ --mount=type=cache,target=/app/target/ \ --mount=type=cache,target=/usr/local/cargo/git/db \ --mount=type=cache,target=/usr/local/cargo/registry/ \ cargo build --locked --release && \ cp ./target/release/$APP_NAME /bin/server FROM alpine:3.18 AS final USER root COPY --from=build /bin/server /bin/ EXPOSE 8016 ENV RUST_BACKTRACE=1 ENV RUST_LOG=debug CMD ["/bin/server"] apk add part took a while to figure out because on every run, compile was failing with different error, I needed to install all the dev lib dependencies to the alpine linux 2. Test with docker compose up --build until everything is fine. I was using curl for testing the app curl "localhost:8016/whois?ip=1.1.1.1" -v 3. Than docker push ozkanpakdil/arti_whois to push it to docker repository ...

December 23, 2024 · 1 min · Özkan Pakdil

JetBrains developer stats of 2024

Here is a summary of JetBrains developer stats of 2024. Java and Javascript are going down and Typescript and Rust are going up most used lang %61 javascript Unexpectedly WebAssembly is growing strong Most popular db is MySql and second PostgresSQL 🥳 ...

December 23, 2024 · 1 min · Özkan Pakdil

How to generate a Aurora Postgresql cluster with all auto explain enabled

PostgreSQL has query execution plans configured as extension, meaning they do not come out of the box we need to configure it, For on-prem or owning server you can check this link which tells how to configure it. Problem is there are so many steps. And it is confusing for AWS Aurora I wrote a small bash script Here just to make this work automatic. Here is powershell version SubnetGroupName -> AWS subnet name for connecting which has all the configuration ready $psqlPath = “C:\tools\postgresql-16.6-2\pgsql\bin\psql.exe” -> user should have psql in the machine and change the path accordingly Before starting it, user should have aws secret and keys defined in their env variables, explained here After successful execution you should see the test cluster like below, and you can check logs to see how execution plans are created. ...

December 11, 2024 · 1 min · Özkan Pakdil

HashMap collisions and how JDK handles it

I was thinking on this question How does HashMap handle collisions internally? What changes were introduced in Java 8 for its implementation? and reading this blog says On a final note, from Java 8, the linked lists are dynamically replaced with balanced binary search trees in collision resolution after the number of collisions in a given bucket location exceed a certain threshold. Than I wonder how it works and went and found the source code of hash map in openjdk. It is a very long class, almost 2600 lines, but so many comments 🤓 it is not very common to see this much comment in a java code, anyway then I start reading it and wanted to note down how it behaves on collusion ...

November 27, 2024 · 3 min · Özkan Pakdil

FFM (Foreign Function and Memory) Stdlib Example

FFM is the new API trying to replace JNI and jep is here It is basically calling functions outside of JVM or accessing memory not managed by JVM. I wanted to test can FFM beat regular Java API, below you can find a simple test doing math sin with FFM and with regular Math.sin import java.lang.foreign.FunctionDescriptor; import java.lang.foreign.Linker; import java.lang.foreign.MemorySegment; import java.lang.foreign.SymbolLookup; import java.lang.foreign.ValueLayout; public class FFMSinTest { public static void main(String[] args) throws Throwable { Linker linker = Linker.nativeLinker(); SymbolLookup stdlib = linker.defaultLookup(); // Locate the "sin" function in the C math library MemorySegment sinAddress = stdlib.find("sin").orElseThrow(); FunctionDescriptor descriptor = FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.JAVA_DOUBLE); var sinHandle = linker.downcallHandle(sinAddress, descriptor); double angle = Math.PI / 4; // 45 degrees in radians // Timing Java's Math.sin() long javaStartTime = System.nanoTime(); for (int i = 0; i < 1_000_000; i++) { double result = Math.sin(angle); } long javaEndTime = System.nanoTime(); long javaDuration = javaEndTime - javaStartTime; // Timing C sin via FFM long ffmStartTime = System.nanoTime(); for (int i = 0; i < 1_000_000; i++) { double result = (double) sinHandle.invoke(angle); } long ffmEndTime = System.nanoTime(); long ffmDuration = ffmEndTime - ffmStartTime; System.out.println("Java Math.sin() took: " + javaDuration / 1_000_000.0 + " ms"); System.out.println("C sin (FFM) took: " + ffmDuration / 1_000_000.0 + " ms"); } } And result is ...

November 11, 2024 · 2 min · Özkan Pakdil