Skip to content

Commit

Permalink
XMR.NET (#36)
Browse files Browse the repository at this point in the history
* .NET Core XMR container
* Feature parity with PHP XMR
* Slightly different environment variables and log format
  • Loading branch information
dasgarner authored Oct 16, 2023
1 parent da3abf1 commit 394c785
Show file tree
Hide file tree
Showing 21 changed files with 798 additions and 710 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- develop
- dotnet

release:
types: [ published ]
Expand Down Expand Up @@ -38,6 +39,12 @@ jobs:
docker build . -t ghcr.io/xibosignage/xibo-xmr:develop
docker push ghcr.io/xibosignage/xibo-xmr:develop
- name: Build Develop
if: github.ref == 'refs/heads/dotnet'
run: |
docker build . -t ghcr.io/xibosignage/xibo-xmr:dotnet
docker push ghcr.io/xibosignage/xibo-xmr:dotnet
- name: Build Release
if: github.event_name == 'release'
run: |
Expand Down
212 changes: 210 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,211 @@
vendor/
.idea/
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/

# Visual Studio 2015 cache/options directory
.vs/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# VS code
.vscode

# Ignore config file for local testing.
config.json
54 changes: 25 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
FROM composer:1.6 as composer
COPY . /app
RUN composer install --no-interaction --no-dev --ignore-platform-reqs --optimize-autoloader
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /App

FROM php:8.1-cli
MAINTAINER Xibo Signage Ltd <[email protected]>
# Copy everything
COPY . ./

ENV XMR_DEBUG false
ENV XMR_QUEUE_POLL 5
ENV XMR_QUEUE_SIZE 10
ENV XMR_IPV6RESPSUPPORT false
ENV XMR_IPV6PUBSUPPORT false
# Restore as distinct layers
RUN dotnet restore

RUN apt-get update && apt-get install -y libzmq3-dev git \
&& rm -rf /var/lib/apt/lists/*
# Build and publish a release
RUN dotnet publish -c Release -o out

RUN git clone https://github.com/zeromq/php-zmq.git \
&& cd php-zmq \
&& phpize && ./configure \
&& make \
&& make install \
&& cd .. \
&& rm -fr php-zmq
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:7.0

RUN docker-php-ext-enable zmq
LABEL org.opencontainers.image.source=https://github.com/xibosignage/xibo-xmr
LABEL org.opencontainers.image.description="Xibo Message Relay - XMR"
LABEL org.opencontainers.image.licenses=AGPL-3.0-or-later
LABEL org.opencontainers.image.authors="[email protected]"

EXPOSE 9505 50001

COPY ./entrypoint.sh /entrypoint.sh
COPY . /opt/xmr
COPY --from=composer /app/vendor /opt/xmr/vendor
WORKDIR /App
COPY --from=build-env /App/out .

RUN chown -R nobody /opt/xmr && chmod 755 /entrypoint.sh
# Define some environment variables
ENV Logging__LogLevel__Default "Information"
ENV Zmq__listenOn "tcp://*:50001"
ENV Zmq__pubOn__0 "tcp://*:9505"
ENV Zmq__ipv6RespSupport false
ENV Zmq__ipv6PubSupport false

# Start XMR
USER nobody
# Expose the ports
EXPOSE 9505 50001

CMD ["/entrypoint.sh"]
ENTRYPOINT ["dotnet", "xibo-xmr.dll"]
42 changes: 42 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using xibo_xmr;

IHost host = Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddCommandLine(args);
config.AddJsonFile($"appsettings.json", optional: false, reloadOnChange: true);
config.AddEnvironmentVariables();
})
.ConfigureServices((hostContext, services) =>
{
services.Configure<ZmqSettings>(hostContext.Configuration.GetSection("Zmq"));
services.AddHostedService<Worker>();
})
.UseWindowsService()
.UseSystemd()
.Build();

host.Run();
11 changes: 11 additions & 0 deletions Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"profiles": {
"xibo_xmr": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}
Loading

0 comments on commit 394c785

Please sign in to comment.