Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
**/bin/
**/data/
**/node_modules/
cli/
apps/cli/
output/
.editorconfig
.gitattributes
.gitignore
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,21 @@ jobs:
- name: Check out Git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda

- name: Set up NodeJS
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version-file: package.json
cache: pnpm
cache: yarn

- name: Install dependencies
run: |
pnpm install --frozen-lockfile
yarn install --immutable

- name: Run build
run: pnpm build

- name: Install built dependencies
run: |
pnpm install --frozen-lockfile
run: yarn build

- name: Run linting and formatting
run: pnpm check
run: yarn check

- name: Run tests
run: pnpm test
run: yarn test
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ coverage/
bin/
data/
dist/
cli/client/
apps/cli/client/
tsconfig.tsbuildinfo
.turbo/
.yarn/cache/
.yarn/install-state.gz
out/
output/
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pnpm lint-staged
yarn lint-staged
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
.idea/
.husky/
.turbo/
cache/
coverage/
data/
dist/
node_modules/
pnpm-lock.yaml
yarn.lock
LICENSE
openapi.json
out/
14 changes: 7 additions & 7 deletions .vscode/hive.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"folders": [
{
"name": "root",
"path": "../",
"path": "..",
},
{
"name": "api",
Expand All @@ -13,25 +13,25 @@
"path": "../apps/web",
},
{
"name": "packages",
"path": "../packages",
"name": "cli",
"path": "../apps/cli",
},
{
"name": "cli",
"path": "../cli",
"name": "packages",
"path": "../packages",
},
],
"settings": {
"files.exclude": {
"apps": true,
"packages": true,
"cli": true,
"**/coverage": true,
"**/dist": false,
"**/node_modules": false,
},
"search.exclude": {
"cli/client": true,
"apps/cli/client": true,
"**/.turbo": true,
"**/coverage": true,
"**/dist": true,
"**/node_modules": true,
Expand Down
940 changes: 940 additions & 0 deletions .yarn/releases/yarn-4.13.0.cjs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.13.0.cjs
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
REDIS_PORT: 6379
REDIS_PASSWORD: password
YT_API_KEY: <secret>
METRICS_ENABLED: true
volumes:
- hive:/var/lib/hive
ports:
Expand All @@ -31,20 +32,8 @@ services:
networks:
- hive

web:
image: ghcr.io/killbasa/hive-web:nightly
restart: unless-stopped
environment:
VITE_API_URL: http://localhost:3001
ports:
- 127.0.0.1:3000:3000
depends_on:
- hive
networks:
- hive

redis:
image: redis:7.2.4-alpine3.19
image: redis:7.4.3-alpine3.21
restart: unless-stopped
command: ['redis-server', '--requirepass password']
networks:
Expand Down Expand Up @@ -77,16 +66,21 @@ The only version of yt-dlp that is guarateed to work is the version that is bund
1. Download yt-dlp binary

```sh
wget https://github.com/yt-dlp/yt-dlp/releases/download/2024.08.06/yt-dlp
wget https://github.com/yt-dlp/yt-dlp/releases/download/2025.04.30/yt-dlp
chmod +x yt-dlp
mv ./yt-dlp ./apps/api/bin
```

or run the setup script

```sh
sh ./apps/api/scripts/deps.sh
```

1. Setup .env files

```sh
cp apps/api/.env.example apps/api/.env
cp apps/web/.env.example apps/web/.env
```

3. Start services
Expand All @@ -95,10 +89,10 @@ cp apps/web/.env.example apps/web/.env
docker compose -f apps/api/compose.yml up -d
```

4. Build applications
4. Build applications and dependencies

```sh
pnpm build
yarn build
```

### Developing on Mac OS
Expand Down
1 change: 1 addition & 0 deletions apps/api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
cache/
data/
output/
4 changes: 4 additions & 0 deletions apps/api/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
bin/
cache/
data/
dist/
node_modules/
openapi.json
24 changes: 13 additions & 11 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## Base ##
FROM node:23.11.0-alpine3.21 AS base
FROM node:25.8.1-alpine3.23 AS base

# python: sqlite compilation and supervisord
# ffmpeg: video post-processing
# nginx: serve static files and reverse proxy
# supervisor: run multiple processes in a container
RUN apk update --no-cache && \
apk add --no-cache \
python3=3.12.10-r0 \
ffmpeg=6.1.2-r1 \
nginx=1.26.3-r0 \
python3=3.12.12-r0 \
ffmpeg=6.1.2-r2 \
nginx=1.28.0-r3 \
supervisor=4.2.5-r5

## Depdencies ##
FROM alpine@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c AS dependencies
## Dependencies ##
FROM alpine@sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412 AS dependencies

RUN wget -q https://github.com/yt-dlp/yt-dlp/releases/download/2025.03.31/yt-dlp \
RUN wget -q https://github.com/yt-dlp/yt-dlp/releases/download/2025.11.12/yt-dlp \
-O /tmp/yt-dlp && \
chmod +x /tmp/yt-dlp

Expand All @@ -31,27 +31,29 @@ ENV PATH="$PNPM_HOME:$PATH"
RUN apk add --no-cache \
build-base=0.5-r3

COPY pnpm-lock.yaml pnpm-workspace.yaml package.json tsconfig.json .npmrc ./
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json tsconfig.json ./
COPY apps/api ./apps/api/
COPY apps/web ./apps/web/
COPY packages ./packages/

RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
corepack enable pnpm && \
corepack use pnpm@10.9.0 && \
corepack use pnpm@10.18.2 && \
pnpm install && \
pnpm --recursive run build && \
pnpm --filter @hive/api run build:prod && \
mkdir output && \
pnpm --filter @hive/api deploy --prod output
mkdir -p output/api && mkdir -p output/ui && \
pnpm --filter @hive/api deploy --prod output/api && pnpm --filter @hive/web deploy --prod output/ui

## App ##
FROM base AS app

LABEL org.opencontainers.image.authors="killbasa <git@killbasa.com>"
LABEL org.opencontainers.image.source=https://github.com/killbasa/hive
LABEL org.opencontainers.image.licenses=AGPL-3.0-or-later

ENV NODE_ENV=production
ENV IS_CONTAINER=true
ENV PATH=/hive/bin:$PATH

RUN adduser --system --uid 1001 hive && \
Expand Down
4 changes: 2 additions & 2 deletions apps/api/compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
services:
redis:
image: redis:7.4.2-alpine3.21
image: redis:8.4.0-alpine3.22
restart: unless-stopped
command: ["redis-server", "--requirepass password"]
ports:
- 127.0.0.1:6379:6379

nginx:
image: nginx:1.26.3-alpine3.20 # Needs to match version in Dockerfile
image: nginx:1.28.0-alpine3.22 # Needs to match version in Dockerfile
restart: unless-stopped
network_mode: host
environment:
Expand Down
68 changes: 43 additions & 25 deletions apps/api/configs/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ http {
server_tokens off;
access_log /dev/stdout;

proxy_cache_path /tmp/cache levels=1:2 keys_zone=auth_cache:10m;

# proxy_cache_path /tmp/cache/auth levels=1:2 keys_zone=auth_cache:10m;
# proxy_cache_path /tmp/cache/mp4 keys_zone=mp4_cache:70m;
proxy_cache_path /tmp/hive-auth levels=1:2 keys_zone=auth_cache:10m;
proxy_cache_path /tmp/hive-mp4 keys_zone=mp4_cache:70m;

gzip on;

Expand All @@ -29,37 +27,46 @@ http {
keepalive 2;
}

upstream hive_web {
server 127.0.0.1:3000;
keepalive 2;
}

server {
listen 3001;
listen [::]:3001;

server_name _;

# location ~ /.mp4 {
# limit_except GET { deny all; }
# auth_request /access;
location ~/.mp4 {
limit_except GET { deny all; }
auth_request /access;

alias /var/lib/hive/media;

# alias /var/lib/hive/media;
mp4;
mp4_buffer_size 1M;
mp4_max_buffer_size 3M;

# mp4;
# mp4_buffer_size 1M;
# mp4_max_buffer_size 3M;
aio threads=default;

# aio threads=default;
proxy_cache mp4_cache;
proxy_cache_valid 200 206 300s;
proxy_cache_lock on;

# proxy_cache mp4_cache;
# proxy_cache_valid 200 300s;
# proxy_cache_lock on;
slice 1m;
proxy_cache_key $host$uri$is_args$args$slice_range;
proxy_set_header Range $slice_range;
proxy_http_version 1.1;

# slice 1m;
# proxy_cache_key $host$uri$is_args$args$slice_range;
# proxy_set_header Range $slice_range;
# proxy_http_version 1.1;
proxy_cache_lock_timeout 0s;
proxy_cache_lock_age 200s;
proxy_cache_use_stale updating;
}

# proxy_cache_lock_timeout 0s;
# proxy_cache_lock_age 200s;
# proxy_cache_use_stale updating;
# }
location / {
return 301 /ui;
}

location /assets {
limit_except GET { deny all; }
Expand All @@ -74,11 +81,22 @@ http {
tcp_nodelay on;
}

location / {
location /api {
proxy_pass http://hive_api;

proxy_http_version 1.1;
#proxy_read_timeout 1h;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;

# Make sure websocket connections don't timeout
proxy_read_timeout 1d;
}

location /ui {
proxy_pass http://hive_web;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
Expand Down
Loading
Loading