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

Refactor of Docker, updated workflow #1063

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5317fae
refactor: test on other os, update action, cleanup docker
Gauvino Jul 31, 2024
e73d165
Merge branch 'master' into refactor-docker-ci
Gauvino Aug 7, 2024
71654a9
[build] 0.3.2
openbullet Sep 7, 2024
ea2894e
Merge branch 'openbullet:master' into refactor-docker-ci
Gauvino Sep 7, 2024
49ee194
Merge branch 'staging' into refactor-docker-ci
Gauvino Sep 11, 2024
fee840e
Bump dompurify from 3.1.0 to 3.1.7 in /openbullet2-web-client
dependabot[bot] Oct 11, 2024
9443f23
Merge pull request #1129 from openbullet/dependabot/npm_and_yarn/open…
openbullet Oct 15, 2024
7035548
Partial refactor of RuriLib
openbullet Oct 15, 2024
035712a
Refactored more of RuriLib's code
openbullet Oct 15, 2024
993d7b4
Refactored more of RuriLib's code
openbullet Dec 15, 2024
85bec99
Refactored
openbullet Dec 15, 2024
a05515b
Refactored
openbullet Dec 15, 2024
8947c86
Fixed small mistake that made tests fail
openbullet Dec 15, 2024
ecea0fb
Merge branch 'openbullet:master' into refactor-docker-ci
Gauvino Jan 6, 2025
7a2dd42
refactor: test on other os, update action, cleanup docker
Gauvino Jul 31, 2024
a164658
Bump dompurify from 3.1.0 to 3.1.7 in /openbullet2-web-client
dependabot[bot] Oct 11, 2024
46a2ef5
Merge branch 'refactor-docker-ci' of https://github.com/Gauvino/OpenB…
Gauvino Jan 6, 2025
0df29f4
refactor: test on other os, update action, cleanup docker
Gauvino Jul 31, 2024
9e21a6b
Bump dompurify from 3.1.0 to 3.1.7 in /openbullet2-web-client
dependabot[bot] Oct 11, 2024
8459cb1
Merge branch 'refactor-docker-ci' of https://github.com/Gauvino/OpenB…
Gauvino Jan 6, 2025
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
14 changes: 13 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
openbullet2-web-client/node_modules
Changelog/
.github
.git
.gitignore
.dockerignore
Dockerfile
Dockerfile.build
Dockerfile.remote
docker-compose.yml
CONTRIBUTORS.md
LICENSE
README.md
openbullet2-web-client/node_modules
10 changes: 5 additions & 5 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Read the version
- name: Read version
run: echo "VERSION=$(cat OpenBullet2.Web/version.txt)" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v6
with:
push: true
file: ./Dockerfile.remote
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ jobs:
if: contains(github.event.head_commit.message, '[build]')
steps:
- uses: actions/checkout@v4

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Unit and integration tests
run: dotnet test

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
if: contains(github.event.head_commit.message, '[build]')
steps:
- uses: actions/checkout@v4

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ on:
- staging

jobs:
test:
runs-on: ubuntu-latest
run-tests:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]

runs-on: "${{ matrix.os }}"
steps:
- uses: actions/checkout@v4

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Unit and integration tests
run: dotnet test
34 changes: 25 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,35 @@ COPY --from=frontend /build ./wwwroot
COPY OpenBullet2.Web/dbip-country-lite.mmdb .

# Install dependencies
RUN apt-get update -yq && apt-get install -y --no-install-recommends apt-utils
RUN apt-get upgrade -yq && apt-get install -yq apt-utils curl git nano wget unzip python3 python3-pip
RUN echo "deb http://deb.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list.d/debian.list \
&& apt-get update -yq \
&& apt-get install -y --no-install-recommends \
apt-utils \
&& apt-get upgrade -yq \
&& apt-get install -yq \
curl \
wget \
unzip \
git \
python3 \
python3-pip

# Setup nodejs
RUN curl -sL https://deb.nodesource.com/setup_current.x | bash - && apt-get install -yq nodejs build-essential
RUN echo "deb http://deb.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list.d/debian.list
RUN curl -sL https://deb.nodesource.com/setup_current.x | bash - \
&& apt-get install -yq \
nodejs \
build-essential

