diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cb80ae7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,121 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test +.env.production + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# Config file +config.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4d5e0e2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release + +on: + push: + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + tapnisu/forwarding-discord-telegram + ghcr.io/tapnisu/forwarding-discord-telegram + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=sha + + - 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 + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7a53409 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM node:18-alpine3.20 AS base +LABEL authors="tapnisu" + +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" + +WORKDIR /app + +COPY package.json pnpm-lock.yaml /app/ +RUN corepack enable && corepack prepare + +FROM base AS prod-deps +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile + +FROM base AS build +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile + +COPY . /app +RUN pnpm run build + +FROM base +COPY --from=build /app/dist /app/dist +COPY --from=prod-deps /app/node_modules /app/node_modules + +CMD [ "pnpm", "run", "start" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d0c45dd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +name: forwarding-discord-telegram +services: + bot: + image: tapnisu/forwarding-discord-telegram:main + environment: + DISCORD_TOKEN: ${DISCORD_TOKEN} + TELEGRAM_TOKEN: ${TELEGRAM_TOKEN} + TELEGRAM_CHAT_ID: ${TELEGRAM_CHAT_ID} + volumes: + - ./config.json:/app/config.json + restart: unless-stopped diff --git a/package.json b/package.json index 4fcc6b7..ddd46d9 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "@grammyjs/auto-retry": "^2.0.2", "discord.js-selfbot-v13": "^3.4.0", "dotenv": "^16.4.5", - "grammy": "^1.30.0" + "grammy": "^1.30.0", + "prettier": "^3.3.3" }, "devDependencies": { "@eslint/compat": "^1.2.0", @@ -40,7 +41,6 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", "globals": "^15.11.0", - "prettier": "^3.3.3", "typescript": "^5.6.3", "typescript-eslint": "^8.8.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 43e34cd..6a44d4c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: grammy: specifier: ^1.30.0 version: 1.30.0 + prettier: + specifier: ^3.3.3 + version: 3.3.3 devDependencies: '@eslint/compat': specifier: ^1.2.0 @@ -42,9 +45,6 @@ importers: globals: specifier: ^15.11.0 version: 15.11.0 - prettier: - specifier: ^3.3.3 - version: 3.3.3 typescript: specifier: ^5.6.3 version: 5.6.3