Skip to content

Commit

Permalink
Merge pull request #102 from Statrue/dev
Browse files Browse the repository at this point in the history
feat: add Dev Container support
  • Loading branch information
nepsyn authored May 26, 2024
2 parents 8c3a04a + 43ca844 commit 2bab8c3
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 1 deletion.
67 changes: 67 additions & 0 deletions .devcontainer/.env.dev.server
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Application
APP_ENV=prod
APP_HOST=0.0.0.0
APP_PORT=3000
APP_SECRET_KEY=devkey
APP_HTTP_PROXY=
APP_ENABLE_CORS=1

# FFmpeg
FFMPEG_PATH=ffmpeg
FFPROBE_PATH=ffprobe

# Database
DB_HOST=mysql
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=
DB_DATABASE=minaplay

# Redis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_DB=0
REDIS_PASSWORD=

# Aria2
ARIA2_RPC_HOST=aria2
ARIA2_RPC_PORT=6800
ARIA2_RPC_PATH=/jsonrpc
ARIA2_RPC_SECRET=dev
ARIA2_AUTO_UPDATE_TRACKER=1
ARIA2_TRACKER_LIST_URL="https://cdn.jsdelivr.net/gh/ngosang/trackerslist@master/trackers_best.txt"

# Mediasoup
MS_ANNOUNCED_IP=127.0.0.1
MS_RTC_MIN_PORT=12000
MS_RTC_MAX_PORT=12999
MS_WORKERS_NUM=4
MS_AUDIO_CLOCK_RATE=48000
MS_AUDIO_CHANNELS=2
MS_AUDIO_MAX_INCOME_BITRATE=1500000

# Live Stream
STREAM_RTMP_PORT=1935
STREAM_HTTP_PORT=3001
STREAM_CHUNK_SIZE=60000
STREAM_PUBLISH_KEY=

# Notifications
# WS
NOTIFY_WS=1

# Email
NOTIFY_EMAIL=0
NOTIFY_EMAIL_SMTP_HOST=mail.example.com
NOTIFY_EMAIL_SMTP_PORT=25
NOTIFY_EMAIL_SMTP_SECURE=0
NOTIFY_EMAIL_SMTP_USER=no-reply@example.com
NOTIFY_EMAIL_SMTP_PASSWORD=password
NOTIFY_EMAIL_ORIGIN="MinaPlay <minaplay@example.com>"
NOTIFY_EMAIL_SUBJECT="MinaPlay Email Notification"

# ServerChan
NOTIFY_SERVER_CHAN=0

# Telegram
NOTIFY_TELEGRAM=0
1 change: 1 addition & 0 deletions .devcontainer/.env.dev.web
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_HOST="http://localhost:3000"
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Minaplay_DevContainer",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [5173, 3000, 3001, 1935]

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "sh ./.devcontainer/setup.sh",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
60 changes: 60 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
services:
app:
image: mcr.microsoft.com/vscode/devcontainers/typescript-node:20-bookworm
container_name: basic_env
environment:
- DB_HOST=mysql
- REDIS_HOST=redis
- MS_ANNOUNCED_IP=127.0.0.1
networks:
- minaplay-network
ports:
- "5173:5173"
- "3000:3000"
- "3001:3001"
- "1935:1935"
volumes:
- ../..:/workspaces:cached
depends_on:
- mysql
- redis
- aria2
command: sleep infinity

mysql:
image: mysql:8
container_name: mysql
environment:
- TZ=Asia/Shanghai
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_DATABASE=minaplay
networks:
- minaplay-network
ports:
- "3306:3306"
volumes:
- mysql-data:/var/lib/mysql

redis:
image: redis:latest
container_name: redis
networks:
- minaplay-network
ports:
- "6379:6379"

aria2:
image: p3terx/aria2-pro:latest
container_name: aria2
networks:
- minaplay-network
ports:
- "6800:6800"
environment:
- RPC_SECRET=dev

volumes:
mysql-data:

networks:
minaplay-network:
21 changes: 21 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
pwd
#####################
# web project setup #
#####################
# Navigate to the web directory
cd ./packages/web
# setup
yarn install
cp ../../.devcontainer/.env.dev.web .env

########################
# server project setup #
########################
# Navigate to the server directory
cd ../server
# setup
yarn
yarn add sharp --ignore-engines
yarn global add @nestjs/cli
cp ../../.devcontainer/.env.dev.server .env
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "vue-tsc --noEmit && vite build",
"lint": "eslint . --fix --ignore-path .gitignore",
"dev": "vite",
"dev": "vite --host",
"preview": "vite preview",
"generate-pwa-assets": "pwa-assets-generator --preset minimal src/assets/logo.svg"
},
Expand Down

0 comments on commit 2bab8c3

Please sign in to comment.