Bugfixes and Docker dev test script

This commit is contained in:
krateng 2022-02-20 05:06:38 +01:00
parent 0f473599a7
commit d3258a7e63
7 changed files with 46 additions and 3 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@
/*.yml
/pylintrc
.venv/*
/testdata
# build
/dist

View File

@ -24,6 +24,7 @@ RUN \
# expected behavior for a default setup is for maloja to "just work"
ENV MALOJA_SKIP_SETUP=yes
ENV MALOJA_HOST=0.0.0.0
EXPOSE 42010
# use exec form for better signal handling https://docs.docker.com/engine/reference/builder/#entrypoint

33
Dockerfile-dev Normal file
View File

@ -0,0 +1,33 @@
FROM python:3-alpine
# Based on the work of Jonathan Boeckel <jonathanboeckel1996@gmail.com>
# https://gitlab.com/Joniator/docker-maloja
# https://github.com/Joniator
WORKDIR /usr/src/app
# Copy project into dir
COPY ./install ./install
COPY ./requirements.txt ./requirements.txt
# Build dependencies (This will pipe all packages from the file)
RUN sed 's/#.*//' ./install/dependencies_build.txt | xargs apk add --no-cache --virtual .build-deps
# Runtime dependencies (Same)
RUN sed 's/#.*//' ./install/dependencies_run.txt | xargs apk add --no-cache
# Python dependencies
RUN pip3 install --no-cache-dir -r requirements.txt
# Local project install
COPY . .
RUN pip3 install /usr/src/app
# Remove build dependencies
RUN apk del .build-deps
# expected behavior for a default setup is for maloja to "just work"
ENV MALOJA_SKIP_SETUP=yes
ENV MALOJA_HOST=0.0.0.0
EXPOSE 42010
# use exec form for better signal handling https://docs.docker.com/engine/reference/builder/#entrypoint
ENTRYPOINT ["maloja", "run"]

2
dockertest.sh Normal file
View File

@ -0,0 +1,2 @@
docker build -t maloja-dev . -f Dockerfile-dev
docker run -p 42010:42010 -v $PWD/testdata:/mlj -e MALOJA_DATA_DIRECTORY=/mlj maloja-dev

View File

@ -462,8 +462,12 @@ def start_db():
dbstatus['healthy'] = True
# inform time module about begin of scrobbling
firstscrobble = sqldb.get_scrobbles()[0]
register_scrobbletime(firstscrobble['time'])
try:
firstscrobble = sqldb.get_scrobbles()[0]
register_scrobbletime(firstscrobble['time'])
except IndexError:
register_scrobbletime(int(datetime.datetime.now().timestamp()))
# create cached information
cached.update_medals()

View File

@ -68,11 +68,12 @@ def setup():
newpw = prompt("Please set a password for web backend access. Leave this empty to generate a random password.",skip=SKIP,secret=True)
if newpw is None:
newpw = randomstring(32)
newpw_repeat = newpw
print("Generated password:",col["yellow"](newpw))
else:
newpw_repeat = prompt("Please type again to confirm.",skip=SKIP,secret=True)
if newpw != newpw_repeat: print("Passwords do not match!")
else: auth.defaultuser.setpw(newpw)
auth.defaultuser.setpw(newpw)
if malojaconfig["SEND_STATS"] is None:
answer = ask("I would like to know how many people use Maloja. Would it be okay to send a daily ping to my server (this contains no data that isn't accessible via your web interface already)?",default=True,skip=SKIP)

View File

@ -284,6 +284,7 @@ def run_server():
try:
#run(webserver, host=HOST, port=MAIN_PORT, server='waitress')
log(f"Listening on {HOST}:{PORT}")
waitress.serve(webserver, host=HOST, port=PORT, threads=THREADS)
except OSError:
log("Error. Is another Maloja process already running?")