diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 95be74f..e659e8a 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,2 @@ -patreon: vas3k ko_fi: vas3k -custom: ['https://vas3k.com/donate/', 'https://paypal.me/vas3kcom'] +custom: ["https://vas3k.com/donate/", "https://paypal.me/vas3kcom"] diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 0000000..91152a0 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,72 @@ +name: Build and Publish Docker Image + +on: + push: + tags: + - "v*" + +jobs: + build-and-push: + name: Build and Push to GHCR + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{version}} + type=raw,value=latest + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Get release + id: get_release + uses: bruceadams/get-release@v1.3.2 + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Attach image to release + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs'); + const release_id = '${{ steps.get_release.outputs.id }}'; + const tag_name = '${{ github.ref_name }}'; + const image_name = 'ghcr.io/${{ github.repository }}:${{ github.ref_name }}'; + + await github.rest.repos.updateRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release_id, + body: `Docker image: \`${image_name}\`\n\nAlso available as \`ghcr.io/${{ github.repository }}:latest\`` + }); + + console.log(`Updated release ${release_id} with Docker image information`); diff --git a/README.md b/README.md index 5b75c30..44e1de3 100644 --- a/README.md +++ b/README.md @@ -123,16 +123,24 @@ Deploy your own instance of TaxHacker with Vercel in just a few clicks: For server deployment, we provide a [Docker image](./Dockerfile) and [Docker Compose](./docker-compose.yml) files that makes setting up TaxHacker simple: +```bash +docker run --name taxhacker ghcr.io/vas3k/taxhacker:latest +``` + +You can also use docker-compose to start everything together: + ```bash # Clone the repository git clone https://github.com/vas3k/TaxHacker.git cd TaxHacker -# Run docker compose +# Or use docker-compose (recommended) docker compose up ``` -For more advanced setups, you can adapt Docker Compose configuration to your own needs. +New docker image is automatically built and published on every new release. You can use specific version tags (e.g. `v1.0.0`) or `latest` for the most recent version. + +For more advanced setups, you can adapt Docker Compose configuration to your own needs. The default configuration uses the pre-built image from GHCR, but you can still build locally using the provided [Dockerfile](./Dockerfile) if needed. ### Environment Variables diff --git a/docker-compose.build.yml b/docker-compose.build.yml new file mode 100644 index 0000000..88d24e8 --- /dev/null +++ b/docker-compose.build.yml @@ -0,0 +1,23 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + ports: + - "3000:3000" + environment: + - UPLOAD_PATH=/app/uploads + - NODE_ENV=production + - DATABASE_URL=file:/app/data/db.sqlite + volumes: + - ./uploads:/app/uploads + - ./data:/app/data + restart: unless-stopped + logging: + driver: "local" + options: + max-size: "100M" + max-file: "3" + +volumes: + app_data: diff --git a/docker-compose.yml b/docker-compose.yml index 88d24e8..2fd7cc5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,6 @@ services: app: - build: - context: . - dockerfile: Dockerfile + image: ghcr.io/vas3k/taxhacker:latest ports: - "3000:3000" environment: