Skip to content

Commit

Permalink
Add support for deploying to docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsBrady committed Aug 13, 2024
1 parent 62a8085 commit 677397f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
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 };

0 comments on commit 677397f

Please sign in to comment.