diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..1686e399 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,43 @@ +name: Publication Docker image + +on: [push] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Login Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: all + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v1 + id: buildx + - name: Cache Docker Image Layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Build and Push Docker Image + uses: docker/build-push-action@v2 + id: docker_build + with: + context: ./ + file: ./Dockerfile + builder: ${{ steps.buildx.outputs.name }} + platforms: linux/amd64, linux/arm64, linux/aarch64 + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/imaginaryprototype:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache,mode=max + - name: Verify + run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 67c699be..07d4a01e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,9 @@ RUN go mod download COPY . . # Run quality control -RUN go test ./... -test.v -race -test.coverprofile=atomic . +# RUN go test ./... -test.v -race -test.coverprofile=atomic . +ARG TARGETPLATFORM +RUN if [ "$TARGETPLATFORM" = "linux/arm64" ] ; then go test ./... -test.v -test.coverprofile=atomic . ; else go test ./... -test.v -race -test.coverprofile=atomic . ; fi RUN golangci-lint run . # Compile imaginary