# Install chromium and firefox for selenium and puppeteer
RUN apt-get update -yq && apt-get install -y --no-install-recommends firefox chromium
RUN pip3 install webdrivermanager || true
RUN webdrivermanager firefox chrome --linkpath /usr/local/bin || true

RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update -yq && apt-get install -y --no-install-recommends firefox chromium \
&& pip3 install webdrivermanager || true \
&& webdrivermanager firefox chrome --linkpath /usr/local/bin || true

# Clean up
RUN apt-get remove curl wget unzip --yes \
&& apt-get clean autoclean --yes \
&& apt-get autoremove --yes \
&& rm -rf /var/cache/apt/archives* /var/lib/apt/lists/*

EXPOSE 5000
CMD ["dotnet", "./OpenBullet2.Web.dll", "--urls=http://*:5000"]
56 changes: 31 additions & 25 deletions Dockerfile.remote
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim

ENV DEBIAN_FRONTEND=noninteractive
ENV DEBIAN_FRONTEND=noninteractive \
LC_ALL="en_US.UTF-8" \
LANG="en_US.UTF-8" \
LANGUAGE="en_US:en"

# Install basic dependencies
RUN apt-get update -yq \
&& apt-get install -y --no-install-recommends \
apt-utils \
curl \
git \
nano \
wget \
unzip \
python3 \
python3-pip \
gnupg \
lsb-release \
software-properties-common
&& apt-get install -y --no-install-recommends \
curl \
wget \
unzip \
gnupg \
git \
python3 \
python3-pip \
lsb-release \
software-properties-common

# Setup Node.js (LTS Version)
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash - \
&& apt-get install -yq nodejs build-essential
&& apt-get install -yq \
nodejs \
build-essential

# Add Mozilla Team PPA for the latest Firefox
RUN echo "deb http://ppa.launchpad.net/mozillateam/ppa/ubuntu focal main" | tee /etc/apt/sources.list.d/mozillateam-ppa.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A6DCF7707EBC211F \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9BDB3D89CE49EC21 \
&& apt-get update -yq
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A6DCF7707EBC211F \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9BDB3D89CE49EC21 \
&& apt-get update -yq

# Install the latest Firefox and Chromium
RUN apt-get install -y --no-install-recommends \
firefox \
chromium
firefox \
chromium

# Install WebDriverManager
RUN pip3 install webdrivermanager || true \
&& webdrivermanager firefox chrome --linkpath /usr/local/bin || true

# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
&& webdrivermanager firefox chrome --linkpath /usr/local/bin || true

WORKDIR /app

# Download and unpack the latest OpenBullet2.Web release
RUN wget https://github.com/openbullet/openbullet2/releases/latest/download/OpenBullet2.Web.zip \
&& unzip OpenBullet2.Web.zip \
&& rm OpenBullet2.Web.zip
&& unzip OpenBullet2.Web.zip \
&& rm OpenBullet2.Web.zip

# Clean up
RUN apt-get remove curl wget unzip gnupg --yes \
&& apt-get clean autoclean --yes \
&& apt-get autoremove --yes \
&& rm -rf /var/cache/apt/archives* /var/lib/apt/lists/*

EXPOSE 5000

Expand Down
8 changes: 4 additions & 4 deletions OpenBullet2.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
builder.Services.AddScoped<IGuestRepository, DbGuestRepository>();
builder.Services.AddScoped<IRecordRepository, DbRecordRepository>();
builder.Services.AddScoped<IWordlistRepository>(service =>
new HybridWordlistRepository(service.GetService<ApplicationDbContext>(),
new HybridWordlistRepository(service.GetRequiredService<ApplicationDbContext>(),
$"{Globals.UserDataFolder}/Wordlists"));

builder.Services.AddScoped<DataPoolFactoryService>();
Expand All @@ -143,7 +143,7 @@
builder.Services.AddSingleton<IUpdateService, UpdateService>();
builder.Services.AddSingleton<PerformanceMonitorService>();
builder.Services.AddSingleton<IConfigRepository>(service =>
new DiskConfigRepository(service.GetService<RuriLibSettingsService>(),
new DiskConfigRepository(service.GetRequiredService<RuriLibSettingsService>(),
$"{Globals.UserDataFolder}/Configs"));
builder.Services.AddSingleton<ConfigService>();
builder.Services.AddSingleton(service =>
Expand All @@ -155,7 +155,7 @@
builder.Services.AddSingleton<ProxyCheckOutputFactory>();
builder.Services.AddSingleton<JobManagerService>();
builder.Services.AddSingleton(service =>
new JobMonitorService(service.GetService<JobManagerService>(),
new JobMonitorService(service.GetRequiredService<JobManagerService>(),
$"{Globals.UserDataFolder}/triggeredActions.json", false));
builder.Services.AddSingleton<HitStorageService>();
builder.Services.AddSingleton(_ => new RuriLibSettingsService(Globals.UserDataFolder));
Expand All @@ -166,7 +166,7 @@
_ => new IntoliRandomUAProvider("user-agents.json"));
builder.Services.AddSingleton<IRNGProvider, DefaultRNGProvider>();
builder.Services.AddSingleton<IJobLogger>(service =>
new FileJobLogger(service.GetService<RuriLibSettingsService>(),
new FileJobLogger(service.GetRequiredService<RuriLibSettingsService>(),
$"{Globals.UserDataFolder}/Logs/Jobs"));
builder.Services.AddSingleton<ConfigDebuggerService>();
builder.Services.AddSingleton<ProxyCheckJobService>();
Expand Down
42 changes: 24 additions & 18 deletions OpenBullet2.Web/Utils/BlockMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
using RuriLib.Models.Blocks.Settings;
using RuriLib.Models.Blocks.Settings.Interpolated;
using System.Text.Json;
using OpenBullet2.Web.Exceptions;

namespace OpenBullet2.Web.Utils;

static internal class BlockMapper
internal static class BlockMapper
{
// Here I did the dto -> block mappings manually while I find
// a way to make automapper work properly on BlockSetting...
static internal List<BlockInstance> MapStack(
internal static List<BlockInstance> MapStack(
this List<JsonElement> jsonElements, IMapper mapper)
{
var stack = new List<BlockInstance>();
Expand All @@ -28,6 +29,11 @@ static internal List<BlockInstance> MapStack(
var id = jsonElement.GetProperty("id").GetString();
BlockInstance block;

if (id is null)
{
throw new MappingException("Block id not found");
}

switch (id)
{
case "HttpRequest":
Expand Down Expand Up @@ -212,7 +218,7 @@ private static void MapMultipartSettings(MultipartRequestParamsDto dto,
foreach (var c in dto.Contents)
{
var contentDto = PolyMapper.ConvertPolyDto<HttpContentSettingsGroupDto>(
(JsonElement)c!);
(JsonElement)c);

HttpContentSettingsGroup content;

Expand Down Expand Up @@ -269,44 +275,44 @@ private static void MapSetting(BlockSettingDto? dto, BlockSetting setting)
}

setting.InputMode = dto.InputMode;
setting.InputVariableName = dto.InputVariableName;
setting.InputVariableName = dto.InputVariableName ?? string.Empty;
var value = (JsonElement)dto.Value!;

switch (dto.Type)
{
case BlockSettingType.String:
((StringSetting)setting.FixedSetting).Value = value.GetString();
((InterpolatedStringSetting)setting.InterpolatedSetting).Value = value.GetString();
((StringSetting)setting.FixedSetting!).Value = value.GetString();
((InterpolatedStringSetting)setting.InterpolatedSetting!).Value = value.GetString();
break;

case BlockSettingType.Int:
((IntSetting)setting.FixedSetting).Value = value.GetInt32();
((IntSetting)setting.FixedSetting!).Value = value.GetInt32();
break;

case BlockSettingType.Float:
((FloatSetting)setting.FixedSetting).Value = value.GetSingle();
((FloatSetting)setting.FixedSetting!).Value = value.GetSingle();
break;

case BlockSettingType.Bool:
((BoolSetting)setting.FixedSetting).Value = value.GetBoolean();
((BoolSetting)setting.FixedSetting!).Value = value.GetBoolean();
break;

case BlockSettingType.ByteArray:
((ByteArraySetting)setting.FixedSetting).Value = value.GetBytesFromBase64();
((ByteArraySetting)setting.FixedSetting!).Value = value.GetBytesFromBase64();
break;

case BlockSettingType.ListOfStrings:
((ListOfStringsSetting)setting.FixedSetting).Value = value
.Deserialize<List<string>>(Globals.JsonOptions);
((InterpolatedListOfStringsSetting)setting.InterpolatedSetting).Value = value
.Deserialize<List<string>>(Globals.JsonOptions);
((ListOfStringsSetting)setting.FixedSetting!).Value = value
.Deserialize<List<string>>(Globals.JsonOptions)!;
((InterpolatedListOfStringsSetting)setting.InterpolatedSetting!).Value = value
.Deserialize<List<string>>(Globals.JsonOptions)!;
break;

case BlockSettingType.DictionaryOfStrings:
((DictionaryOfStringsSetting)setting.FixedSetting).Value = value
.Deserialize<Dictionary<string, string>>(Globals.JsonOptions);
((InterpolatedDictionaryOfStringsSetting)setting.InterpolatedSetting).Value = value
.Deserialize<Dictionary<string, string>>(Globals.JsonOptions);
((DictionaryOfStringsSetting)setting.FixedSetting!).Value = value
.Deserialize<Dictionary<string, string>>(Globals.JsonOptions)!;
((InterpolatedDictionaryOfStringsSetting)setting.InterpolatedSetting!).Value = value
.Deserialize<Dictionary<string, string>>(Globals.JsonOptions)!;
break;

case BlockSettingType.Enum:
Expand Down
5 changes: 2 additions & 3 deletions RuriLib.Http/Helpers/ChunkedDecoderOptimized.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ private void ParseNewChunk(ref ReadOnlySequence<byte> buff)
}
}

private int GetChunkLength(ref ReadOnlySequence<byte> buff)
private static int GetChunkLength(ref ReadOnlySequence<byte> buff)
{
if (buff.IsSingleSegment)
{
var index = -1;
var span = buff.FirstSpan;
index = span.IndexOf(_crlfBytes);
var index = span.IndexOf(_crlfBytes);

if (index == -1)
{
Expand Down
2 changes: 1 addition & 1 deletion RuriLib.Http/RuriLib.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Authors>Ruri</Authors>
<Version>1.0.1</Version>
<Description>This is a library that provides a custom HTTP client, in addition to an HttpMessageHandler to be used with the default HttpClient of System.Net</Description>
<Copyright>Ruri 2022</Copyright>
<Copyright>Ruri 2024</Copyright>
<RepositoryUrl>https://github.com/openbullet/OpenBullet2/tree/master/RuriLib.Http</RepositoryUrl>
<PackageTags>http; proxy; socks; client; custom;</PackageTags>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion RuriLib.Parallelization.Tests/ParallelizerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public async Task Run_DecreaseConcurrentThreads_CompleteSlower()
[Fact]
public async Task Run_PauseAndResume_CompleteAll()
{
var count = 10;
const int count = 10;
var parallelizer = ParallelizerFactory<int, bool>.Create(
type: _type,
workItems: Enumerable.Range(1, count),
Expand Down
2 changes: 1 addition & 1 deletion RuriLib.Parallelization/RuriLib.Parallelization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Authors>Ruri</Authors>
<Description>This is a library that can perform multiple tasks (yes, a lot, even infinitely many) that act on some input and return a certain output.</Description>
<Copyright>Ruri 2022</Copyright>
<Copyright>Ruri 2024</Copyright>
<PackageProjectUrl>https://github.com/openbullet/OpenBullet2/tree/master/RuriLib.Parallelization</PackageProjectUrl>
<RepositoryUrl>https://github.com/openbullet/OpenBullet2/tree/master/RuriLib.Parallelization</RepositoryUrl>
<PackageTags>parallelization; task; tasks; manager; taskmanager; multithreading; parallel; multithread; async;</PackageTags>
Expand Down
Loading
Loading