feat: container-ports per env (BACKEND_PORT/FRONTEND_PORT) + host-ports
This commit is contained in:
1 parent
07f28107b3
commit
1bf7c19c31
5 files changed
+28
-14
No files matched your search
+6
-2
@@ -7,5 +7,9 @@ DOWNLOAD_DIR=~/StreamripDownloads
|
||||
UID=1000
|
||||
GID=1000
|
||||
|
||||
# Backend-Ziel für den Frontend-Rewrite (Compose-Netzwerk)
|
||||
BACKEND_URL=http://backend:8000
|
||||
# Ports: HOST = dein Rechner (linke Seite), ohne HOST = innen (rechte Seite).
|
||||
# Beispiel: BACKEND_HOST_PORT=8333 -> API unter http://localhost:8333
|
||||
BACKEND_HOST_PORT=8000
|
||||
BACKEND_PORT=8000
|
||||
FRONTEND_HOST_PORT=3002
|
||||
FRONTEND_PORT=3000
|
||||
@@ -56,9 +56,16 @@ CONFIG_DIR=~/.config/streamrip # config.toml + streamrip-DBs -> /config
|
||||
DOWNLOAD_DIR=~/StreamripDownloads # Downloads -> /downloads
|
||||
UID=1000 # Besitzer der Dateien im Container
|
||||
GID=1000
|
||||
BACKEND_URL=http://backend:8000 # internes API-Ziel fürs Frontend
|
||||
BACKEND_HOST_PORT=8000 # API auf deinem Rechner (linke Seite)
|
||||
BACKEND_PORT=8000 # API im Container (rechte Seite)
|
||||
FRONTEND_HOST_PORT=3002 # UI auf deinem Rechner
|
||||
FRONTEND_PORT=3000 # UI im Container
|
||||
```
|
||||
|
||||
Beispiel: `BACKEND_HOST_PORT=8333` → API unter `http://localhost:8333` (innen unverändert).
|
||||
`BACKEND_PORT=8334` stellt zusätzlich den Container-Port um — `BACKEND_URL` und
|
||||
Healthchecks folgen automatisch, nur diese eine Variable ist nötig.
|
||||
|
||||
Compose-Auszug (komplett in `docker-compose.yml`):
|
||||
|
||||
```yaml
|
||||
@@ -70,19 +77,20 @@ services:
|
||||
UID: ${UID:-1000}
|
||||
GID: ${GID:-1000}
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "${BACKEND_HOST_PORT:-8000}:${BACKEND_PORT:-8000}"
|
||||
environment:
|
||||
- STREAMRIP_CONFIG=/config/config.toml
|
||||
- STREAMRIP_DOWNLOAD_DIR=/downloads
|
||||
- BACKEND_PORT=${BACKEND_PORT:-8000}
|
||||
volumes:
|
||||
- ${CONFIG_DIR:-~/.config/streamrip}:/config
|
||||
- ${DOWNLOAD_DIR:-~/StreamripDownloads}:/downloads
|
||||
frontend:
|
||||
build: ./frontend
|
||||
ports:
|
||||
- "3002:3000"
|
||||
- "${FRONTEND_HOST_PORT:-3002}:${FRONTEND_PORT:-3000}"
|
||||
environment:
|
||||
- BACKEND_URL=${BACKEND_URL:-http://backend:8000}
|
||||
- BACKEND_URL=http://backend:${BACKEND_PORT:-8000}
|
||||
depends_on:
|
||||
- backend
|
||||
```
|
||||
|
||||
+4
-3
@@ -6,7 +6,8 @@ ARG GID=1000
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
STREAMRIP_CONFIG=/config/config.toml \
|
||||
STREAMRIP_DOWNLOAD_DIR=/downloads
|
||||
STREAMRIP_DOWNLOAD_DIR=/downloads \
|
||||
BACKEND_PORT=8000
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg git \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
@@ -24,5 +25,5 @@ USER appuser
|
||||
|
||||
EXPOSE 8000
|
||||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')"
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
CMD python -c "import os, urllib.request; urllib.request.urlopen(f'http://localhost:{os.environ.get(\"BACKEND_PORT\", \"8000\")}/api/health')"
|
||||
CMD uvicorn app.main:app --host 0.0.0.0 --port ${BACKEND_PORT:-8000}
|
||||
+5
-4
@@ -6,20 +6,21 @@ services:
|
||||
UID: ${UID:-1000}
|
||||
GID: ${GID:-1000}
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "${BACKEND_HOST_PORT:-8000}:${BACKEND_PORT:-8000}"
|
||||
environment:
|
||||
- STREAMRIP_CONFIG=/config/config.toml
|
||||
- STREAMRIP_DOWNLOAD_DIR=/downloads
|
||||
- BACKEND_PORT=${BACKEND_PORT:-8000}
|
||||
volumes:
|
||||
- ${CONFIG_DIR:-~/.config/streamrip}:/config
|
||||
- ${DOWNLOAD_DIR:-~/StreamripDownloads}:/downloads
|
||||
frontend:
|
||||
build: ./frontend
|
||||
ports:
|
||||
- "3002:3000"
|
||||
- "${FRONTEND_HOST_PORT:-3002}:${FRONTEND_PORT:-3000}"
|
||||
environment:
|
||||
- BACKEND_URL=${BACKEND_URL:-http://backend:8000}
|
||||
- BACKEND_URL=http://backend:${BACKEND_PORT:-8000}
|
||||
- HOSTNAME=0.0.0.0
|
||||
- PORT=3000
|
||||
- PORT=${FRONTEND_PORT:-3000}
|
||||
depends_on:
|
||||
- backend
|
||||
+1
-1
@@ -17,5 +17,5 @@ USER node
|
||||
|
||||
EXPOSE 3000
|
||||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
||||
CMD wget -q -O /dev/null http://127.0.0.1:3000/ || exit 1
|
||||
CMD wget -q -O /dev/null http://127.0.0.1:${PORT:-3000}/ || exit 1
|
||||
CMD ["node", "server.js"]
|
||||
Reference in new issue
Block a user