From eff79d3cfbc094f0d79899466085d8c3f1d55691 Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Tue, 6 Sep 2022 01:06:56 +0000 Subject: [PATCH] feat: github action build for DockerHub --- .../workflows/create_release_and_build.yml | 31 +++++++++++++------ containerised/Dockerfile | 4 +-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/create_release_and_build.yml b/.github/workflows/create_release_and_build.yml index 0d629ae..e1bf3ee 100644 --- a/.github/workflows/create_release_and_build.yml +++ b/.github/workflows/create_release_and_build.yml @@ -7,16 +7,8 @@ jobs: deploy: runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@master - - # cache some rust data? - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Checkout + uses: actions/checkout@v3 # Build for linux x86_64 - name: build release linux_x86_64 @@ -72,6 +64,25 @@ jobs: - name: compress windows_x86_64 binary run: zip -j ./oxker_windows_x86_64.zip target/x86_64-pc-windows-gnu/release/oxker.exe + # Build images for Dockerhub + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + - name: Build for Docker Hub + run: | + docker build --platform linux/arm/v6,linux/arm64,linux/amd64 \ + -t ${{ secrets.DOCKERHUB_USERNAME }}/oxker:latest \ + --push \ + -f containerised/Dockerfile . + + - name: Release uses: softprops/action-gh-release@v1 with: diff --git a/containerised/Dockerfile b/containerised/Dockerfile index d5e77ca..acff8c2 100644 --- a/containerised/Dockerfile +++ b/containerised/Dockerfile @@ -22,7 +22,7 @@ WORKDIR /usr/src RUN cargo new oxker # We want dependencies cached, so copy those first -COPY Cargo.toml Cargo.lock /usr/src/oxker/ +COPY Cargo.* /usr/src/oxker/ # Set the working directory WORKDIR /usr/src/oxker @@ -55,4 +55,4 @@ COPY --from=builder /oxker /usr/local/bin COPY ./containerised/start_oxker.sh ./ # Run the application -ENTRYPOINT [ "./start_oxker.sh"] \ No newline at end of file +ENTRYPOINT [ "./start_oxker.sh"]