[READ-ONLY] Mirror of https://github.com/SantaClaas/meal. melt.claa.sh
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214ARG RUST_VERSION=1.92
FROM rust:${RUST_VERSION} AS builder
# Install cmake to build libsql# Run apt-get in one step for caching https://docs.docker.com/build/building/best-practices/#apt-getRUN apt-get update && apt-get install -y --no-install-recommends \ cmake \ && rm -rf /var/lib/apt/lists/*
# Create a new empty shell project to enable downloading dependencies before building for cachingRUN USER=root cargo new --bin delivery-serviceRUN USER=root cargo new --name meal-core --lib coreRUN USER=root cargo new --name pumpe --bin pumpeRUN USER=root cargo new --name tugboat --bin tugboat
# Copy over manifestsCOPY ./Cargo.lock ./Cargo.lockCOPY ./Cargo.toml ./Cargo.tomlCOPY ./core/Cargo.toml ./core/Cargo.tomlCOPY ./delivery-service/Cargo.toml ./delivery-service/Cargo.tomlCOPY ./pumpe/Cargo.toml ./pumpe/Cargo.tomlCOPY ./tugboat/Cargo.toml ./tugboat/Cargo.toml
# Build and cache the dependenciesRUN cargo build --release
# Remove build artifacts that are not needed in next stepsRUN rm ./target/release/deps/delivery_service*RUN rm ./target/release/deps/meal_core*RUN rm ./target/release/deps/pumpe*RUN rm ./target/release/deps/tugboat*
# Don't remove source code as that breaks building from cargo workspace
# Build core rust wasmFROM builder AS build-core
# Install wasm-pack#TODO improve this step as it builds from source and is slow but downloading built binary would need hash check and might changeRUN cargo install wasm-pack
# Copy over the source code to build the libraryRUN rm core/src/*.rsCOPY ./core/src ./core/src
# Build the applicationRUN wasm-pack build --target web --release ./core
# Build tool to compress filesFROM builder AS build-pumpe
# Copy over the source code to build the applicationRUN rm ./pumpe/src/*.rsCOPY ./pumpe/src ./pumpe/src
# Build the applicationRUN cargo build --package pumpe --release
FROM node:lts-slim AS node-base# Updating corepack to not have signing keys out of dateRUN npm install --global corepack@latest# Installs pnpm(?)RUN corepack enable# Pin pnpm as corepack picks the latest version otherwise. pnpm 12 fails pnpm fetch without a lockfile and on# unapproved dependency build scriptsRUN corepack install --global pnpm@10.34.6#TODO use pnpm fetch to cache dependencies and only use pnpm install --offline to not refetch# Install git as build reads commit hashRUN apt-get update && apt-get install -y git
# Build the appFROM node-base AS build-appWORKDIR /app-build
# Copy git repositoryCOPY ./.git ./.git# Copy build artifacts from core rust wasm buildCOPY --from=build-core /core/pkg ./core/pkg# Copy tool to compress filesCOPY --from=build-pumpe /target/release/pumpe ./pumpe
# Copy over manifests# Workspace rootCOPY ./package.json ./package.jsonCOPY ./pnpm-workspace.yaml ./pnpm-workspace.yamlCOPY ./pnpm-lock.yaml ./pnpm-lock.yaml
# App specificCOPY ./app/package.json ./app/package.json
# Install dependenciesRUN pnpm install --frozen-lockfile
# Copy over the source to build the applicationCOPY ./app ./app
# Build and cacheRUN pnpm run build
# Compress filesRUN ./pumpe ./app/dist
# Build the delivery service containing the API and hosting the appFROM builder AS build-delivery-service
# Copy over the source code to build the applicationRUN rm ./delivery-service/src/*.rsCOPY ./delivery-service/src ./delivery-service/src
# Build the applicationRUN cargo build --package delivery-service --release
# The final image can be specified with the target when building the docker image# Final base imageFROM debian:bookworm-slim AS final-delivery-service
# Copy the build artifacts from the build stageCOPY --from=build-delivery-service /target/release/delivery-service .# The ./app directory is where the delivery service looks for when app static files are requestedCOPY --from=build-app /app-build/app/dist ./app
EXPOSE 3000# Set the startup command to run the applicationCMD ["./delivery-service"]
# Build tugboat stylesFROM node-base AS build-tugboat-stylesWORKDIR /tugboat-styles
# Copy tool to compress filesCOPY --from=build-pumpe /target/release/pumpe ./pumpe
#TODO this should be the lock file not the workspace file?COPY ./pnpm-workspace.yaml ./pnpm-workspace.yamlRUN pnpm fetch
# Copy over manifests# Workspace rootCOPY ./package.json ./package.jsonCOPY ./pnpm-lock.yaml ./pnpm-lock.yaml
# App specificCOPY ./tugboat/package.json ./tugboat/package.json
# Install dependenciesRUN pnpm install --frozen-lockfile
# Copy over the source to build the stylesCOPY ./tugboat ./tugboat
# Build and cacheRUN cd tugboat \ && pnpx @tailwindcss/cli --input ./app.css --output ./public/app.css --minify \ && cd ..
# Compress filesRUN ./pumpe ./tugboat/public
FROM builder AS build-tugboat
# Copy over the source code to build the applicationRUN rm ./tugboat/src/*.rsCOPY ./tugboat/src ./tugboat/srcCOPY ./tugboat/templates ./tugboat/templates
# Build the applicationRUN cargo build --package tugboat --release
# The final image can be specified with the target when building the docker image# Final base imageFROM debian:bookworm-slim AS final-tugboat
RUN apt-get update && apt-get install -y --no-install-recommends \ # OpenSSL dependency for reqwest used by bitwarden libssl-dev \ # Certificates needed to make HTTPS requests ca-certificates \ && rm -rf /var/lib/apt/lists/*
# Copy the build artifacts from the build stageCOPY --from=build-tugboat-styles /tugboat-styles/tugboat/public ./publicCOPY --from=build-tugboat /target/release/tugboat .
EXPOSE 3001# Set the startup command to run the applicationCMD ["./tugboat"]