Compare commits
2 Commits
cf3abe92f5
...
9801ba4ba6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9801ba4ba6 | ||
|
|
f6fcf82eae |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -5,8 +5,8 @@ __pycache__
|
||||
|
||||
# dist folders
|
||||
dist
|
||||
frontend/dist
|
||||
backend/dist
|
||||
app/frontend/dist
|
||||
app/backend/dist
|
||||
|
||||
# sqlite file
|
||||
*.db
|
||||
|
||||
51
Dockerfile
51
Dockerfile
@@ -1,51 +0,0 @@
|
||||
# FROM ubuntu:24.04
|
||||
|
||||
# ADD ./loader/loader-crm /etc/cron.d/loader-crm
|
||||
# RUN chmod 0644 /etc/cron/loader-crm
|
||||
# RUN touch /var/log/chron.log
|
||||
|
||||
# RUN apt-get update
|
||||
# RUN apt-get -y install cron
|
||||
# RUN systemctl enable cron
|
||||
|
||||
# Setup the loader
|
||||
FROM python:3.12 AS loader
|
||||
COPY ./loader /srv/cprush-stats
|
||||
WORKDIR /srv/cprush-stats
|
||||
RUN python -m pip install --upgrade pip
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
CMD ["python3", "createrushdatabase.py"]
|
||||
|
||||
FROM node:23
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
# build the frontend
|
||||
COPY ./frontend /frontend
|
||||
WORKDIR /frontend
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
RUN mkdir -p /srv/cprush-stats/frontend
|
||||
RUN cp -rf ./dist/* /srv/cprush-stats/frontend
|
||||
|
||||
# build the backend
|
||||
COPY ./backend /backend
|
||||
WORKDIR /backend
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
RUN mkdir -p /srv/cprush-stats
|
||||
RUN cp -rf ./dist/* /srv/cprush-stats
|
||||
RUN cp package.json /srv/cprush-stats/package.json
|
||||
|
||||
WORKDIR loader
|
||||
|
||||
EXPOSE 3001
|
||||
ENV NODE_ENV=production
|
||||
ENV MEMCACHE_ADDR="localhost:11211"
|
||||
|
||||
COPY --from=loader /srv/cprush-stats/testdb.db /srv/cprush-stats/testdb.db
|
||||
|
||||
WORKDIR /srv/cprush-stats
|
||||
RUN npm install
|
||||
CMD ["sh", "-c", "node app.js -m $MEMCACHE_ADDR"]
|
||||
41
app/Dockerfile
Normal file
41
app/Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
||||
FROM node:23 AS frontend
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
# build the frontend
|
||||
COPY ./frontend /frontend
|
||||
WORKDIR /frontend
|
||||
RUN npm install
|
||||
CMD ["npm", "run", "build"]
|
||||
# RUN mkdir -p /srv/cprush-stats/frontend
|
||||
# RUN cp -rf ./dist/* /srv/cprush-stats/frontend
|
||||
|
||||
FROM node:23 AS backend
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
# build the backend
|
||||
COPY ./backend /backend
|
||||
WORKDIR /backend
|
||||
RUN npm install
|
||||
CMD ["npm", "run", "build"]
|
||||
# RUN mkdir -p /srv/cprush-stats
|
||||
# RUN cp -rf ./dist/* /srv/cprush-stats
|
||||
# RUN cp package.json /srv/cprush-stats/package.json
|
||||
|
||||
FROM node:23 AS server
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
RUN mkdir -p /srv/cprush-stats/frontend
|
||||
COPY --from=frontend /frontend/dist /srv/cprush-stats/frontend
|
||||
COPY --from=backend /backend/dist /srv/cprush-stats
|
||||
COPY --from=backend /backend/package.json /srv/cprush-stats/package.json
|
||||
|
||||
EXPOSE 3001
|
||||
ENV NODE_ENV=production
|
||||
ENV MEMCACHE_ADDR="localhost:11211"
|
||||
|
||||
WORKDIR /srv/cprush-stats
|
||||
RUN npm install
|
||||
CMD ["sh", "-c", "node app.js -m $MEMCACHE_ADDR"]
|
||||
@@ -19,7 +19,6 @@ const port = process.argv[process.argv.indexOf('-p')]
|
||||
const memcache_addr = process.argv[process.argv.indexOf('-m')]
|
||||
? process.argv[process.argv.indexOf('-m') + 1]
|
||||
: 'localhost:11211'
|
||||
// const memcache = new memcached('localhost:11211', {})
|
||||
const memcachep = new Memcache(memcache_addr)
|
||||
|
||||
addGameApis(app, jsonParser, memcachep)
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 526 B After Width: | Height: | Size: 526 B |
@@ -6,7 +6,8 @@ networks:
|
||||
|
||||
services:
|
||||
cprush:
|
||||
image: potato
|
||||
# image: potato
|
||||
build: ./app
|
||||
networks:
|
||||
- cprush-net
|
||||
environment:
|
||||
@@ -15,6 +16,10 @@ services:
|
||||
- 3001:3001
|
||||
depends_on:
|
||||
- memcache
|
||||
loader:
|
||||
build: ./loader
|
||||
environment:
|
||||
- REPLAY_TIME=600
|
||||
memcache:
|
||||
image: memcached
|
||||
networks:
|
||||
|
||||
11
loader/Dockerfile
Normal file
11
loader/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
# Setup the loader
|
||||
FROM python:3.12 AS loader
|
||||
COPY . /loader
|
||||
WORKDIR /loader
|
||||
RUN python -m pip install --upgrade pip
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
ENV REPLAY_TIME=0
|
||||
|
||||
|
||||
CMD ["sh", "-c", "python3 createrushdatabase.py -r $REPLAY_TIME"]
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
|
||||
PYTHON_VEN="$parent_path"/venv/bin/python
|
||||
if [ ! -f $PYTHON_VEN ]; then
|
||||
echo "Setting up new VENV"
|
||||
python3 -m venv venv
|
||||
echo "Installing requirements."
|
||||
source ./venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
deactivate
|
||||
fi
|
||||
|
||||
echo "Start DB Creation"
|
||||
$parent_path/venv/bin/python createrushdatabase.py
|
||||
@@ -1,9 +1,18 @@
|
||||
import time
|
||||
import argparse
|
||||
|
||||
from databasesync import createDatabase
|
||||
from sheetloader import downloadGamesCSV, downloadCharactersCSV
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-r", "--replay_time", type=int)
|
||||
args = parser.parse_args()
|
||||
|
||||
CHARACTER_DATA_OUT_FILE = "CharacterData.csv"
|
||||
GAME_DATA_OUT_FILE = "GameData.csv"
|
||||
DATABASE_NAME = "testdb.db"
|
||||
|
||||
|
||||
|
||||
def execute():
|
||||
downloadCharactersCSV(CHARACTER_DATA_OUT_FILE)
|
||||
@@ -11,4 +20,10 @@ def execute():
|
||||
createDatabase(DATABASE_NAME, GAME_DATA_OUT_FILE, CHARACTER_DATA_OUT_FILE)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("starting up loader.")
|
||||
print("replay time: ", args.replay_time)
|
||||
execute()
|
||||
while args.replay_time and args.replay_time > 0:
|
||||
print("re-run in ", args.replay_time, "seconds", flush=True)
|
||||
time.sleep(args.replay_time)
|
||||
execute()
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
*/10 * * * * python3 /loader/createrushdatabase.py
|
||||
Reference in New Issue
Block a user