Skip to content

Commit

Permalink
Improve performance of building image with multi stage build
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallku committed Apr 9, 2024
1 parent 33992b6 commit b521217
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 41 deletions.
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
FROM rust:1.73-alpine AS builder
FROM rust:1.73-alpine AS base

WORKDIR /usr/src/marshallku-blog-cdn

RUN set -eux; \
apk add --no-cache musl-dev pkgconfig libressl-dev; \
rm -rf $CARGO_HOME/registry

COPY . .
COPY Cargo.* .

RUN mkdir src && \
echo 'fn main() {println!("Hello, world!");}' > src/main.rs && \
cargo build --release && \
rm target/release/marshallku-blog-cdn* && \
rm target/release/deps/marshallku_blog_cdn* && \
rm -rf src

FROM base AS builder

COPY src src
RUN cargo build --release

FROM alpine:3.14
Expand Down
74 changes: 35 additions & 39 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
{
"words": [
"actix",
"addrs",
"autodocs",
"BUILDKIT",
"callout",
"codebases",
"codepoint",
"codepoints",
"hookform",
"iname",
"libressl",
"localforage",
"Malgun",
"marshallku",
"mindepth",
"nextjs",
"pkgconfig",
"preconfigured",
"preconfigures",
"Pretendard",
"Promiseable",
"referer",
"reqwest",
"rfind",
"treeshake",
"tsup",
"Turborepo",
"vercel",
"WEBM",
"WEBP",
"xlink"
],
"ignorePaths": [
"Cargo.lock",
"Cargo.toml",
"target",
"config/nginx.conf"
]
"words": [
"actix",
"addrs",
"autodocs",
"BUILDKIT",
"callout",
"codebases",
"codepoint",
"codepoints",
"hookform",
"iname",
"libressl",
"localforage",
"Malgun",
"marshallku",
"mindepth",
"nextjs",
"pkgconfig",
"preconfigured",
"preconfigures",
"Pretendard",
"println",
"Promiseable",
"referer",
"reqwest",
"rfind",
"treeshake",
"tsup",
"Turborepo",
"vercel",
"WEBM",
"WEBP",
"xlink"
],
"ignorePaths": ["Cargo.lock", "Cargo.toml", "target", "config/nginx.conf"]
}

0 comments on commit b521217

Please sign in to comment.