Skip to content

Commit

Permalink
use clients and service from jarvis_lib; use cargo chef for faster bu…
Browse files Browse the repository at this point in the history
…ilds
  • Loading branch information
JorritSalverda committed May 21, 2021
1 parent bcda852 commit 5840c84
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 769 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.git
helm
target

.dockerignore
.estafette.yaml
Expand Down
4 changes: 2 additions & 2 deletions .estafette.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ stages:
repoUrl: https://helm.jorritsalverda.com/

bake:
image: extensions/docker:stable
image: extensions/docker:dev
action: build
repositories:
- jsalverda

push-to-docker-hub:
image: extensions/docker:stable
image: extensions/docker:dev
action: push
repositories:
- jsalverda
Expand Down
63 changes: 23 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,11 @@ include = ["src/**/*", "LICENSE", "README.md"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
byteorder = "1.4"
chrono = "0.4"
conv = "0.3"
gcp-bigquery-client = "0.9"
k8s-openapi = { version = "0.11", default-features = false, features = ["v1_20"] }
kube = "0.52"
kube-runtime = "0.52"
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8"
serde_json = "1.0"
tokio = { version = "1.5", features = ["macros"] }
uuid = { version = "0.8", features = ["v4"] }
derivative = "2.2"
serde-xml-rs = "0.4"
websocket = "0.26"
regex = "1.5"
jarvis-lib = { git = "https://github.com/JorritSalverda/jarvis-lib", tag = "0.1.5" }

[target.x86_64-unknown-linux-musl.dependencies]
openssl = { version = "0.10", features = ["vendored"] }
jarvis-lib = { git = "https://github.com/JorritSalverda/jarvis-lib", tag = "0.1.15" }
32 changes: 21 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
# Step 1: Build the application
FROM rust:1.52 as builder

WORKDIR app
# from https://www.lpalmieri.com/posts/fast-rust-docker-builds/
FROM rust:1.52 as planner
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends musl-tools
RUN rustup target add x86_64-unknown-linux-musl
RUN cargo install cargo-chef --version 0.1.20
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

# RUN apk add --update musl-dev
FROM rust:1.52 as cacher
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends musl-tools
RUN rustup target add x86_64-unknown-linux-musl
RUN cargo install cargo-chef --version 0.1.20
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json

FROM rust:1.52 as builder
RUN apt-get update && apt-get install -y --no-install-recommends musl-tools
RUN rustup target add x86_64-unknown-linux-musl
WORKDIR /app
COPY . .
COPY --from=cacher /app/target target
COPY --from=cacher /usr/local/cargo /usr/local/cargo
RUN cargo test --release --target x86_64-unknown-linux-musl
RUN ls -latr /app/target/x86_64-unknown-linux-musl/release/
RUN cargo build --release --target x86_64-unknown-linux-musl
RUN ls -latr /app/target/x86_64-unknown-linux-musl/release/

# Step 2: Create the runtime container image
FROM scratch AS runtime

COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/jarvis-alpha-innotec-exporter .
USER 1000
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/jarvis-alpha-innotec-exporter .
ENTRYPOINT ["./jarvis-alpha-innotec-exporter"]
Loading

0 comments on commit 5840c84

Please sign in to comment.