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