forked from gattaca-com/helix
-
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.
- Loading branch information
Showing
3 changed files
with
46 additions
and
81 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 @@ | ||
target |
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,61 +1,24 @@ | ||
FROM rust:1.75.0 as helix | ||
|
||
RUN apt update -y | ||
RUN apt install -y clang | ||
RUN apt install -y protobuf-compiler | ||
|
||
RUN wget https://github.com/mozilla/sccache/releases/download/v0.3.1/sccache-v0.3.1-x86_64-unknown-linux-musl.tar.gz \ | ||
&& tar xzf sccache-v0.3.1-x86_64-unknown-linux-musl.tar.gz \ | ||
&& mv sccache-v0.3.1-x86_64-unknown-linux-musl/sccache /usr/local/bin/sccache \ | ||
&& chmod +x /usr/local/bin/sccache | ||
|
||
ARG AWS_ACCESS_KEY_ID | ||
ARG AWS_SECRET_ACCESS_KEY | ||
ARG REPO_NAME | ||
|
||
RUN echo "REPO_NAME: $REPO_NAME" | ||
|
||
# Test to make sure that aws access is set correctly | ||
RUN test -n "$AWS_ACCESS_KEY_ID" || (echo "AWS_ACCESS_KEY_ID not set" && false) | ||
RUN test -n "$AWS_SECRET_ACCESS_KEY" || (echo "AWS_SECRET_ACCESS_KEY not set" && false) | ||
|
||
ENV SCCACHE_BUCKET=sccache-gtc | ||
ENV SCCACHE_REGION=eu-west-1 | ||
ENV SCCACHE_S3_USE_SSL=true | ||
|
||
# Copy necessary contents into the container at /app | ||
ADD ./repos /app/ | ||
|
||
RUN ls -lah /app | ||
RUN ls -lah /app/${REPO_NAME} | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app/${REPO_NAME} | ||
|
||
RUN --mount=type=cache,target=/root/.cargo \ | ||
--mount=type=cache,target=/usr/local/cargo/registry \ | ||
cargo fetch | ||
|
||
# Run build | ||
RUN --mount=type=cache,target=/root/.cargo \ | ||
--mount=type=cache,target=/usr/local/cargo/registry \ | ||
RUSTC_WRAPPER=/usr/local/bin/sccache cargo build -p helix-cmd --release | ||
|
||
# Copy binary into the workdir | ||
RUN mv /app/$REPO_NAME/target/release/helix-cmd /app/helix-cmd | ||
|
||
# our final base | ||
FROM debian:stable-slim | ||
|
||
RUN mkdir /root/logs | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y ca-certificates | ||
|
||
FROM lukemathwalker/cargo-chef:latest-rust-1.81.0 AS chef | ||
WORKDIR /app | ||
|
||
COPY --from=helix /app/helix-cmd* ./ | ||
RUN apt update -y && apt install -y clang protobuf-compiler | ||
|
||
FROM chef AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef AS builder | ||
COPY --from=planner /app/recipe.json recipe.json | ||
# Build dependencies - this is the caching Docker layer! | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
# Build application | ||
COPY . . | ||
RUN cargo build --release | ||
|
||
# We do not need the Rust toolchain to run the binary! | ||
FROM debian:bookworm-slim AS runtime | ||
RUN apt-get update && apt-get install -y libssl-dev | ||
WORKDIR /app | ||
COPY --from=builder /app/target/release/helix-cmd* ./ | ||
|
||
# set the startup command to run your binary | ||
ENTRYPOINT ["/app/helix-cmd"] | ||
|
||
ENTRYPOINT ["/app/helix-cmd"] |