Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
openbullet committed Jul 10, 2024
2 parents 5656d5d + 5738156 commit f0064d7
Show file tree
Hide file tree
Showing 43 changed files with 682 additions and 408 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
openbullet2-web-client/node_modules
43 changes: 43 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ on:
- 'master'

jobs:
test:
runs-on: ubuntu-latest
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

build:
runs-on: ubuntu-latest
needs: test
# Only run if the commit message contains the string [build]
if: contains(github.event.head_commit.message, '[build]')
steps:
Expand Down Expand Up @@ -87,3 +99,34 @@ jobs:
with:
## If no one connects after 5 minutes, shut down server.
wait-timeout-minutes: 5

docker:
name: Push Docker image to Docker Hub
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

# 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

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

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

- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64
tags: openbullet/openbullet2:latest,openbullet/openbullet2:${{ env.VERSION }}
18 changes: 17 additions & 1 deletion .github/workflows/build-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ on:
- 'staging'

jobs:
test:
runs-on: ubuntu-latest
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

build:
runs-on: ubuntu-latest
needs: test
# Only run if the commit message contains the string [build]
if: contains(github.event.head_commit.message, '[build]')
steps:
Expand All @@ -22,10 +34,14 @@ jobs:
- name: Get commit number
run: echo "COMMIT_NUMBER=$(git rev-list --count HEAD)" >> $GITHUB_ENV

# Append the commit number to version.txt
# Append the commit number to version.txt of the web client
- name: Append commit number to version.txt
run: echo ".$COMMIT_NUMBER" >> OpenBullet2.Web/version.txt

# Append the commit number to version.txt of the native client
- name: Append commit number to version.txt
run: echo ".$COMMIT_NUMBER" >> OpenBullet2.Native/version.txt

# Get the commit description
- name: Get commit description
run: |
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run tests

on:
push:
branches:
- master
- staging
pull_request:
branches:
- master
- staging

jobs:
test:
runs-on: ubuntu-latest
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
21 changes: 0 additions & 21 deletions .github/workflows/unittests.yml

This file was deleted.

69 changes: 69 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# -------
# BACKEND
# -------
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS backend

WORKDIR /code

COPY . .
RUN dotnet publish OpenBullet2.Web -c Release -o /build/web

WORKDIR /build/web

# Remove all .xml files
# (we cannot use <GenerateDocumentationFile>false</GenerateDocumentationFile>
# because we need it for swagger)
RUN find . -name "*.xml" -type f -delete

# Manually copy over the dbip-country-lite.mmdb file from /code to /build
# since for some reason it doesn't get copied over by the dotnet publish command
RUN cp /code/OpenBullet2.Web/dbip-country-lite.mmdb /build

# --------
# FRONTEND
# --------
FROM node:20.9.0 AS frontend

WORKDIR /code

COPY openbullet2-web-client/package.json .
COPY openbullet2-web-client/package-lock.json .
RUN npm install

