Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docker images, fixed docker nvidia opencl support, updated all requirements #15

Merged
merged 8 commits into from
Jul 5, 2024
Merged
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
25 changes: 24 additions & 1 deletion .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
build-and-publish-alpine:
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -43,6 +43,29 @@ jobs:
tags: ${{ env.REGISTRY }}/cc-youcube/youcube:latest,${{ env.REGISTRY }}/cc-youcube/youcube:alpine
labels: ${{ steps.meta.outputs.labels }}

build-and-publish-nvidia:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Login to container registry 🔐
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata 🏷️
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: 🔨 Build and Publish nvidia 🚀
uses: docker/build-push-action@v3
with:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- "src/**"

jobs:
build-image:
build-alpine-image:
runs-on: ubuntu-latest

steps:
Expand All @@ -23,6 +23,13 @@ jobs:
with:
context: src

build-nvidia-image:
runs-on: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Build nvidia image 🔨
uses: docker/build-push-action@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
*.dfpwm
*.32vid
dictionary.dic
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ python src/youcube.py
Environment variables you can use to configure the server:

| Variable | Default | Description |
|-------------------------------|------------|--------------------------------------------------------------------------------------------------------------------|
| ----------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------ |
| `HOST` | `0.0.0.0` | The host where the web server runs on. |
| `PORT` | `5000` | The port where the web server should run on |
| `FFMPEG_PATH` | `ffmpeg` | Path to the FFmpeg executable |
Expand All @@ -55,14 +55,15 @@ And [Sanic Builtin values].
## Docker Compose

```yml
version: "2.0"
---
services:
youcube:
image: ghcr.io/cc-youcube/youcube:latest
restart: always
hostname: youcube
ports:
- 5000:5000
...
```

[spotify application]: https://developer.spotify.com/dashboard/applications
Expand All @@ -79,4 +80,4 @@ services:
[preview]: .README/preview-server.png
[Python Version: 3.7+]: https://img.shields.io/badge/Python-3.7+-green?style=for-the-badge&logo=Python&logoColor=white
[Python Lint Workflow Status]: https://img.shields.io/github/actions/workflow/status/CC-YouCube/server/pylint.yml?branch=main&label=Python%20Lint&logo=github&style=for-the-badge
[Sanic Builtin values]: https://sanic.dev/en/guide/running/configuration.md#builtin-values
[Sanic Builtin values]: https://sanic.dev/en/guide/running/configuration.md#builtin-values
81 changes: 40 additions & 41 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "youcube-server"
version = "1.0.0"
authors = [
{name = "Commandcracker"},
]
description = "A server which provides a WebSocket API for YouCube clients"
readme = "README.md"
requires-python = ">=3.7"
keywords = ["youtube", "youcube", "computercraft", "minecraft"]
license = {text = "GPL-3.0"}
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Natural Language :: English",
"Topic :: Multimedia :: Video",
"Topic :: Multimedia :: Sound/Audio :: Players",
]
# Required for pulling dependencies from requirements.txt
dynamic = ["dependencies"]

[project.urls]
Homepage = "https://youcube.madefor.cc"
Repository = "https://github.com/CC-YouCube/server"
Documentation = "https://youcube.madefor.cc/guides/server/installation/"

[tool.setuptools.dynamic]
# Pull dependencies from requirements.txt
dependencies = {file = ["src/requirements.txt"]}

[tool.setuptools.packages.find]
where = ["src"] # list of folders that contain the packages (["."] by default)
include = ["youcube*"] # package names should match these glob patterns (["*"] by default)

[tool.autopep8]
ignore = "E701"

[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "youcube-server"
version = "1.0.0"
authors = [{ name = "Commandcracker" }]
description = "A server which provides a WebSocket API for YouCube clients"
readme = "README.md"
requires-python = ">=3.7"
keywords = ["youtube", "youcube", "computercraft", "minecraft"]
license = { text = "GPL-3.0" }
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Natural Language :: English",
"Topic :: Multimedia :: Video",
"Topic :: Multimedia :: Sound/Audio :: Players",
]
# Required for pulling dependencies from requirements.txt
dynamic = ["dependencies"]

[project.urls]
Homepage = "https://youcube.madefor.cc"
Repository = "https://github.com/CC-YouCube/server"
Documentation = "https://youcube.madefor.cc/guides/server/installation/"

[tool.setuptools.dynamic]
# Pull dependencies from requirements.txt
dependencies = { file = ["src/requirements.txt"] }

[tool.setuptools.packages.find]
where = ["src"] # list of folders that contain the packages (["."] by default)
include = [
"youcube*",
] # package names should match these glob patterns (["*"] by default)

[tool.autopep8]
ignore = "E701"
9 changes: 9 additions & 0 deletions spellcheck_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ Popen
ffmpeg
subprocess
utils
spotipy

# Web Development
websocket
YouCube
Spotify
html
dev

# Programming Keywords
str
env
untrusted
usr
Expand Down Expand Up @@ -64,9 +67,15 @@ github
dlp
geeksforgeeks
www
metalink

# Video Streaming
yc
yt
dl
youtube

