Skip to content

Commit

Permalink
Add basic docker compose setup
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-kenzel committed Jul 15, 2024
1 parent 6c10710 commit 3dfccdb
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
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

0 comments on commit 3dfccdb

Please sign in to comment.