Add Dockerfile

This commit is contained in:
Lennart
2024-10-31 17:10:07 +01:00
parent 3a96e98f45
commit 9714533ef1
3 changed files with 45 additions and 1 deletions

16
.dockerignore Normal file
View File

@@ -0,0 +1,16 @@
target
crates/*/target
# For libraries ignore Cargo.lock
crates/*/Cargo.lock
db.toml
db.sqlite3*
config.toml
schema.sql
/.idea
.env
**/node_modules
**/dist

28
Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
FROM node:23-slim AS frontend-builder
RUN corepack enable
WORKDIR /frontend
COPY crates/frontend/frontend/package.json /frontend/package.json
RUN pnpm install
COPY crates/frontend/frontend /frontend
RUN pnpm build
# Templates will be in /frontend/dist/templates
# Assets will be in /frontend/dist/assets
FROM rust:1.82-alpine AS builder
# We need to statically link C dependencies like sqlite, otherwise we get
# exec /usr/local/bin/rustical: no such file or directory
# x86_64-unknown-linux-musl does static linking by default
RUN apk add --no-progress build-base; \
rustup target add x86_64-unknown-linux-musl
WORKDIR /rustical
COPY . .
COPY --from=frontend-builder /frontend/dist crates/frontend/frontend/dist
RUN --mount=type=cache,target=target cargo install --target x86_64-unknown-linux-musl --path .
FROM scratch
COPY --from=builder /usr/local/cargo/bin/rustical /usr/local/bin/rustical
CMD ["/usr/local/bin/rustical"]
LABEL org.opencontainers.image.authors="Lennart K github.com/lennart-k"
EXPOSE 4000

View File

@@ -30,7 +30,7 @@ a calendar server
- [ ] Restore endpoint
- [ ] Packaging
- [x] Ensure cargo install works
- [ ] Docker image
- [x] Docker image
- [ ] Releases
- [ ] Locking
- [ ] Testing such that I'm confident enough to use it myself :)