Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for deploying to docker container #21

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:lts
WORKDIR /app
COPY package.json yarn.lock tsconfig.json .
RUN corepack enable && \
yarn workspaces focus --production && \
yarn install --immutable
COPY config.json .
COPY scripts ./scripts
COPY src ./src
RUN yarn tsc
CMD ["yarn", "prod"]
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Discord bot for the Mars Rover Design Team's Discord server

## Running

Rename `config_example.json` to `config.json` and place your bot's token in the `token` field and the client ID in the `clientID` field of that file.
The `guildID` is the guild that you use to test the commands and the server that slash commands will be auto-updated on.
Set Environment variables:

Use `yarn start` to compile and run the bot.
- `BOTTOKEN` is your bot's token
- `CLIENTID` is your app's client ID
- `GUILDID` is the guild that dev commands will be deployed to

Use `yarn start` to compile and run the bot or `yarn prod` to run an already built project.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"typescript": "^5.5.4"
},
"scripts": {
"prod": "node .",
"start": "yarn tsc && node .",
"build": "yarn tsc",
"deploydev": "yarn tsc && node build/scripts/deployDev.js",
Expand Down
4 changes: 2 additions & 2 deletions scripts/deployDev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ client.once('ready', async (client: Client) => {

if (client.application) {
await client.application.commands
.set(commandsData, config.guildId)
.set(commandsData, process.env.GUILDID!)
.then(() => console.log('Updated Dev commands'))
.catch(console.error);
} else console.log('No Client app');

exit();
});

client.login(config.token);
client.login(process.env.BOTTOKEN!);
2 changes: 1 addition & 1 deletion scripts/deployGlobal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ client.once('ready', async (client: Client) => {
exit();
});

client.login(config.token);
client.login(process.env.BOTTOKEN!);
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ client.on('interactionCreate', async (interaction: Interaction) => {
}
});

client.login(config.token);
client.login(process.env.BOTTOKEN);

export { client };