From 183b045f0e1250130e9da2a5fa4041e336a5fab0 Mon Sep 17 00:00:00 2001 From: Joe Burnard Date: Wed, 7 Feb 2024 22:25:33 +0000 Subject: [PATCH] ci --- .dockerignore | 3 +++ .github/workflows/rust.yml | 9 ++++++--- Dockerfile | 9 +++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..36d5f06 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +grafana-storage/ +target/ +Dockerfile \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7ba6882..4b7010f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -16,7 +16,10 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Build - run: cargo build - - name: Run tests - run: cargo test + run: docker build -t ghcr.io/ducc/calories:$GITHUB_SHA -t ghcr.io/ducc/calories:latest -f Dockerfile . + + - name: Push + if: github.ref == 'refs/heads/master' + run: docker push ghcr.io/ducc/calories:$GITHUB_SHA ghcr.io/ducc/calories:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1290889 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM rust:1.75-bullseye as builder +WORKDIR /usr/src/myapp +COPY . . +RUN cargo install --path . + +FROM debian:bullseye-slim +RUN apt-get update && apt-get install -y ca-certificates libssl-dev && rm -rf /var/lib/apt/lists/* +COPY --from=builder /usr/local/cargo/bin/calories /usr/local/bin/calories +CMD ["calories"] \ No newline at end of file