update for self-deploy using Docker

update

update

update for self-deploy using Docker
This commit is contained in:
Gabriel Kheisa 2024-04-07 14:49:12 +07:00 committed by gabrielkheisa
parent 8c572600c0
commit 5b41c99602
3 changed files with 82 additions and 21 deletions

20
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: Docker Build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build Docker image
run: docker build -t discord-badge .

29
Dockerfile Normal file
View File

@ -0,0 +1,29 @@
# Stage 1: Build stage
FROM node:16 AS builder
# Set the working directory in the builder stage
WORKDIR /usr/src/app
# Copy the package.json and package-lock.json files to the builder stage
COPY package*.json ./
# Install npm dependencies in the builder stage
RUN npm install
# Copy the rest of the application code to the builder stage
COPY . .
# Stage 2: Production stage
FROM node:16-alpine
# Set the working directory in the production stage
WORKDIR /usr/src/app
# Copy the built artifacts from the builder stage to the production stage
COPY --from=builder /usr/src/app .
# Expose the port the app runs on
EXPOSE 3000
# Command to run the application in the production stage
CMD ["node", "index.js"]

View File

@ -15,28 +15,40 @@ If you're still learning and want the badge, follow the instructions below!
# Instructions # Instructions
1. Go to https://discord.com/developers/applications, and create a new application on the account you want the badge on.
- Go to https://discord.com/developers/applications, and create a new application on the account you want the badge on. 2. Go to the bot tab and generate a bot account for the application.
- Go to the bot tab and generate a bot account for the application. 3. Click the "Reset Token" button to generate a token (if you have 2fa enabled, you'll need your code).
- Click the "Reset Token" button to generate a token (if you have 2fa enabled, you'll need your code). 4. Copy the token to your clipboard.
- Copy the token to your clipboard. 5. Click this badge to clone this repo to a new repl in Replit -> [![Run on Repl.it](https://replit.com/badge/github/hackermondev/discord-active-developer-badge)](https://replit.com/new/github/hackermondev/discord-active-developer-badge)
- Click this badge to clone this repo to a new repl in Replit -> [![Run on Repl.it](https://replit.com/badge/github/hackermondev/discord-active-developer-badge)](https://replit.com/new/github/hackermondev/discord-active-developer-badge) 6. You will be redirected to Replit, you might have to create an account (you can Register with Google).
- You will be redirected to Replit, you might have to create an account (you can Register with Google).
- Replit is a website, and does not run off your computer! - Replit is a website, and does not run off your computer!
- Wait for the repo has finished cloning and the repl to fully connect. 7. Wait for the repo has finished cloning and the repl to fully connect.
- Click the green "Run" button at the top. 8. Click the green "Run" button at the top.
- Go to the console (big black square on the right) and paste in the token you copied earlier (**Note**: ``CTRL + V`` won't work, you'll need to do ``CTRL + Shift + V`` or right-click and click paste). 9. Go to the console (big black square on the right) and paste in the token you copied earlier (**Note**: ``CTRL + V`` won't work, you'll need to do ``CTRL + Shift + V`` or right-click and click paste).
- Press the 'Enter' key. 10. Press the 'Enter' key.
- Wait for it to print 'DONE | Application/Bot is up and running. DO NOT CLOSE THIS TAB UNLESS YOU ARE FINISHED USING THE BOT, IT WILL PUT THE BOT OFFLINE.' in the console, **DON'T STOP THE PROGRAM OR CLOSE THE TAB YET OR THE BOT WILL CONSIDERED BY DISCORD AS 'UNRESPONSIVE'** 11. Wait for it to print 'DONE | Application/Bot is up and running. DO NOT CLOSE THIS TAB UNLESS YOU ARE FINISHED USING THE BOT, IT WILL PUT THE BOT OFFLINE.' in the console, **DON'T STOP THE PROGRAM OR CLOSE THE TAB YET OR THE BOT WILL CONSIDERED BY DISCORD AS 'UNRESPONSIVE'**
- Go back to the application page, go to the "General Information" tab, scroll down and copy application id. 12. Go back to the application page, go to the "General Information" tab, scroll down and copy application id.
- Create a new discord server (you can delete it at the end). 13. Create a new discord server (you can delete it at the end).
- Enable community on the server (you only need to do this if you don't own any other discord server with community enabled) 14. Enable community on the server (you only need to do this if you don't own any other discord server with community enabled)
- Return back to https://discord.com/developers/applications. 15. Return back to https://discord.com/developers/applications.
- Copy the application id. 16. Copy the application id.
- Use this invite link to add the application to the server: (replace ``{applicationid}`` with what you copied) ``https://discord.com/oauth2/authorize?client_id={applicationid}&scope=bot%20applications.commands&permissions=105227086912`` 17. Use this invite link to add the application to the server: (replace ``{applicationid}`` with what you copied) ``https://discord.com/oauth2/authorize?client_id={applicationid}&scope=bot%20applications.commands&permissions=105227086912``
- In the server, go to a channel and use the ``/ping`` command on the bot. 18. In the server, go to a channel and use the ``/ping`` command on the bot.
- Go to the <https://discord.com/developers/active-developer> page and register everything (**if it says you're not eligible, it's because you're not registered in their system yet. you might have to wait up to 24 hours**). 19. Go to the <https://discord.com/developers/active-developer> page and register everything (**if it says you're not eligible, it's because you're not registered in their system yet. you might have to wait up to 24 hours**).
- Congrats on that shiny new badge. 20. Congrats on that shiny new badge.
## Instructions with Docker
### With Dockerfile
1. Follow step 1 to 4 from the main instruction above
2. Build the Dockerfile
```bash
docker build -t discord-badge .
```
3. Run the container and insert your Discord bot token
```bash
docker run -it -p 3000:3000 discord-badge
```
4. Jump directly to step 12 and follow the remaining steps from the main instruction
**NOTE:** Make sure you have the “Use data to improve Discord” setting enabled under User Settings > Privacy & Safety otherwise you won't be able to be marked as eligible. **NOTE:** Make sure you have the “Use data to improve Discord” setting enabled under User Settings > Privacy & Safety otherwise you won't be able to be marked as eligible.