# Other
f'Attachment
WIP
xml
82 changes: 48 additions & 34 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,65 @@
FROM ghcr.io/commandcracker/ffmpeg:latest AS ffmpeg

FROM ffmpeg as sanjuuni
FROM ffmpeg AS sanjuuni

ENV SANJUUNI_VERSION=ed34c266cd489e4db796ca803e247b48b43853e0
ENV SANJUUNI_VERSION=778644b164c8877e56f9f5512480dde857133815

ARG SANJUUNI_SHA512SUM="9e482e3b8f8885e8f458856f11d5ee4c27a0aa469b8c54abe1aef943f630ca27eb148c8779ba7a053c1abcce298513e98b614747a77ae1c0cbc86a0a7c95a6d8 *sanjuuni.tar.gz"
ARG SANJUUNI_SHA512SUM="353b97e53ec2daba3046b3062c8a389c75066ea410f9abe089467a4648e83afe926cd65ad0904a0d59eca0520e3174e0f3190987cfee3abbdc9141a04a80ef1a *sanjuuni.tar.gz"

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

RUN set -eux; \
apk add --no-cache --update g++ zlib-dev poco-dev make; \
wget --output-document=sanjuuni.tar.gz https://github.com/MCJack123/sanjuuni/archive/${SANJUUNI_VERSION}.tar.gz; \
echo "${SANJUUNI_SHA512SUM}" | sha512sum -c -; \
mkdir --parents sanjuuni; \
tar --extract --directory sanjuuni --strip-components=1 --file=sanjuuni.tar.gz; \
rm sanjuuni.tar.gz;
apk add --no-cache --update \
g++=13.2.1_git20240309-r0 \
zlib-dev=1.3.1-r1 \
poco-dev=1.12.4-r0 \
make=4.4.1-r2; \
wget -q --output-document=sanjuuni.tar.gz https://github.com/MCJack123/sanjuuni/archive/${SANJUUNI_VERSION}.tar.gz; \
echo "${SANJUUNI_SHA512SUM}" | sha512sum -c -; \
mkdir --parents sanjuuni; \
tar --extract --directory sanjuuni --strip-components=1 --file=sanjuuni.tar.gz; \
rm sanjuuni.tar.gz;

WORKDIR /sanjuuni

RUN set -eux; \
./configure; \
make
./configure; \
make

FROM ghcr.io/commandcracker/alpine-pypy3.10-pip:3.20.1-pypy-7.3.14-pip-24.1.1 AS builder

FROM ghcr.io/commandcracker/alpine-pypy3.10-pip:3.19.0-pypy-7.3.14-pip-23.3.2 AS builder
WORKDIR /

COPY requirements.txt .
COPY youcube ./youcube
COPY compile.py .

RUN set -eux; \
apk add --no-cache --update build-base; \
pip install --no-cache-dir -U setuptools -r requirements.txt; \
python3 compile.py; \
pip uninstall pip -y
apk add --no-cache --update build-base=0.5-r3; \
pip install --no-cache-dir -U setuptools -r requirements.txt; \
python3 compile.py; \
pip uninstall pip -y

FROM alpine:3.19.0
FROM alpine:3.20.1

WORKDIR /opt/server

RUN set -eux; \
apk add --no-cache --update \
# pypy requirements
libffi libbz2 \
# sanjuuni requirements
poco \
# ffmpeg requirements
libgcc libstdc++ ca-certificates libgomp expat; \
apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.18/community libssl1.1 libcrypto1.1; \
chown 1000 /opt/server/
apk add --no-cache --update \
# CVE-2024-5535 TODO: remove when base image is updated
openssl \
# pypy requirements
libffi=3.4.6-r0 libbz2=1.0.8-r6 \
# sanjuuni requirements
poco=1.12.4-r0 \
# ffmpeg requirements
libgcc=13.2.1_git20240309-r0 \
libstdc++=13.2.1_git20240309-r0 \
ca-certificates=20240226-r0 \
libgomp=13.2.1_git20240309-r0 \
expat=2.6.2-r0; \
apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.18/community libssl1.1=1.1.1u-r1 libcrypto1.1=1.1.1u-r1; \
chown 1000 /opt/server/

COPY --from=builder /opt/pypy /opt/pypy
# add ffmpeg
Expand All @@ -54,14 +68,14 @@ COPY --from=ffmpeg /usr/local /usr/local
COPY --from=sanjuuni /sanjuuni/sanjuuni /usr/local/bin

ENV \
# Make sure we use the virtualenv:
PATH="/opt/pypy/bin:$PATH" \
# Use ffmpeg libs
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 \
# yt-dlp cache dir
XDG_CACHE_HOME="/opt/server/.yt-dlp-cache" \
# FIXME: Add UVLOOP support for alpine pypy
SANIC_NO_UVLOOP=true
# Make sure we use the virtualenv:
PATH="/opt/pypy/bin:$PATH" \
# Use ffmpeg libs
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 \
# yt-dlp cache dir
XDG_CACHE_HOME="/opt/server/.yt-dlp-cache" \
# FIXME: Add UVLOOP support for alpine pypy
SANIC_NO_UVLOOP=true

USER 1000

Expand Down
Loading
Loading