COPY openbullet2-web-client .
RUN npm run build
RUN mkdir /build && mv dist/* /build

# ---------
# AGGREGATE
# ---------
FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim

ENV DEBIAN_FRONTEND=noninteractive

WORKDIR /app

COPY --from=backend /build/web .
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

# 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

# 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/*

WORKDIR /app

EXPOSE 5000
CMD ["dotnet", "./OpenBullet2.Web.dll", "--urls=http://*:5000"]

2 changes: 1 addition & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN cp /code/OpenBullet2.Web/dbip-country-lite.mmdb /build
# --------
# FRONTEND
# --------
FROM node:20.3.0 AS frontend
FROM node:20.9.0 AS frontend

WORKDIR /code

Expand Down
16 changes: 0 additions & 16 deletions Dockerfile.old

This file was deleted.

9 changes: 8 additions & 1 deletion OpenBullet2.Native/Views/Dialogs/ImportProxiesDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@
<TabItem x:Name="pasteTab">
<StackPanel>
<Label Content="Paste your proxies in the box below" />
<TextBox x:Name="proxiesBox" AcceptsReturn="True" TextWrapping="Wrap" Height="100" VerticalScrollBarVisibility="Auto" Margin="0 5" FontFamily="Consolas"/>
<TextBox x:Name="proxiesBox"
AcceptsReturn="True"
TextWrapping="Wrap"
Height="100"
VerticalScrollBarVisibility="Auto"
Margin="0 5"
VerticalContentAlignment="Top"
FontFamily="Consolas"/>
</StackPanel>
</TabItem>
<TabItem x:Name="remoteTab">
Expand Down
1 change: 1 addition & 0 deletions OpenBullet2.Native/Views/Dialogs/SelectWordlistDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
FontFamily="Consolas"
IsReadOnly="True"
AcceptsReturn="True"
VerticalContentAlignment="Top"
Text="{Binding LinesPreview}" />
</Grid>

Expand Down
1 change: 1 addition & 0 deletions OpenBullet2.Native/Views/Pages/ConfigCSharpCode.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
Grid.Row="1"
AcceptsReturn="True"
IsReadOnly="True"
VerticalContentAlignment="Top"
Text="{Binding UsingsString}" />
</Grid>

Expand Down
1 change: 1 addition & 0 deletions OpenBullet2.Native/Views/Pages/ConfigLoliCode.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
FontFamily="Consolas"
Grid.Row="1"
AcceptsReturn="True"
VerticalContentAlignment="Top"
Text="{Binding UsingsString}" />
</Grid>

Expand Down
11 changes: 4 additions & 7 deletions OpenBullet2.Native/Views/Pages/ConfigSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,19 +375,16 @@
VerticalContentAlignment="Center"
Margin="5 10 0 0"/>
<Label Margin="0 10 0 0">Blocked URLs (one per line)</Label>
<RichTextBox x:Name="blockedUrlsRTB"
<TextBox x:Name="blockedUrlsTextBox"
Background="{DynamicResource BackgroundSecondary}"
Foreground="{DynamicResource ForegroundMain}"
FontFamily="Consolas"
Margin="5"
Height="100"
VerticalContentAlignment="Top"
AcceptsReturn="True"
TextChanged="BlockedUrlsChanged">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
</TextBox>
</StackPanel>
</ScrollViewer>
</Grid>
Expand Down
9 changes: 4 additions & 5 deletions OpenBullet2.Native/Views/Pages/ConfigSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public ConfigSettings()
DataContext = vm;

InitializeComponent();
SetRTBContents();
SetMultiLineTextBoxContents();
}

public void UpdateViewModel() => vm.UpdateViewModel();

private void BlockedUrlsChanged(object sender, TextChangedEventArgs e)
=> vm.BlockedUrls = blockedUrlsRTB.Lines().ToList();
=> vm.BlockedUrls = blockedUrlsTextBox.Text.Split(Environment.NewLine).ToList();

private void AddCustomInput(object sender, RoutedEventArgs e) => vm.AddCustomInput();
private void RemoveCustomInput(object sender, RoutedEventArgs e)
Expand All @@ -48,10 +48,9 @@ private void RemoveResource(object sender, RoutedEventArgs e)
private void RemoveDataRule(object sender, RoutedEventArgs e)
=> vm.RemoveDataRule((DataRule)(sender as Button).Tag);

private void SetRTBContents()
private void SetMultiLineTextBoxContents()
{
blockedUrlsRTB.Document.Blocks.Clear();
blockedUrlsRTB.AppendText(string.Join(Environment.NewLine, vm.BlockedUrls), Colors.White);
blockedUrlsTextBox.Text = string.Join(Environment.NewLine, vm.BlockedUrls);
}

private void TestDataRules(object sender, RoutedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion OpenBullet2.Native/Views/Pages/OBSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
</Button>
<Label Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Content="Description" />
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding Description}" Height="30" Margin="5 0" />
<TextBox Grid.Row="2" Grid.ColumnSpan="3" Grid.Column="0" FontFamily="Consolas" AcceptsReturn="True" Text="{Binding Body}" Margin="5" />
<TextBox Grid.Row="2" Grid.ColumnSpan="3" Grid.Column="0" FontFamily="Consolas" VerticalContentAlignment="Top" AcceptsReturn="True" Text="{Binding Body}" Margin="5" />
</Grid>
</Border>
</DataTemplate>
Expand Down
Loading

0 comments on commit f0064d7

Please sign in to comment.