Merge branch 'cicd'
Some checks failed
ci / docker (push) Has been cancelled

This commit is contained in:
Frank Villaro-Dixon 2024-10-13 01:24:02 +02:00
commit f781a392de
4 changed files with 37 additions and 9 deletions

View file

@ -0,0 +1,31 @@
name: ci
on:
push:
branches:
- "cicd"
- main
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: forge.k3s.fr
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: forge.k3s.fr/elevation-api-eu/server:latest

View file

@ -37,7 +37,7 @@ impl DatasetRepository {
info!("Will open {full_filename} because not in cache!"); info!("Will open {full_filename} because not in cache!");
let ds = Dataset::open(full_filename.clone()); let ds = Dataset::open(full_filename.clone());
match ds { match ds {
Err(x) => { Err(_) => {
error!("File not present"); error!("File not present");
return None; return None;
} }

View file

@ -10,7 +10,7 @@ use axum::{
use axum_macros::debug_handler; use axum_macros::debug_handler;
use std::env; use std::env;
use serde::ser::{SerializeSeq, Serializer}; use serde::ser::SerializeSeq;
use serde::{Deserialize, Deserializer, Serialize}; use serde::{Deserialize, Deserializer, Serialize};
use serde_qs::axum::{QsQueryConfig, QsQueryRejection}; use serde_qs::axum::{QsQueryConfig, QsQueryRejection};
use tower_http::trace::TraceLayer; use tower_http::trace::TraceLayer;
@ -105,8 +105,8 @@ async fn main() {
.with_state(cache) .with_state(cache)
.layer( .layer(
TraceLayer::new_for_http() TraceLayer::new_for_http()
.make_span_with(trace::DefaultMakeSpan::new().level(Level::DEBUG)) .make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO))
.on_response(trace::DefaultOnResponse::new().level(Level::DEBUG)), .on_response(trace::DefaultOnResponse::new().level(Level::INFO)),
) )
.layer(Extension(QsQueryConfig::new(5, false).error_handler( .layer(Extension(QsQueryConfig::new(5, false).error_handler(
|err| { |err| {
@ -130,9 +130,6 @@ async fn get_elevation(
query_opts: Query<Opts>, query_opts: Query<Opts>,
Path((lat, lon)): Path<(f64, f64)>, Path((lat, lon)): Path<(f64, f64)>,
) -> Response { ) -> Response {
println!("lat: {}, lon: {}", lat, lon);
println!("query_opts: {:?}", query_opts);
let ele; let ele;
match dem::elevation_from_coordinates(&dsr, lat, lon).await { match dem::elevation_from_coordinates(&dsr, lat, lon).await {
Ok(x) => match x { Ok(x) => match x {
@ -147,7 +144,7 @@ async fn get_elevation(
#[derive(Serialize)] #[derive(Serialize)]
struct Ele { struct Ele {
elevation: f64, elevation: f64,
}; }
if query_opts.json { if query_opts.json {
let r = Ele { elevation: ele }; let r = Ele { elevation: ele };