diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2e1fd94 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +.git +.github +.omx +.vscode +.idea +node_modules +dist +build +logs +docs +.env +.env.* +*.log +*.tmp +*.temp +cursor2api-go +cursor2api-go.exe + diff --git a/.github/workflows/docker-ghcr.yml b/.github/workflows/docker-ghcr.yml new file mode 100644 index 0000000..cd44eb8 --- /dev/null +++ b/.github/workflows/docker-ghcr.yml @@ -0,0 +1,86 @@ +name: Publish Docker Image + +on: + workflow_dispatch: + inputs: + push: + description: Push image to GHCR + type: boolean + required: true + default: true + platforms: + description: Target platforms + type: string + required: true + default: linux/amd64,linux/arm64 + push: + branches: + - main + tags: + - "v*" + +permissions: + contents: read + packages: write + +env: + REGISTRY: ghcr.io + +jobs: + docker: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Prepare image metadata + id: prep + shell: bash + run: | + image="${REGISTRY}/${GITHUB_REPOSITORY}" + image="$(echo "${image}" | tr '[:upper:]' '[:lower:]')" + echo "image=${image}" >> "${GITHUB_OUTPUT}" + + should_push=true + if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${{ inputs.push }}" != "true" ]]; then + should_push=false + fi + echo "push=${should_push}" >> "${GITHUB_OUTPUT}" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + if: steps.prep.outputs.push == 'true' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate Docker tags + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.prep.outputs.image }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and publish image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: ${{ github.event_name == 'workflow_dispatch' && inputs.platforms || 'linux/amd64,linux/arm64' }} + push: ${{ steps.prep.outputs.push == 'true' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.gitignore b/.gitignore index 78a19fc..433452a 100644 --- a/.gitignore +++ b/.gitignore @@ -63,5 +63,3 @@ npm-debug.log* yarn-debug.log* yarn-error.log* -# Docker -.dockerignore \ No newline at end of file