diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..322ab8a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,38 @@ +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +.env +.idea/ +*.service + +http-client.private.env.json + +127.0.0.1.pem +127.0.0.1-key.pem + +resources/poster_cache \ No newline at end of file diff --git a/deployment/Dockerfile b/deployment/Dockerfile new file mode 100644 index 0000000..abc4a1c --- /dev/null +++ b/deployment/Dockerfile @@ -0,0 +1,22 @@ +FROM python:3.11-slim-bullseye + +WORKDIR /mediafusion + +COPY ../Pipfile Pipfile.lock ./ + +# Install dependencies +RUN pip install --upgrade pip && \ + pip install pipenv && \ + apt-get update && \ + apt-get install -y git + + +RUN pipenv install --deploy --ignore-pipfile + +# Copy the source code +COPY .. . + +# Expose the port +EXPOSE 80 + +CMD ["pipenv", "run", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "80"] diff --git a/deployment/deployment.yaml b/deployment/deployment.yaml new file mode 100644 index 0000000..7f7e455 --- /dev/null +++ b/deployment/deployment.yaml @@ -0,0 +1,93 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mediafusion-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: mediafusion + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + maxSurge: 1 + template: + metadata: + labels: + app: mediafusion + spec: + imagePullSecrets: + - name: ocirsecret + containers: + - name: mediafusion + image: ap-singapore-1.ocir.io/axykuon5aont/mediafusion:v3.6.5 + ports: + - containerPort: 80 + env: + - name: MONGO_URI + valueFrom: + secretKeyRef: + name: mediafusion-secrets + key: MONGO_URI + - name: SECRET_KEY + valueFrom: + secretKeyRef: + name: mediafusion-secrets + key: SECRET_KEY + - name: HOST_URL + value: "https://mediafusion.fun" + - name: ENABLE_SCRAPPER + value: "false" + - name: POSTER_CACHE_PATH + value: "/covers" + volumeMounts: + - name: mediafusion-volume + mountPath: /covers + livenessProbe: + httpGet: + path: /health + port: 80 + initialDelaySeconds: 10 + periodSeconds: 60 + failureThreshold: 5 + timeoutSeconds: 10 + readinessProbe: + httpGet: + path: /health + port: 80 + initialDelaySeconds: 5 + periodSeconds: 5 + timeoutSeconds: 10 + volumes: + - name: mediafusion-volume + persistentVolumeClaim: + claimName: mediafusion-pvc + +--- + +apiVersion: v1 +kind: Service +metadata: + name: mediafusion-service +spec: + selector: + app: mediafusion + ports: + - protocol: TCP + port: 80 + targetPort: 80 + type: LoadBalancer + +--- + +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mediafusion-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi