feat(ci): Add Dockerfiles to build locally #103

Merged
lucas merged 1 commit from feat/ci into master 2023-04-05 20:33:11 +02:00
4 changed files with 96 additions and 1 deletions

35
.ci/Dockerfile.linux Normal file
View file

@ -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

35
.ci/Dockerfile.msvc Normal file
View file

@ -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

9
.dockerignore Normal file
View file

@ -0,0 +1,9 @@
target/
docs/
data/
.git/
README.adoc
CHANGELOG.adoc
LICENSE
dictionary.csv
Justfile

View file

@ -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 ci-image-msvc: ci-image-linux
docker build -t dtmt-ci-base-msvc -f .ci/image/Dockerfile.msvc .ci/image docker build -t dtmt-ci-base-msvc -f .ci/image/Dockerfile.msvc .ci/image