Skip to content

Commit 8eb3501

Browse files
ci: use distroless images
Signed-off-by: Henry <mail@henrygressmann.de>
1 parent 78a8423 commit 8eb3501

File tree

8 files changed

+49
-117
lines changed

8 files changed

+49
-117
lines changed

.github/workflows/container.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,23 @@ jobs:
4949
registry: ghcr.io
5050
username: ${{ github.actor }}
5151
password: ${{ secrets.GITHUB_TOKEN }}
52+
- name: Download liwan binaries
53+
run: |
54+
mkdir -p dist
55+
56+
curl -fsSL https://github.com/explodingcamera/liwan/releases/download/${{ inputs.tag }}/liwan-x86_64-unknown-linux-musl.tar.gz \
57+
| tar -xz -C dist --strip-components=1 &
58+
59+
curl -fsSL https://github.com/explodingcamera/liwan/releases/download/${{ inputs.tag }}/liwan-aarch64-unknown-linux-musl.tar.gz \
60+
| tar -xz -C dist/arm64 --strip-components=1 &
61+
62+
wait
5263
- name: Build and push Docker images
53-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # @v6
64+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
5465
with:
5566
context: .
5667
file: ./scripts/Dockerfile
5768
push: true
69+
platforms: linux/amd64,linux/arm64
5870
tags: ${{ steps.meta.outputs.tags }}
5971
labels: ${{ steps.meta.outputs.labels }}
60-
platforms: |
61-
linux/amd64
62-
linux/arm64
63-
build-args: |
64-
TAR_URL_AMD64=https://github.com/explodingcamera/liwan/releases/download/${{ inputs.tag }}/liwan-x86_64-unknown-linux-musl.tar.gz
65-
TAR_URL_ARM64=https://github.com/explodingcamera/liwan/releases/download/${{ inputs.tag }}/liwan-aarch64-unknown-linux-musl.tar.gz

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ The format is roughly based on the output of `git-cliff` and this project adhere
1616
Since this is not a library, this changelog focuses on the changes that are relevant to the end-users. For a detailed list of changes, see the commit history, which adheres to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). New releases are created automatically when a new tag is pushed (Commit message: chore(release): vX.X.X).
1717
-->
1818

19+
## Unreleased
20+
21+
- GeoIP database now automatically reloads if it has been updated on disk
22+
- Docker image is now based on `distroless`
23+
- Switched to using `axum` as the web framework and `ua-parser` for user-agent parsing
24+
1925
## [v1.3.0] - 2025-10-12
2026

2127
- Updated to the latest version of DuckDB (1.4)

Cargo.lock

