Skip to content
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
22 changes: 22 additions & 0 deletions .docker/config/init-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e
set -u

function create_user_and_database() {
local database=$1
echo " Creating user and database '$database'"
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER $database;
CREATE DATABASE $database;
GRANT ALL PRIVILEGES ON DATABASE $database TO $database;
EOSQL
}

if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES"
for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do
create_user_and_database $db
done
echo "Multiple databases created"
fi
119 changes: 119 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
version: "3.7"
services:

db:
image: postgres:14-alpine
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASS}
POSTGRES_MULTIPLE_DATABASES: ${DB_DATABASES}
volumes:
- ./config/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
- ./.tmp/db:/var/lib/postgresql/data

redis:
image: redis:7-alpine
ports:
- 6379:6379
command: redis-server --save 60 1 --loglevel warning

api:
image: ${DOCKER_BOT}
command:
- npm
- run-script
- api
environment:
LOGGING_LEVEL: info
API_SECURITY_TOKEN: ${API_SECURITY_TOKEN}
DATABASE_URL: ${DATABASE}
API_PORT: ${API_PORT}
ports:
- ${API_PORT}:${API_PORT}
depends_on:
- db
restart: always


chain:
image: ${DOCKER_BOT}
command:
- npm
- run-script
- chain
environment:
LOGGING_LEVEL: info
DATABASE_URL: ${DATABASE}
GRAPH_URL: ${GRAPH_URL}
CHAIN_RPC_URL: ${CHAIN_RPC_URL}
CHAIN_ACCOUNT: ${CHAIN_ACCOUNT}
depends_on:
- db
- api
restart: always


aggregation:
image: ${DOCKER_BOT}
command:
- npm
- run-script
- service
environment:
LOGGING_LEVEL: info
DATABASE_URL: ${DATABASE}
depends_on:
- db
- api
restart: always


# discord:
# image: ${DOCKER_BOT}
# command:
# - npm
# - run-script
# - discord
# environment:
# LOGGING_LEVEL: info
# DATABASE_URL: ${DATABASE}
# DISCORD_BOT_KEY:
# depends_on:
# - db
# - api
# restart: always


# twitter:
# image: ${DOCKER_BOT}
# command:
# - npm
# - run-script
# - twitter
# environment:
# LOGGING_LEVEL: info
# DATABASE_URL: ${DATABASE}
# TWITTER_BEARER_TOKEN:
# depends_on:
# - db
# - api
# restart: always


# epic-games:
# image: ${DOCKER_BOT}
# command:
# - npm
# - run-script
# - epicGames
# environment:
# LOGGING_LEVEL: info
# DATABASE_URL: ${DATABASE}
# EPIC_GAMES_DEPLOYMENT_ID:
# EPIC_GAMES_CLIENT_ID:
# EPIC_GAMES_CLIENT_SECRET:
# depends_on:
# - db
# - api
# restart: always

10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dist
lib
.editorconfig
.gitignore
.docker
.trunk
.env*
.gitignore
Dockerfile
README.md
7 changes: 0 additions & 7 deletions .env.template

This file was deleted.

6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ dist

# TernJS port file
.tern-port



.tmp
lib
dist
**.local
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
FROM node:19-alpine
# to build on apple silicone use
# DOCKER_DEFAULT_PLATFORM=linux/amd64 docker build -t battlepass-bot:local .
FROM --platform=linux/amd64 node:lts-alpine
# FROM node:lts-alpine

RUN apk add --no-cache --virtual python make g++
RUN apk add --no-cache --virtual .gyp

WORKDIR /app
COPY src /app/src
COPY *.json /app/
COPY jest.config.js /app/
COPY . .

RUN npm install && apk del .gyp
# RUN npm run build

RUN npm install
RUN npx tsc
CMD ["npm", "run-script", "api"]
93 changes: 0 additions & 93 deletions docker-compose.yaml

This file was deleted.

Loading