modify Dockerfile

+ add special instructions for @volcs0 for debugging
This commit is contained in:
mungai-njoroge 2023-09-20 03:06:01 +03:00
parent f2e110a564
commit ad88ab4adb
6 changed files with 67 additions and 33 deletions

View File

@ -1,22 +1,8 @@
FROM node:latest AS CLIENT
FROM ubuntu:latest
RUN git clone https://github.com/swing-opensource/swingmusic-client.git client
WORKDIR /
WORKDIR /client
RUN git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
RUN yarn install
RUN yarn build
FROM python:latest
WORKDIR /app/swingmusic
COPY . .
COPY --from=CLIENT /client/dist/ client
COPY ./dist/swingmusic /swingmusic
EXPOSE 1970/tcp
@ -24,10 +10,4 @@ VOLUME /music
VOLUME /config
RUN pip install poetry
RUN poetry config virtualenvs.create false
RUN poetry install
ENTRYPOINT ["poetry", "run", "python", "manage.py", "--host", "0.0.0.0", "--config", "/config"]
ENTRYPOINT ["/swingmusic", "--host", "0.0.0.0", "--config", "/config"]

35
Dockerfile.og Normal file
View File

@ -0,0 +1,35 @@
FROM node:latest AS CLIENT
RUN git clone https://github.com/swing-opensource/swingmusic-client.git client
WORKDIR /client
RUN git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
RUN yarn install
RUN yarn build
FROM python:latest
WORKDIR /app/swingmusic
COPY . .
COPY --from=CLIENT /client/dist/ client
EXPOSE 1970/tcp
VOLUME /music
VOLUME /config
RUN pip install poetry
RUN poetry config virtualenvs.create false
RUN poetry install
ENV LASTFM_API_KEY="45c6776a1029a280fabd6a2c8158023d"
ENTRYPOINT ["poetry", "run", "python", "manage.py", "--host", "0.0.0.0", "--config", "/config"]

View File

@ -39,7 +39,7 @@ class HandleArgs:
Runs Pyinstaller.
"""
# get last.fm api key from env
last_fm_key = os.environ.get("LASTFM_API_KEY")
last_fm_key = settings.Keys.LASTFM_API
# if the key is not in env, exit
if not last_fm_key:

View File

@ -4,11 +4,14 @@ interacting with the tracks table.
"""
from collections import OrderedDict
import random
from sqlite3 import Cursor
from app.db.sqlite.utils import tuple_to_track, tuples_to_tracks
from .utils import SQLiteManager
from app.logger import log
from pprint import pprint
class SQLiteTrackMethods:
@ -44,12 +47,21 @@ class SQLiteTrackMethods:
track = OrderedDict(sorted(track.items()))
def force_surrogatepass(string: str):
return string.encode("utf-16", "surrogatepass").decode("utf-16")
# def should_fail():
# """
# Return true randomly.
# """
# return random.randint(0, 1) == 1
for key, value in track.items():
if isinstance(value, str):
track[key] = force_surrogatepass(value)
# if should_fail():
# raise Exception("Failed to insert track")
# def force_surrogatepass(string: str):
# return string.encode("utf-16", "surrogatepass").decode("utf-16")
# for key, value in track.items():
# if isinstance(value, str):
# track[key] = force_surrogatepass(value)
track["artist"] = track["artists"]
track["albumartist"] = track["albumartists"]
@ -64,9 +76,16 @@ class SQLiteTrackMethods:
"""
Inserts a list of tracks into the database.
"""
log.info("Send me the JSON below for debugging.")
with SQLiteManager() as cur:
for track in tracks:
cls.insert_one_track(track, cur)
try:
cls.insert_one_track(track, cur)
except Exception:
pprint(track, indent=4)
log.error("Send me the JSON above for debugging. Use https://pastebin.com and share the link.")
@staticmethod
def get_all_tracks():

View File

@ -334,4 +334,4 @@ class FetchSimilarArtistsLastFM:
# any exception that can be raised by the pool
except Exception as e:
log.warn(e)
pass
return

View File

@ -5,7 +5,6 @@ create the config directory and copy the assets to the app directory.
import os
import shutil
import sys
from configparser import ConfigParser
from app import settings
@ -21,6 +20,7 @@ IS_BUILD = config["DEFAULT"]["BUILD"] == "True"
if IS_BUILD:
settings.Keys.LASTFM_API = config["DEFAULT"]["LASTFM_API_KEY"]
class CopyFiles:
"""Copies assets to the app directory."""