-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated dockerfile, docker integrations
- Loading branch information
1 parent
713f190
commit 0ebfcad
Showing
5 changed files
with
75 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
* | ||
!/src | ||
!/static | ||
!/.cargo | ||
!/Cargo.toml | ||
!/rust-toolchain.toml | ||
!/build.rs |
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
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,21 +1,58 @@ | ||
FROM clux/muslrust:nightly AS chef | ||
USER root | ||
RUN cargo install cargo-chef | ||
WORKDIR /app | ||
# rust with musl development utilities & cargo chef preinstalled | ||
FROM ghcr.io/perpetualcacophony/muslrust-chef:nightly AS chef | ||
WORKDIR /build | ||
|
||
|
||
|
||
FROM chef AS planner | ||
COPY . . | ||
|
||
# cargo chef prepare wants these files | ||
COPY Cargo.toml . | ||
COPY src/main.rs src/ | ||
|
||
# create the cargo chef recipe file | ||
RUN cargo +nightly chef prepare --recipe-path recipe.json | ||
|
||
|
||
|
||
FROM chef AS builder | ||
COPY --link --from=planner /app/recipe.json recipe.json | ||
RUN cargo +nightly chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json | ||
|
||
# copy recipe file to builder | ||
COPY --link --from=planner /build/recipe.json . | ||
|
||
# cargo chef cook to cache dependencies from recipe file | ||
RUN cargo +nightly chef cook \ | ||
--release \ | ||
--target x86_64-unknown-linux-musl \ | ||
--recipe-path recipe.json \ | ||
--features docker | ||
|
||
# copy the rest of the source code to builder | ||
COPY . . | ||
RUN touch /app/build.rs | ||
RUN cargo +nightly build --release --target x86_64-unknown-linux-musl | ||
|
||
# touch the build script to ensure cargo runs it | ||
RUN touch build.rs | ||
|
||
# build binary | ||
RUN cargo +nightly build \ | ||
--release \ | ||
--target x86_64-unknown-linux-musl \ | ||
--features docker | ||
|
||
|
||
|
||
# using alpine for small final image | ||
FROM alpine AS runtime | ||
COPY --link --from=builder /app/target/x86_64-unknown-linux-musl/release/slimebot /usr/local/bin/slimebot | ||
|
||
# add slimebot user & group | ||
RUN addgroup --system slimebot && \ | ||
adduser --system slimebot --ingroup slimebot | ||
|
||
EXPOSE 443 | ||
|
||
# copy binary from builder | ||
COPY --link --from=builder --chown=slimebot:slimebot /build/target/x86_64-unknown-linux-musl/release/slimebot /usr/local/bin/slimebot | ||
|
||
USER slimebot:slimebot | ||
ENTRYPOINT ["slimebot"] | ||
|
||
ENTRYPOINT slimebot |
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
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