From 295503e8e4be0f40a19924263a70a1597a07c3c0 Mon Sep 17 00:00:00 2001 From: gmega Date: Tue, 29 Oct 2024 19:09:15 -0300 Subject: [PATCH] add docker build/remove unused flows --- .github/workflows/docker.yml | 47 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 36 --------------------- .github/workflows/stale.yml | 23 -------------- docker/bittorrent-tracker.Dockerfile | 11 +++++++ 4 files changed, 58 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/stale.yml create mode 100644 docker/bittorrent-tracker.Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..b041a38 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,47 @@ +name: Docker + +on: + push: + branches: + - master + + workflow_dispatch: + +env: + DOCKER_FILE: docker/bittorrent-tracker.Dockerfile + DOCKER_REPO: codexstorage/bittorrent-tracker + +jobs: + docker: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - 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_TOKEN }} + + - name: Setup Docker Metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_REPO }} + flavor: | + latest=true + tags: | + type=sha + + - name: Build and Push + uses: docker/build-push-action@v6 + with: + context: . + file: ${{ env.DOCKER_FILE }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 037e5ac..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Release - -on: - push: - branches: - - master - -jobs: - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - persist-credentials: false - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Cache - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-npm- - - name: Install dependencies - run: npm i - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 2b2bab3..0000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Mark stale issues and pull requests - -on: - schedule: - - cron: '0 12 * * *' - -jobs: - stale: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - - steps: - - uses: actions/stale@v8 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?' - stale-pr-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?' - exempt-issue-labels: accepted,blocked,bug,dependency,enhancement,'help wanted',question,security,meta - exempt-pr-labels: accepted,blocked,bug,dependency,enhancement,'help wanted',question,security,meta - stale-issue-label: 'stale' - stale-pr-label: 'stale' diff --git a/docker/bittorrent-tracker.Dockerfile b/docker/bittorrent-tracker.Dockerfile new file mode 100644 index 0000000..f324a1f --- /dev/null +++ b/docker/bittorrent-tracker.Dockerfile @@ -0,0 +1,11 @@ +FROM node:22-alpine3.20 + +ENV TRACKER_PORT=8000 + +RUN apk add gcompat + +WORKDIR /opt/bitorrent-tracker +COPY . ./ +RUN npm install + +ENTRYPOINT ["bash", "-c", "/opt/bittorrent-tracker/bin/cmd.js --port ${TRACKER_PORT}"] \ No newline at end of file