Lines changed: 6 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ async-compression={version="0.4", default-features=false, features=["gzip", "tok
3232
tokio-tar={package="astral-tokio-tar", version="0.5"}
3333
sha3={version="0.10"}
3434
argon2={version="0.5", features=["rand"]}
35-
password-hash={version="0.5", features=["rand_core", "getrandom"]}
35+
password-hash={version="0.5", features=["rand_core", "getrandom"]} # required for getrandom feature
3636
zstd={version="0.13", default-features=false}
37-
uuid={version="1.19", features=["v4"]}
3837

3938
# general
4039
argh={version="0.1", default-features=false, features=["help"]}
@@ -47,7 +46,14 @@ tracing-subscriber={version="0.3", features=["env-filter"]}
4746
ahash="0.8"
4847

4948
# web
50-
axum={version="0.8", features=["macros"]}
49+
axum={version="0.8", default-features=false, features=[
50+
"http1",
51+
"tokio",
52+
"json",
53+
"matched-path",
54+
"original-uri",
55+
"query",
56+
]}
5157
axum-extra={version="0.12", default-features=false, features=["cookie", "typed-header"]}
5258
http="1.4"
5359
headers="0.4"
@@ -61,13 +67,9 @@ tower_governor={version="0.8", default-features=false, features=["axum"]}
6167
aide={version="0.16.0-alpha.2", default-features=false, features=[
6268
"axum",
6369
"axum-json",
64-
"axum-query",
6570
"axum-matched-path",
66-
"axum-tokio",
67-
"axum-extra",
6871
"axum-extra-cookie",
6972
"axum-extra-headers",
70-
"macros",
7173
]}
7274
schemars={version="1.2", features=["derive", "chrono04"]}
7375

scripts/Dockerfile

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
FROM debian:13-slim AS downloader
2-
ARG TAR_URL_AMD64
3-
ARG TAR_URL_ARM64
4-
ARG TARGETPLATFORM
5-
6-
RUN apt-get update && apt-get install -y curl tar
7-
RUN echo "Downloading liwan for ${TARGETPLATFORM}..." \
8-
&& TAR_URL=$(if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then echo ${TAR_URL_ARM64}; else echo ${TAR_URL_AMD64}; fi) \
9-
&& curl -fsSL $TAR_URL -o /tmp/package.tar.gz \
10-
&& mkdir -p /app \
11-
&& tar -xzf /tmp/package.tar.gz -C /app \
12-
&& chmod +x /app/liwan
13-
14-
FROM alpine:3
1+
FROM gcr.io/distroless/cc-debian13:nonroot
152

163
ENV LIWAN_CONFIG=/liwan.config.toml
174
ENV LIWAN_DATA_DIR=/data
185

19-
COPY --from=downloader /app/liwan /liwan
20-
ENTRYPOINT ["/liwan"]
6+
COPY --from=buildx /dist/${TARGETARCH:+amd64/}liwan /liwan
7+
218
EXPOSE 9042
22-
STOPSIGNAL SIGINT
9+
STOPSIGNAL SIGINT
10+
ENTRYPOINT ["/liwan"]

src/utils/hash.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,9 @@ pub fn onboarding_token() -> String {
5454
rand::rng().fill_bytes(&mut bytes);
5555
bs58::encode(bytes).into_string()
5656
}
57+
58+
pub fn db_name() -> String {
59+
let mut bytes = [0u8; 16];
60+
rand::rng().fill_bytes(&mut bytes);
61+
bs58::encode(bytes).into_string()
62+
}

src/utils/r2d2_sqlite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use crate::utils::hash::db_name;
12
use rusqlite::{Connection, OpenFlags, Result};
23
use std::path::{Path, PathBuf};
3-
use uuid::Uuid;
44

55
pub struct SqliteConnectionManager {
66
source: PathBuf,
@@ -13,7 +13,7 @@ impl SqliteConnectionManager {
1313
}
1414

1515
pub fn memory() -> Self {
16-
Self { source: format!("file:{}?mode=memory&cache=shared", Uuid::new_v4()).into(), flags: OpenFlags::default() }
16+
Self { source: format!("file:{}?mode=memory&cache=shared", db_name()).into(), flags: OpenFlags::default() }
1717
}
1818

1919
pub fn with_flags(self, flags: OpenFlags) -> Self {

src/web/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ fn save_spec(spec: openapi::OpenApi) -> Result<()> {
9898

9999
let path = Path::new("./web/src/api/dashboard.ts");
100100
if path.exists() {
101-
let spec = serde_json::to_string(&spec)?
102-
.replace(r#""servers":[],"#, "") // fets doesn't work with an empty servers array
103-
.replace("; charset=utf-8", "") // fets doesn't detect the json content type correctly
104-
.replace(r#""format":"int64","#, ""); // fets uses bigint for int64
101+
let spec = serde_json::to_string(&spec)?;
105102

106103
// check if the spec has changed
107104
let old_spec = std::fs::read_to_string(path)?;
@@ -112,6 +109,7 @@ fn save_spec(spec: openapi::OpenApi) -> Result<()> {
112109
tracing::info!("API has changed, updating the openapi spec...");
113110
std::fs::write(path, format!("export default {spec} as const;\n"))?;
114111
}
112+
115113
Ok(())
116114
}
117115

0 commit comments

Comments
 (0)