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 basic docker compose setup #108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions docker/bot/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
**/.dockerignore
**/.env
**/.git
**/.github
**/.gitignore
**/.gitmodules
**/.husky
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/node_modules
**/npm-debug.log
**/build
.eslintrc.yml
.git-blame-ignore-revs
.prettierignore
.prettierrc.cjs
docker
indexes
LICENSE.txt
lint-staged.config.mjs
Makefile
package-lock.json
package.json
README.md
run-persist.sh
scripts
SECURITY.md
start.sh
test
tsconfig.json
vitest.config.ts
20 changes: 20 additions & 0 deletions docker/bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# syntax=docker/dockerfile:1

FROM node:current-alpine

RUN --mount=type=bind,source=./package.json,target=package.json \
--mount=type=bind,source=./package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci

RUN adduser -s /bin/bash -D wheatley;echo 'wheatley:wheatley' | chpasswd

USER wheatley

WORKDIR /home/wheatley/bot

COPY . .

RUN npm run build

CMD ["node", "build/src/main.js"]
33 changes: 33 additions & 0 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: wheatley

services:
bot:
container_name: wheatley_bot
image: TCCPP/wheatley
build:
context: ../
dockerfile: docker/bot/Dockerfile
# pull_policy: build
depends_on:
- db
# restart: always

db:
container_name: wheatley_db
image: mongo:latest
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=password
- MONGO_INITDB_DATABASE=wheatley
volumes:
- ./db/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
- ./db/mongod.conf:/etc/mongod.conf:ro
- wheatley_data:/data/db
# expose:
# - 27017
ports:
- 127.0.0.1:27017:27017
# restart: always

volumes:
wheatley_data:
7 changes: 7 additions & 0 deletions docker/db/mongo-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


// https://stackoverflow.com/a/68253550
db = db.getSiblingDB('admin');
db.auth("admin", "password");
db = db.getSiblingDB('wheatley');
db.createUser({user:'wheatley', pwd: 'wheatley', roles:[{db:'wheatley', role:'readWrite'}]});
5 changes: 5 additions & 0 deletions docker/db/mongod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
net:
port: 27017
bindIp: 0.0.0.0
security:
authorization: enabled
Loading