Skip to content

Commit

Permalink
Add deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
vtm9 committed Feb 23, 2022
1 parent 34054b2 commit ecaa2f1
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
Dockerfile
tmp
kubeconfig.yaml
kubeconfig.yml
.env
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.log
.env
coverage
/tmp
kubeconfig.yml
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16-slim

RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates git vim make curl \
&& rm -rf /var/lib/apt/lists/*

COPY package.json .
COPY package-lock.json .

COPY . .

RUN make install-deps

CMD make run
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
PWD:=$(shell pwd)

kb-%: export KUBECONFIG=$(PWD)/kubeconfig.yml

install: install-deps install-env

run:
bin/client.js
./bin/client.js

install-env:
cp env.template .env
Expand All @@ -21,4 +25,16 @@ lint:
publish:
npm publish

.PHONY: test
docker-build:
docker pull codebattle/discord-bot:latest || true
docker build --cache-from=codebattle/discord-bot:latest --tag codebattle/discord-bot:latest .

docker-push:
docker push codebattle/discord-bot:latest

kb-deploy:
kubectl apply -f deployment.yaml

kb-k9s:
k9s
.PHONY: test run
2 changes: 1 addition & 1 deletion bin/client.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/node
#!/usr/bin/env node

require('../index.js');
22 changes: 22 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: discord-bot
labels:
app: discord-bot
spec:
replicas: 1
selector:
matchLabels:
app: discord-bot
template:
metadata:
labels:
app: discord-bot
spec:
containers:
- name: discord-bot
image: codebattle/discord-bot:latest
env:
- name: DEPLOYED
value: "1"
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"bugs": {
"url": "https://github.com/ReDBrother/codebattle_bot/issues"
},
"type": "module",
"jest": {
"testEnvironment": "node",
"transform": {}
Expand Down

0 comments on commit ecaa2f1

Please sign in to comment.