chore: update dockerfile for templates

image-uploads
Jef Roosens 2025-01-10 15:29:45 +01:00
parent 4a4b8bba3d
commit 1d910bc421
No known key found for this signature in database
GPG Key ID: 21FD3D77D56BAF49
3 changed files with 11 additions and 7 deletions

View File

@ -3,3 +3,4 @@
!Cargo.toml
!Cargo.lock
!src/**
!templates/**

View File

@ -24,8 +24,9 @@ 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
COPY --from=builder /app/target/release/calathea /app/calathea
COPY --from=builder /app/dumb-init /app/dumb-init
COPY templates /app/templates
# Create a non-root user & make sure it can write to the data directory
RUN set -x && \
@ -35,9 +36,9 @@ RUN set -x && \
WORKDIR /data
ENV TEMPLATE_DIR=/app/templates
USER www-data:www-data
ENTRYPOINT [ "/bin/dumb-init", "--" ]
CMD [ "/bin/calathea" ]
ENTRYPOINT [ "/app/dumb-init", "--" ]
CMD [ "/app/calathea" ]

View File

@ -32,7 +32,9 @@ async fn main() {
let pool = r2d2::Pool::new(manager).unwrap();
db::run_migrations(&pool, &MIGRATIONS).unwrap();
let tera = Tera::new("templates/**/*").unwrap();
let template_dir = std::env::var("TEMPLATE_DIR").unwrap_or(String::from("./templates"));
let tera = Tera::new(&format!("{template_dir}/**/*")).unwrap();
let ctx = Context {
pool,
tera: Arc::new(tera),