From e84d8468546a1525d65ddb802f25feb90f5cc57d Mon Sep 17 00:00:00 2001 From: Buck McCready Date: Wed, 9 Aug 2023 19:12:43 -0700 Subject: [PATCH] Improve Dockerfile image layers to avoid recompiles --- Dockerfile | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index d752850..26e06ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,12 @@ # syntax=docker/dockerfile:1 -# Comments are provided throughout this file to help you get started. -# If you need more help, visit the Dockerfile reference guide at -# https://docs.docker.com/engine/reference/builder/ - -################################################################################ -# Create a stage for building the application. +# Stage for building backend ARG RUST_VERSION=1.71.0 ARG APP_NAME=cavalier_contours_server FROM rust:${RUST_VERSION}-slim-bullseye AS build_backend ARG APP_NAME +WORKDIR /app # Build the application. # Leverage a cache mount to /usr/local/cargo/registry/ @@ -30,39 +26,36 @@ cargo build --locked --release cp ./target/release/$APP_NAME /bin/server EOF +# Stage for building frontend (Rust needed for building WASM) FROM rust:${RUST_VERSION}-slim-bullseye AS build_frontend WORKDIR /app +# Install curl RUN apt-get update && \ apt-get install -yq --no-install-recommends \ curl +# Install node and wasm-pack RUN <