Skip to content

Commit

Permalink
added ffmpeg to docker, improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
teticio committed Aug 26, 2021
1 parent 5f034ae commit 87dc1e6
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_API_URL='http://localhost:8000/api/v1'
REACT_APP_API_URL='http://localhost:8001/api/v1'
3 changes: 2 additions & 1 deletion backend/deejai.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import random
import shutil
import librosa
import logging
import requests
import numpy as np
from io import BytesIO
Expand Down Expand Up @@ -229,7 +230,7 @@ def _get_similar_vec():
]
return ids
except Exception as e:
print(e)
logging.error(e)
if os.path.exists(f'./{playlist_id}.mp3'):
os.remove(f'./{playlist_id}.mp3')
return []
9 changes: 5 additions & 4 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def get_db():
"https://deej-ai.online",
"http://localhost:8000",
"http://localhost:3000",
"http://127.0.0.1:8080",
]

app.add_middleware(
Expand Down Expand Up @@ -79,8 +80,8 @@ async def spotify_callback(code: str, state: Optional[str] = '/'):
headers = {
'Authorization':
'Basic ' +
b64encode(f'{credentials.client_id}:{credentials.client_secret}'
.encode('utf-8')).decode('utf-8')
b64encode(f'{credentials.client_id}:{credentials.client_secret}'.
encode('utf-8')).decode('utf-8')
}
async with aiohttp.ClientSession() as session:
try:
Expand Down Expand Up @@ -108,8 +109,8 @@ async def spotify_refresh_token(refresh_token: str):
headers = {
'Authorization':
'Basic ' +
b64encode(f'{credentials.client_id}:{credentials.client_secret}'
.encode('utf-8')).decode('utf-8')
b64encode(f'{credentials.client_id}:{credentials.client_secret}'.
encode('utf-8')).decode('utf-8')
}
async with aiohttp.ClientSession() as session:
try:
Expand Down
3 changes: 3 additions & 0 deletions build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
eval $(minikube -p minikube docker-env)
docker build . -f helm-chart/images/Dockerfile -t deejai
22 changes: 16 additions & 6 deletions helm-chart/deejai/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,27 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 3000
containerPort: 80
protocol: TCP
{{- if .Values.deployment.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 300
path: {{ .Values.deployment.livenessProbe.path }}
port: {{ .Values.deployment.livenessProbe.port }}
initialDelaySeconds: {{ .Values.deployment.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.deployment.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.deployment.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.deployment.livenessProbe.failureThreshold }} {{- end }}
{{- if .Values.deployment.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /
port: http
path: {{ .Values.deployment.readinessProbe.path }}
port: {{ .Values.deployment.readinessProbe.port }}
initialDelaySeconds: {{ .Values.deployment.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.deployment.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.deployment.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.deployment.readinessProbe.failureThreshold }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
Expand Down
31 changes: 21 additions & 10 deletions helm-chart/deejai/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replicaCount: 1

image:
repository: deejai
pullPolicy: Never
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

Expand All @@ -21,7 +21,7 @@ serviceAccount:
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: "deejai"
name: ""

podAnnotations: {}

Expand All @@ -37,8 +37,8 @@ securityContext: {}
# runAsUser: 1000

service:
type: NodePort
port: 3000
type: ClusterIP
port: 80

ingress:
enabled: false
Expand Down Expand Up @@ -82,9 +82,20 @@ tolerations: []

affinity: {}

# eval $(minikube -p minikube docker-env)
# docker build . -f helm-chart/images/Dockerfile -t deejai
# helm install deejai helm-chart/deejai --values helm-chart/deejai/values.yaml
# export POD_NAME=$(kubectl get pods -l "app.kubernetes.io/name=deejai,app.kubernetes.io/instance=deejai" -o jsonpath="{.items[0].metadata.name}")
# kubectl port-forward $POD_NAME 3000:3000
# helm upgrade deejai helm-chart/deejai --values helm-chart/deejai/values.yaml
deployment:
readinessProbe:
enabled: false
path: /healthz
port: http
initialDelaySeconds: 0
periodSeconds: 5
failureThreshold: 1000 # we rely on the liveness probe to resolve issues if needed
timeoutSeconds: 3
livenessProbe:
enabled: false
path: /healthz
port: http
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 3
timeoutSeconds: 10
14 changes: 6 additions & 8 deletions helm-chart/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ FROM python:3.8
COPY . /deej-ai.online-app
WORKDIR "/deej-ai.online-app"
RUN apt update
RUN apt install libsndfile1 nodejs npm -y
RUN apt install ffmpeg libsndfile-dev nodejs npm -y
RUN npm install --global yarn
RUN rm -rf node_modules deejai.db
RUN yarn install
RUN pip install -r requirements-lock.txt
RUN sed -i 's@https://deej-ai.online@http://localhost:3000@g' .env.production
RUN sed -i 's@https://deej-ai.online@http://localhost:3000@g' backend/credentials.py
RUN sed -i 's|\(http\)[^/]*/[^/]*/[^/]*/|http://localhost:8080/|g' .env.production
RUN sed -i 's|\(http\)[^/]*/[^/]*/[^/]*/|http://localhost:8080/|g' backend/credentials.py
RUN yarn build
ENV APP_URL http://localhost:3000
ENV APP_URL http://localhost:8080
ENV CUDA_VISIBLE_DEVICES ""
CMD ["uvicorn", "backend.main:app", "--reload", "--port=3000"]

# docker build . -f helm-chart/images/Dockerfile -t deejai
# docker run --rm --network="host" deejai
CMD ["uvicorn", "backend.main:app", "--reload", "--port=80"]
EXPOSE 80
4 changes: 4 additions & 0 deletions install_helm_chart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
helm uninstall deejai -n deejai
kubectl create namespace deejai
helm install deejai helm-chart/deejai -n deejai --values helm-chart/deejai/values.yaml
4 changes: 0 additions & 4 deletions src/components/RemovableTrack.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@

import { useState } from "react";
import { FaTimes } from "react-icons/fa";
import { HorizontalSpacer } from "../lib";
import Track from "./Track";

export default function RemovableTrack({ track_id, uuid, onRemove = f => f }) {
const [loaded, setLoaded] = useState(false);

return (
<>
<Track
track_id={track_id}
onLoad={() => setLoaded(true)}
>
</Track>
<HorizontalSpacer px={10} />
Expand Down

0 comments on commit 87dc1e6

Please sign in to comment.