Skip to content

Commit

Permalink
Merge pull request #521 from SpaceCowMedia/discord-bot-kubernetes
Browse files Browse the repository at this point in the history
Discord bot kubernetes
  • Loading branch information
ldeluigi authored Aug 22, 2024
2 parents 92fc7a6 + d472e63 commit 69de75a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ jobs:
ECR_REPOSITORY: ${{ secrets.AWS_DISCORD_ECR_REPO_NAME }}
IMAGE_TAG: latest
run: |
docker tag spellbook-backend:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag spellbook-discord-bot:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Rollout pods 🚀
Expand Down
49 changes: 49 additions & 0 deletions backend/.kubernetes/kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,52 @@ roleRef:
name: spellbook-ns-full-access
apiGroup: rbac.authorization.k8s.io

---

apiVersion: apps/v1
kind: Deployment
metadata:
namespace: spellbook
name: spellbook-discord-bot
labels:
app: spellbook-discord-bot
spec:
selector:
matchLabels:
app: spellbook-discord-bot
template:
metadata:
labels:
app: spellbook-discord-bot
spec:
serviceAccountName: app-service-account
containers:
- name: spellbook-discord-bot-app
image: 083767677168.dkr.ecr.us-east-2.amazonaws.com/spellbook-prod-discord-ecr
ports:
- containerPort: 80
livenessProbe:
exec:
command:
- curl
- -f
- https://backend.commanderspellbook.com
initialDelaySeconds: 40
periodSeconds: 20
timeoutSeconds: 5
env:
- name: KUBE_DISCORD_TOKEN
valueFrom:
secretKeyRef:
name: discord-bot-secrets
key: discord-token
- name: KUBE_ADMIN_USER__0
valueFrom:
secretKeyRef:
name: discord-bot-secrets
key: deloo-discord-id
- name: KUBE_ADMIN_USER__1
valueFrom:
secretKeyRef:
name: discord-bot-secrets
key: andy-discord-id
6 changes: 3 additions & 3 deletions bot/discord/spellbook_discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
add_reactions=True,
use_external_emojis=True,
)
administration_guilds = [int(guild) for guild in (os.getenv(f'ADMIN_GUILD__{i}') for i in range(10)) if guild is not None]
administration_users = [int(user) for user in (os.getenv(f'ADMIN_USER__{i}') for i in range(10)) if user is not None]
administration_guilds = [int(guild) for guild in (os.getenv(f'KUBE_ADMIN_GUILD__{i}', os.getenv(f'ADMIN_GUILD__{i}')) for i in range(10)) if guild is not None]
administration_users = [int(user) for user in (os.getenv(f'KUBE_ADMIN_USER__{i}', os.getenv(f'ADMIN_USER__{i}')) for i in range(10)) if user is not None]

MAX_SEARCH_RESULTS = 7

Expand Down Expand Up @@ -346,4 +346,4 @@ async def find_my_combos(interaction: discord.Interaction, decklist: str | None
await interaction.response.send_modal(FindMyCombosModal())


bot.run(os.getenv('DISCORD_TOKEN', ''))
bot.run(os.getenv('KUBE_DISCORD_TOKEN', os.getenv('DISCORD_TOKEN', '')))

0 comments on commit 69de75a

Please sign in to comment.