-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from games-on-whales/docker
Docker build
- Loading branch information
Showing
49 changed files
with
1,780 additions
and
844 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Start by removing everything and add just the things we need | ||
* | ||
|
||
!src | ||
!cmake | ||
!CMakeLists.txt | ||
!.clang-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
time: "00:00" | ||
target-branch: "nightly" | ||
open-pull-requests-limit: 10 | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
time: "00:00" | ||
target-branch: "nightly" | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
name: Docker build | ||
|
||
on: | ||
push: | ||
# TODO: enable workflow_run when merged into master | ||
# workflow_run: | ||
# workflows: [ "Linux build and test" ] | ||
# types: | ||
# - completed | ||
|
||
jobs: | ||
buildx: | ||
# Only run this when tests are passing, see: https://github.com/orgs/community/discussions/26238 | ||
# if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# Set derived configuration variables: | ||
# - images: images to build (docker and/or github) | ||
# - push: if images need to be uploaded to repository (when secrets available) | ||
# - has_docker_token | ||
# - has_github_token | ||
# - cache_from: image tag to use for imported cache | ||
# - cache_to: image tag to use for exported cache | ||
# - github_server_url: reference to source code repository | ||
- name: Prepare | ||
id: prep | ||
run: | | ||
IMAGES="" | ||
PUSH=false | ||
if [ -n "${{ secrets.DOCKERHUB_TOKEN }}" ]; then | ||
IMAGES="gameonwhales/wolf" | ||
PUSH=true | ||
echo "has_docker_token=true" >> $GITHUB_OUTPUT | ||
fi | ||
if [ -n "${{ secrets.GHCR_TOKEN }}" ]; then | ||
REGISTRY_IMAGE="ghcr.io/${{ github.repository_owner }}/wolf" | ||
if [ "$IMAGES" = "" ]; then | ||
IMAGES="ghcr.io/${REGISTRY_IMAGE}" | ||
else | ||
IMAGES="$IMAGES,ghcr.io/${REGISTRY_IMAGE}" | ||
fi | ||
PUSH=true | ||
echo "has_github_token=true" >> $GITHUB_OUTPUT | ||
echo "cache_from=type=registry,ref=${REGISTRY_IMAGE}:buildcache" >> $GITHUB_OUTPUT | ||
echo "cache_to=type=registry,ref=${REGISTRY_IMAGE}:buildcache,mode=max" >> $GITHUB_OUTPUT | ||
else | ||
echo "cache_from=type=registry,ref=${REGISTRY_IMAGE}:buildcache" >> $GITHUB_OUTPUT | ||
echo "cache_to=" >> $GITHUB_OUTPUT | ||
fi | ||
echo "images=${IMAGES}" >> $GITHUB_OUTPUT | ||
echo "push=${PUSH}" >> $GITHUB_OUTPUT | ||
echo "github_server_url=${GITHUB_SERVER_URL}" >> $GITHUB_OUTPUT | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: ${{ steps.prep.outputs.images }} | ||
# generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}} | ||
type=edge,branch=master | ||
type=ref,event=branch | ||
type=raw,value=alpha | ||
type=sha | ||
flavor: latest=false # let's not produce a :latest tag | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
install: true | ||
version: latest | ||
driver-opts: image=moby/buildkit:master | ||
|
||
- name: Login to DockerHub | ||
if: steps.prep.outputs.has_docker_token != '' # secrets not available in PRs | ||
uses: docker/login-action@v2 | ||
with: | ||
username: abeltramo | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
|
||
- name: Login to GitHub Container Registry | ||
if: steps.prep.outputs.has_github_token != '' # secrets not available in PRs | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
|
||
- name: Build Gstreamer | ||
uses: docker/build-push-action@v3 | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: docker | ||
file: docker/gstreamer.Dockerfile | ||
push: true | ||
tags: ghcr.io/${{ github.repository_owner }}/gstreamer:1.20.3,gameonwhales/gstreamer:1.20.3 # TODO: set gstreamer version as param | ||
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/gstreamer:buildcache-1.20.3 | ||
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/gstreamer:buildcache-1.20.3,mode=max | ||
|
||
- name: Build Wolf | ||
uses: docker/build-push-action@v3 | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: . | ||
file: Dockerfile | ||
push: ${{ steps.prep.outputs.push }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
build-args: | | ||
IMAGE_SOURCE=${{ steps.prep.outputs.github_server_url }}/${{ github.repository }} | ||
cache-from: ${{ steps.prep.outputs.cache_from }} | ||
cache-to: ${{ steps.prep.outputs.cache_to }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Pushes the contents of the repo to the Codeberg mirror | ||
name: Repo Mirror | ||
on: [ push ] | ||
jobs: | ||
codeberg: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pixta-dev/repository-mirroring-action@v1 | ||
with: | ||
target_repo_url: "[email protected]:games-on-whales/wolf.git" | ||
ssh_private_key: ${{ secrets.CODEBERG_SSH }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
######################################################## | ||
FROM ubuntu:22.04 AS wolf-builder | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
ninja-build \ | ||
cmake \ | ||
ccache \ | ||
git \ | ||
clang \ | ||
libboost-thread-dev libboost-filesystem-dev libboost-log-dev libboost-stacktrace-dev \ | ||
libssl-dev \ | ||
libgstreamer1.0-dev \ | ||
libevdev-dev \ | ||
libunwind-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY src /wolf/src | ||
COPY cmake /wolf/cmake | ||
COPY CMakeLists.txt /wolf/CMakeLists.txt | ||
WORKDIR /wolf | ||
|
||
# TODO: link with gstreamer from gameonwhales/gstreamer:1.20.3 | ||
|
||
ENV CCACHE_DIR=/cache/ccache | ||
ENV CMAKE_BUILD_DIR=/cache/cmake-build | ||
RUN --mount=type=cache,target=/cache/ccache \ | ||
--mount=type=cache,target=/cache/cmake-build \ | ||
cmake -B$CMAKE_BUILD_DIR \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DCMAKE_CXX_STANDARD=17 \ | ||
-DCMAKE_CXX_EXTENSIONS=OFF \ | ||
-DBUILD_SHARED_LIBS=OFF \ | ||
-DBoost_USE_STATIC_LIBS=ON \ | ||
-DBUILD_TESTING=OFF \ | ||
-G Ninja && \ | ||
ninja -C $CMAKE_BUILD_DIR && \ | ||
# We have to copy out the built executable because this will only be available inside the buildkit cache | ||
cp $CMAKE_BUILD_DIR/src/wolf/wolf /wolf/wolf | ||
|
||
######################################################## | ||
FROM rust:1.66-slim AS gst-plugin-wayland | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update -y && \ | ||
apt-get install -y --no-install-recommends \ | ||
git ca-certificates pkg-config \ | ||
libwayland-dev libwayland-server0 libudev-dev libinput-dev libxkbcommon-dev libgbm-dev \ | ||
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ARG SUNRISE_SHA=eb5b07d79c42a69e700ca5666ce1710f9c8f4ef0 | ||
ENV SUNRISE_SHA=$SUNRISE_SHA | ||
RUN git clone https://github.com/Drakulix/sunrise.git && \ | ||
cd sunrise && \ | ||
git checkout $SUNRISE_SHA | ||
|
||
WORKDIR /sunrise/gst-plugin-wayland-display | ||
|
||
RUN --mount=type=cache,target=/usr/local/cargo/registry cargo build --release | ||
|
||
|
||
######################################################## | ||
FROM gameonwhales/gstreamer:1.20.3 AS runner | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Wolf runtime dependencies | ||
# curl only used by plugin curlhttpsrc (remote video play) | ||
RUN apt-get update -y && \ | ||
apt-get install -y --no-install-recommends \ | ||
ca-certificates libcurl4 \ | ||
tini \ | ||
libssl3 \ | ||
libevdev2 \ | ||
va-driver-all \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# gst-plugin-wayland runtime dependencies | ||
RUN apt-get update -y && \ | ||
apt-get install -y --no-install-recommends \ | ||
libwayland-server0 libinput10 libxkbcommon0 libgbm1 \ | ||
libglvnd0 libgl1 libglx0 libegl1 libgles2 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# TODO: avoid running as root | ||
|
||
COPY --from=wolf-builder /wolf/wolf /wolf/wolf | ||
COPY --from=gst-plugin-wayland /sunrise/gst-plugin-wayland-display/target/release/libgstwaylanddisplay.so $GST_PLUGIN_PATH/libgstwaylanddisplay.so | ||
|
||
# Here is where the dinamically created wayland sockets will be stored | ||
ENV XDG_RUNTIME_DIR=/wolf/run/ | ||
RUN mkdir $XDG_RUNTIME_DIR | ||
|
||
WORKDIR /wolf | ||
|
||
ARG WOLF_CFG_FOLDER=/wolf/cfg | ||
ENV WOLF_CFG_FOLDER=$WOLF_CFG_FOLDER | ||
RUN mkdir $WOLF_CFG_FOLDER | ||
|
||
ENV LOG_LEVEL=INFO | ||
ENV CFG_FILE=$WOLF_CFG_FOLDER/config.toml | ||
ENV PRIVATE_KEY_FILE=$WOLF_CFG_FOLDER/key.pem | ||
ENV PRIVATE_CERT_FILE=$WOLF_CFG_FOLDER/cert.pem | ||
VOLUME $WOLF_CFG_FOLDER | ||
|
||
# HTTPS | ||
EXPOSE 47984/tcp | ||
# HTTP | ||
EXPOSE 47989/tcp | ||
# Video | ||
EXPOSE 47998/udp | ||
# Control | ||
EXPOSE 47999/udp | ||
# Audio | ||
EXPOSE 48000/udp | ||
# RTSP | ||
EXPOSE 48010/tcp | ||
|
||
ENTRYPOINT ["/usr/bin/tini", "--"] | ||
CMD ["/wolf/wolf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Start by removing everything and add just the things we need | ||
* |
Oops, something went wrong.