diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0b9f266 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,43 @@ +name: Publish to Docker Hub + +on: + push: + branches: + - "main" + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Get latest version + run: | + curl -s https://api.github.com/repos/pocketbase/pocketbase/releases/latest \ + | grep "tag_name" \ + | awk '{print $2}' \ + | tr -d '"' \ + | tr -d ',' \ + | tr -d 'v' \ + | tr -d ' ' \ + >> $VERSION + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + sernhandler/pocketbase:latest + sernhandler/pocketbase:$VERSION + build-args: | + VERSION=$VERSION \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 91f6dc0..56042b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,9 @@ FROM alpine:latest AS download ARG VERSION -ADD https://github.com/pocketbase/pocketbase/releases/download/v${VERSION}/pocketbase_${VERSION}_linux_amd64.zip /pb.zip +ARG BUILDARCH + +ADD https://github.com/pocketbase/pocketbase/releases/download/v${VERSION}/pocketbase_${VERSION}_linux_${BUILDARCH}.zip /pb.zip RUN unzip /pb.zip && chmod +x /pocketbase FROM alpine