Make ws4kp being exposed optional
This commit is contained in:
@@ -63,8 +63,8 @@ RUN npm install -g yarn && yarn install --frozen-lockfile || yarn install
|
|||||||
COPY index.js ./
|
COPY index.js ./
|
||||||
COPY src/ ./src/
|
COPY src/ ./src/
|
||||||
|
|
||||||
# Expose both ports
|
# Expose streaming app port (WS4KP port only exposed when explicitly configured)
|
||||||
EXPOSE 3000 8080
|
EXPOSE 3000
|
||||||
|
|
||||||
# Start both services using JSON array format
|
# Start both services using JSON array format
|
||||||
CMD ["/bin/sh", "-c", "cd /app && node index.js & cd /streaming-app && yarn start"]
|
CMD ["/bin/sh", "-c", "cd /app && node index.js & cd /streaming-app && yarn start"]
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -17,7 +17,7 @@ docker-compose pull
|
|||||||
docker-compose up
|
docker-compose up
|
||||||
|
|
||||||
# The service runs on http://localhost:3000
|
# The service runs on http://localhost:3000
|
||||||
# ws4kp interface available at http://localhost:8080
|
# WS4KP interface available at http://localhost:8080 (if port is exposed)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Environment Variables
|
### Environment Variables
|
||||||
@@ -26,20 +26,25 @@ Configure ports and services via environment variables:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Default values
|
# Default values
|
||||||
PORT=3000 # Main streaming server port
|
PORT=3000 # Main streaming server port
|
||||||
WS4KP_PORT=8080 # WS4KP weather service port
|
WS4KP_EXTERNAL_PORT=8080 # External port for WS4KP interface (optional)
|
||||||
MUSIC_PATH=/music # Path to music files
|
MUSIC_PATH=/music # Path to music files
|
||||||
|
|
||||||
# Example with custom ports
|
# Example with custom ports
|
||||||
PORT=8000 WS4KP_PORT=9090 docker-compose up
|
PORT=8000 WS4KP_EXTERNAL_PORT=9090 docker-compose up
|
||||||
|
|
||||||
|
# Run without exposing WS4KP externally (only accessible internally to the streaming app)
|
||||||
|
# Comment out the WS4KP port line in docker-compose.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
Or use a `.env` file with docker-compose:
|
Or use a `.env` file with docker-compose:
|
||||||
```env
|
```env
|
||||||
PORT=8000
|
PORT=8000
|
||||||
WS4KP_PORT=9090
|
WS4KP_EXTERNAL_PORT=9090
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note**: The WS4KP weather service runs internally on port 8080 inside the container and is always accessible to the streaming app. The `WS4KP_EXTERNAL_PORT` controls whether it's exposed externally. If you don't need direct access to the WS4KP interface, you can comment out the WS4KP port mapping in `docker-compose.yml` to keep it internal-only.
|
||||||
|
|
||||||
### Persistent Geocoding Cache
|
### Persistent Geocoding Cache
|
||||||
|
|
||||||
Geocoding results are cached in the `./cache` directory. When using docker-compose, this directory is automatically mounted to persist between container restarts. If using Docker directly, mount the cache volume to persist data:
|
Geocoding results are cached in the `./cache` directory. When using docker-compose, this directory is automatically mounted to persist between container restarts. If using Docker directly, mount the cache volume to persist data:
|
||||||
@@ -51,7 +56,11 @@ docker run -p 3000:3000 -p 8080:8080 -v $(pwd)/cache:/streaming-app/cache ghcr.i
|
|||||||
### Using Docker directly
|
### Using Docker directly
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# With WS4KP interface exposed
|
||||||
docker run -p 3000:3000 -p 8080:8080 ghcr.io/sethwv/ws4kp-to-hls:latest
|
docker run -p 3000:3000 -p 8080:8080 ghcr.io/sethwv/ws4kp-to-hls:latest
|
||||||
|
|
||||||
|
# Without exposing WS4KP interface (internal only)
|
||||||
|
docker run -p 3000:3000 ghcr.io/sethwv/ws4kp-to-hls:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note**: Initial build takes an additional ~90 seconds due to downloading and processing the Weatherscan music collection (~500MB, processed to VBR q6 quality with normalization).
|
**Note**: Initial build takes an additional ~90 seconds due to downloading and processing the Weatherscan music collection (~500MB, processed to VBR q6 quality with normalization).
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
# Docker Build Commands
|
# Docker Build Commands
|
||||||
|
|
||||||
|
## Setup buildx builder (one-time setup)
|
||||||
|
|
||||||
|
# Create and use the multiplatform builder
|
||||||
|
docker buildx create --name multiplatform --driver docker-container --use
|
||||||
|
docker buildx inspect --bootstrap
|
||||||
|
|
||||||
|
# Or if builder exists, just switch to it
|
||||||
|
docker buildx use multiplatform
|
||||||
|
|
||||||
## Build and push multi-platform image (AMD64 + ARM64)
|
## Build and push multi-platform image (AMD64 + ARM64)
|
||||||
|
|
||||||
docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/sethwv/ws4kp-to-hls:latest --push .
|
docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/sethwv/ws4kp-to-hls:latest --push .
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ services:
|
|||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- "${PORT:-3000}:${PORT:-3000}"
|
- "${PORT:-3000}:${PORT:-3000}"
|
||||||
- "${WS4KP_PORT:-8080}:${WS4KP_PORT:-8080}"
|
# WS4KP port - comment out this line if you don't need external access to WS4KP
|
||||||
|
# - "${WS4KP_EXTERNAL_PORT:-8080}:8080"
|
||||||
shm_size: 2gb
|
shm_size: 2gb
|
||||||
environment:
|
environment:
|
||||||
- PORT=${PORT:-3000}
|
- PORT=${PORT:-3000}
|
||||||
- WS4KP_PORT=${WS4KP_PORT:-8080}
|
- WS4KP_PORT=8080
|
||||||
volumes:
|
volumes:
|
||||||
- ./cache:/streaming-app/cache
|
- ./cache:/streaming-app/cache
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
@@ -31,8 +31,11 @@ function getCachedGeocode(cityQuery) {
|
|||||||
if (fs.existsSync(cacheFile)) {
|
if (fs.existsSync(cacheFile)) {
|
||||||
const data = fs.readFileSync(cacheFile, 'utf8');
|
const data = fs.readFileSync(cacheFile, 'utf8');
|
||||||
const cached = JSON.parse(data);
|
const cached = JSON.parse(data);
|
||||||
console.log(`Using cached geocode for: ${cityQuery}`);
|
// Verify the query matches
|
||||||
return cached;
|
if (cached.query && cached.query.toLowerCase().trim() === cityQuery.toLowerCase().trim()) {
|
||||||
|
console.log(`Using cached geocode for: ${cityQuery}`);
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(`Cache read error for ${cityQuery}:`, error.message);
|
console.warn(`Cache read error for ${cityQuery}:`, error.message);
|
||||||
@@ -88,6 +91,7 @@ async function geocodeCity(cityQuery) {
|
|||||||
const results = JSON.parse(data);
|
const results = JSON.parse(data);
|
||||||
if (results && results.length > 0) {
|
if (results && results.length > 0) {
|
||||||
const geocodeResult = {
|
const geocodeResult = {
|
||||||
|
query: cityQuery,
|
||||||
lat: parseFloat(results[0].lat),
|
lat: parseFloat(results[0].lat),
|
||||||
lon: parseFloat(results[0].lon),
|
lon: parseFloat(results[0].lon),
|
||||||
displayName: results[0].display_name
|
displayName: results[0].display_name
|
||||||
|
|||||||
Reference in New Issue
Block a user