From 465a9cf5cc7d43b64f385744e8189e30ea950e02 Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Wed, 13 Jan 2021 15:38:32 +0100 Subject: [PATCH] Dockerfile + github action build Docker image with github action --- .github/workflows/push.yaml | 38 +++++++++++++++++++++++++++++++++++++ Dockerfile | 12 ++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/push.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml new file mode 100644 index 0000000..88b12da --- /dev/null +++ b/.github/workflows/push.yaml @@ -0,0 +1,38 @@ +name: ci + +on: + push: + branches: main + +jobs: + main: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - id: sha + run: echo "::set-output name=sha::$(git describe --always --tags --dirty)" + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PW }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + platforms: linux/amd64 + tags: leonnicolas/rust-opencl-demo:latest, leonnicolas/rust-opencl-demo:${{ steps.sha.outputs.sha }} + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e4c4909 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM rust as builder +RUN apt-get update +RUN apt-get install ocl-icd-opencl-dev -y +COPY . . +RUN cargo build --release + +FROM nvidia/opencl:devel-ubuntu18.04 +RUN apt-get update +WORKDIR benchmark +COPY --from=builder target/release/rust-opencl-demo . +ENV PATH="${PATH}:/benchmark" +ENTRYPOINT ["./rust-opencl-demo"]