chore: add Dockerfile

image-uploads
Jef Roosens 2025-01-10 13:22:33 +01:00
parent adef5c1fd5
commit 03b3f692e1
No known key found for this signature in database
GPG Key ID: 21FD3D77D56BAF49
4 changed files with 54 additions and 1 deletions

5
.dockerignore 100644
View File

@ -0,0 +1,5 @@
*
!Cargo.toml
!Cargo.lock
!src/**

1
Cargo.lock generated
View File

@ -703,6 +703,7 @@ version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149"
dependencies = [
"cc",
"pkg-config",
"vcpkg",
]

View File

@ -3,6 +3,10 @@ name = "calathea"
version = "0.1.0"
edition = "2021"
[[bin]]
path = "src/main.rs"
name = "calathea"
[dependencies]
axum = { version = "0.7.9", features = ["macros"] }
chrono = { version = "0.4.39", features = ["serde"] }
@ -10,7 +14,7 @@ r2d2 = "0.8.10"
r2d2_sqlite = "0.25.0"
# this dependency is needed soly because the r2d2_sqlite crate doesn't export
# the 'chrono' feature flag
rusqlite = { version = "0.32.1", features = ["chrono"] }
rusqlite = { version = "0.32.1", features = ["chrono", "bundled"] }
serde = { version = "1.0.217", features = ["derive"] }
tera = "1.20.0"
tokio = { version = "1.42.0", features = ["full"] }

43
Dockerfile 100644
View File

@ -0,0 +1,43 @@
FROM rust:1.83-alpine3.21 AS builder
ARG DI_VER=1.2.5
WORKDIR /app
RUN apk update && apk add --no-cache build-base
# Build dumb-init
RUN wget -O - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.tar.gz" | tar -xzf - && \
cd "dumb-init-${DI_VER}" && \
make SHELL=/bin/sh && \
mv dumb-init .. && \
cd ..
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch --locked
COPY . ./
RUN cargo build --release --frozen
FROM alpine:3.21
COPY --from=builder /app/target/release/calathea /bin/calathea
COPY --from=builder /app/dumb-init /bin/dumb-init
# Create a non-root user & make sure it can write to the data directory
RUN set -x && \
adduser -u 82 -D -S -G www-data www-data && \
mkdir /data && \
chown -R www-data:www-data /data
WORKDIR /data
USER www-data:www-data
ENTRYPOINT [ "/bin/dumb-init", "--" ]
CMD [ "/bin/calathea" ]