Skip to content

Instantly share code, notes, and snippets.

View maxday's full-sized avatar
🦀

Maxime David maxday

🦀
View GitHub Profile
@maxday
maxday / how-to-test-println.rs
Created November 22, 2022 20:56
[RUST] How to test println?
// ❌ not testable
fn greeting_hard_to_test(nb: i32, name: &str) {
for _ in 0..nb {
println!("hi {}", name);
}
}
// ✅ easy to test
trait Logger {
fn log(&mut self, value: String);
@maxday
maxday / Dockerfile
Last active January 12, 2021 02:43
Build a Distroless image for Quarkus
FROM registry.access.redhat.com/ubi8/ubi-minimal as nativebuilder
RUN mkdir -p /tmp/ssl \
&& cp /usr/lib64/libstdc++.so.6.0.25 /tmp/ssl/libstdc++.so.6 \
&& cp /usr/lib64/libgcc_s-8-20191121.so.1 /tmp/ssl/libgcc_s.so.1 \
&& cp /usr/lib64/libz.so.1 /tmp/ssl/libz.so.1
FROM gcr.io/distroless/base
COPY --from=nativebuilder /tmp/ssl/ /
ENV LD_LIBRARY_PATH /
- name: Deploy
run: |
gcloud components install beta --quiet
gcloud beta run deploy ${{ secrets.GCP_APP_NAME }} \
--image gcr.io/${{ secrets.GCP_PROJECT }}/${{ secrets.GCP_APP_NAME }} \
--platform ${{ secrets.GCP_PLATFORM }} \
--allow-unauthenticated --service-account ${{ secrets.GCP_EMAIL }} \
--region ${{ secrets.GCP_REGION }} \
--set-env-vars DISABLE_SIGNAL_HANDLERS=1
- name: Login to GCP
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
service_account_email: ${{ secrets.GCP_EMAIL }}
service_account_key: ${{ secrets.GCP_ACCOUNT_KEY }}
project_id: ${{ secrets.GCP_PROJECT }}
export_default_credentials: true
- name: Push the Docker image to GCP
run: |
gcloud auth configure-docker --quiet
dockerize:
runs-on: ubuntu-latest
name: Embed the native executable in a Docker container
needs: native_build
steps:
- name: Checkout the code
uses: actions/checkout@master
- name: Download the binary
uses: actions/download-artifact@v1
with:
FROM quay.io/quarkus/centos-quarkus-maven:19.3.1-java8
USER root
COPY src /usr/src/app/src
COPY pom.xml /usr/src/app
RUN mvn -f /usr/src/app/pom.xml -Pnative clean verify
- name: Build native executable
uses: maxday/quarkus-native-build-docker-action@1
with:
outputName: app-runner
- name: Upload native executable
uses: actions/upload-artifact@v1
with:
name: native-executable
path: app-runner
on: [push]
jobs:
native_build:
runs-on: ubuntu-latest
name: Build native Quarkus app
steps:
- name: Checkout the code
uses: actions/checkout@master
@maxday
maxday / bootstrap-quarkus.sh
Last active March 22, 2020 19:00
Quickly bootstrap a sample Quarkus app
mvn io.quarkus:quarkus-maven-plugin:1.3.0.Final:create \
-DprojectGroupId=io.github.maxday \
-DprojectArtifactId=quarkus-demo-actions \
-DclassName="io.github.maxday.GreetingResource" \
-Dpath="/hello"
let groupQuery = [
{
$group: {
_id: { repo : "$repo", type: "$type" },
count: { $sum: 1 }
}
},
{
$sort: {
"count": -1