From 64c35a62a9ca4411db82e96de9a9cbf55faefa03 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Wed, 5 Apr 2023 20:22:29 +0200 Subject: [PATCH] feat(ci): Add Dockerfiles to build locally --- .ci/Dockerfile.linux | 35 +++++++++++++++++++++++++++++++++++ .ci/Dockerfile.msvc | 35 +++++++++++++++++++++++++++++++++++ .dockerignore | 9 +++++++++ Justfile | 18 +++++++++++++++++- 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 .ci/Dockerfile.linux create mode 100644 .ci/Dockerfile.msvc create mode 100644 .dockerignore diff --git a/.ci/Dockerfile.linux b/.ci/Dockerfile.linux new file mode 100644 index 0000000..2cb6339 --- /dev/null +++ b/.ci/Dockerfile.linux @@ -0,0 +1,35 @@ +FROM dtmt-ci-base-linux + +# Create dummy crates and copy their Cargo.toml, so that dependencies can be cached +RUN set -e; \ + cargo new --bin crates/dtmt; \ + cargo new --bin crates/dtmm; \ + cargo new --lib lib/dtmt-shared; \ + cargo new --lib lib/nexusmods; \ + cargo new --lib lib/sdk; \ + cargo new --lib lib/serde_sjson; \ + cargo new --lib lib/steamlocate-rs + +COPY Cargo.toml Cargo.lock /src/dtmt/ +COPY crates/dtmt/Cargo.toml /src/dtmt/crates/dtmt/ +COPY crates/dtmm/Cargo.toml /src/dtmt/crates/dtmm/ +COPY lib/dtmt-shared/Cargo.toml /src/dtmt/lib/dtmt-shared/ +COPY lib/nexusmods/Cargo.toml /src/dtmt/lib/nexusmods/ +COPY lib/sdk/Cargo.toml /src/dtmt/lib/sdk/ +COPY lib/serde_sjson/Cargo.toml /src/dtmt/lib/serde_sjson/ +COPY lib/steamlocate-rs/Cargo.toml /src/dtmt/lib/steamlocate-rs/ + +# Crates with build scripts cannot be split that way, but they shouldn't change too often +COPY lib/luajit2-sys /src/dtmt/lib/luajit2-sys +COPY lib/oodle /src/dtmt/lib/oodle +# color-eyre needs to be copied, too, then, as it's used by `oodle` +COPY lib/color-eyre /src/dtmt/lib/color-eyre +COPY --from=dtmt-ci-base-linux /src/*.lib /src/dtmt/lib/oodle/ + +RUN cargo build --release --locked +RUN rm -r crates lib + +COPY . /src/dtmt +COPY --from=dtmt-ci-base-linux /src/*.lib /src/dtmt/lib/oodle/ + +RUN cargo build --release --locked diff --git a/.ci/Dockerfile.msvc b/.ci/Dockerfile.msvc new file mode 100644 index 0000000..0d0a546 --- /dev/null +++ b/.ci/Dockerfile.msvc @@ -0,0 +1,35 @@ +FROM dtmt-ci-base-msvc + +# Create dummy crates and copy their Cargo.toml, so that dependencies can be cached +RUN set -e; \ + cargo new --bin crates/dtmt; \ + cargo new --bin crates/dtmm; \ + cargo new --lib lib/dtmt-shared; \ + cargo new --lib lib/nexusmods; \ + cargo new --lib lib/sdk; \ + cargo new --lib lib/serde_sjson; \ + cargo new --lib lib/steamlocate-rs + +COPY Cargo.toml Cargo.lock /src/dtmt/ +COPY crates/dtmt/Cargo.toml /src/dtmt/crates/dtmt/ +COPY crates/dtmm/Cargo.toml /src/dtmt/crates/dtmm/ +COPY lib/dtmt-shared/Cargo.toml /src/dtmt/lib/dtmt-shared/ +COPY lib/nexusmods/Cargo.toml /src/dtmt/lib/nexusmods/ +COPY lib/sdk/Cargo.toml /src/dtmt/lib/sdk/ +COPY lib/serde_sjson/Cargo.toml /src/dtmt/lib/serde_sjson/ +COPY lib/steamlocate-rs/Cargo.toml /src/dtmt/lib/steamlocate-rs/ + +# Crates with build scripts cannot be split that way, but they shouldn't change too often +COPY lib/luajit2-sys /src/dtmt/lib/luajit2-sys +COPY lib/oodle /src/dtmt/lib/oodle +# color-eyre needs to be copied, too, then, as it's used by `oodle` +COPY lib/color-eyre /src/dtmt/lib/color-eyre +COPY --from=dtmt-ci-base-msvc /src/*.lib /src/dtmt/lib/oodle/ + +RUN cargo build --release --target x86_64-pc-windows-msvc --locked -Zbuild-std +RUN rm -r crates lib + +COPY . /src/dtmt +COPY --from=dtmt-ci-base-msvc /src/*.lib /src/dtmt/lib/oodle/ + +RUN cargo build --release --target x86_64-pc-windows-msvc --frozen -Zbuild-std diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..30c19ad --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +target/ +docs/ +data/ +.git/ +README.adoc +CHANGELOG.adoc +LICENSE +dictionary.csv +Justfile diff --git a/Justfile b/Justfile index 4b6315f..3104fb1 100644 --- a/Justfile +++ b/Justfile @@ -1,4 +1,20 @@ -ci-image: ci-image-linux ci-image-msvc +ci-build: ci-build-msvc ci-build-linux + +ci-build-msvc: + docker run --rm -ti -v ./:/src/dtmt dtmt-ci-base-msvc cargo --color always build --release --target x86_64-pc-windows-msvc --locked -Zbuild-std + +ci-build-linux: + docker run --rm -ti -v ./:/src/dtmt dtmt-ci-base-linux cargo --color always build --profile release-lto --locked + +build-image: build-image-msvc build-image-linux + +build-image-msvc: + docker build -f .ci/Dockerfile.msvc . + +build-image-linux: + docker build -f .ci/Dockerfile.linux . + +ci-image: ci-image-msvc ci-image-linux ci-image-msvc: ci-image-linux docker build -t dtmt-ci-base-msvc -f .ci/image/Dockerfile.msvc .ci/image -- 2.45.3