-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
12 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
# [package] | ||
# name = "markdown-extract-monorepo" | ||
# description = "Extract sections of a markdown file with a regular expression" | ||
# version = "0.1.0" | ||
# authors = ["Sean Bailey <hello@seanbailey.dev>"] | ||
# license = "MIT" | ||
# readme = "README.md" | ||
|
||
[workspace] | ||
members = ["crates/markdown-extract", "crates/markdown-extract-cli"] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,23 @@ | ||
# Dockerfile for creating statically-linked Rust applications. | ||
# See: https://www.artificialworlds.net/blog/2020/04/22/creating-a-tiny-docker-image-of-a-rust-project/ | ||
# See: https://alexbrand.dev/post/how-to-package-rust-applications-into-minimal-docker-containers/ | ||
|
||
# 1: Build the exe | ||
FROM rust:1.57 as builder | ||
# Step 0: Initialise builder | ||
FROM rust:1.81 as builder | ||
WORKDIR /usr/src | ||
RUN rustup target add x86_64-unknown-linux-musl | ||
RUN apt-get update | ||
RUN apt-get install -y musl-tools gcc-x86-64-linux-gnu | ||
ENV RUSTFLAGS='-C linker=x86_64-linux-gnu-gcc' | ||
|
||
# 1a: Prepare for static linking | ||
RUN apt-get update && \ | ||
apt-get dist-upgrade -y && \ | ||
apt-get install -y musl-tools && \ | ||
rustup target add x86_64-unknown-linux-musl | ||
|
||
# 1b: Download and compile Rust dependencies (and store as a separate Docker layer) | ||
RUN USER=root cargo new markdown-extract | ||
# Step 1: Build and install binary | ||
WORKDIR /usr/src/markdown-extract | ||
COPY Cargo.toml Cargo.lock ./ | ||
COPY src ./src | ||
RUN cargo install --target x86_64-unknown-linux-musl --path . | ||
COPY crates ./crates | ||
RUN cargo install \ | ||
--target x86_64-unknown-linux-musl \ | ||
--path ./crates/markdown-extract-cli | ||
|
||
# 2: Copy the exe and extra files ("static") to an empty Docker image | ||
# Step 2: Copy bin to an empty Docker image | ||
FROM scratch | ||
COPY --from=builder /usr/local/cargo/bin/markdown-extract . | ||
# COPY static . | ||
USER 1000 | ||
ENTRYPOINT ["./markdown-extract"] |