Skip to content

Commit

Permalink
remove unecessary println && add publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tchapacan committed Apr 1, 2024
1 parent f635820 commit e91ed74
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "Release docker image"
run-name: "Release docker image: ${{ github.event.release.name }} ⛑️"

on:
push:
# release:
# types: [published]

jobs:
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: linux/amd64,linux/arm64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx

- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
# - name: Login to DockerHub
# uses: docker/login-action@v2
# if: github.event_name != 'pull_request'
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
id: docker_build
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM --platform=$BUILDPLATFORM rust:bookworm as vendor
ARG BUILDPLATFORM
ARG TARGETPLATFORM
RUN echo "Running on: $BUILDPLATFORM / Building for $TARGETPLATFORM"
WORKDIR /app

COPY ./Cargo.toml .
#COPY ./Cargo.lock .
COPY ./src src
RUN mkdir .cargo && cargo vendor > .cargo/config.toml

FROM rust:bookworm as builder
WORKDIR /app

COPY --from=vendor /app/.cargo .cargo
COPY --from=vendor /app/vendor vendor
COPY ./Cargo.toml .
#COPY ./Cargo.lock .
COPY ./src src
RUN cargo build --release

FROM debian:bookworm-slim
WORKDIR /app
ENV RUST_BACKTRACE=full
COPY --from=builder /app/target/release/livebox-exporter-rs livebox-exporter-rs

EXPOSE 9100
ENTRYPOINT ["/app/livebox-exporter-rs"]
3 changes: 0 additions & 3 deletions src/livebox_client_rs/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ impl Client {
.authenticated_post_request("DeviceInfo", "get", serde_json::json!({}))
.await;
let json: Value = serde_json::from_slice(&body_bytes).expect("Could not parse JSON.");
println!("Body was: '{}'.", std::str::from_utf8(&body_bytes).unwrap());
assert!(
parts.status.is_success(),
"Router answered with something else than a success code."
Expand All @@ -153,7 +152,6 @@ impl Client {
.authenticated_post_request("NMC", "getWANStatus", serde_json::json!({}))
.await;
let json: Value = serde_json::from_slice(&body_bytes).expect("Could not parse JSON.");
println!("Body was: '{}'.", std::str::from_utf8(&body_bytes).unwrap());
assert!(
parts.status.is_success(),
"Router answered with something else than a success code."
Expand Down Expand Up @@ -185,7 +183,6 @@ impl Client {
.authenticated_post_request("HomeLan", "getResults", post_data)
.await;
let json: Value = serde_json::from_slice(&body_bytes).expect("Could not parse JSON.");
println!("Body was: '{}'.", std::str::from_utf8(&body_bytes).unwrap());
let mut metrics: Vec<Metrics> = Vec::new();
if let Some(status) = json["status"].as_object() {
for (key, value) in status.iter() {
Expand Down

0 comments on commit e91ed74

Please sign in to comment.