From 5317fae5e07f38309b82dcda7304e8b4888ef826 Mon Sep 17 00:00:00 2001 From: Uruk Date: Wed, 31 Jul 2024 19:11:12 +0200 Subject: [PATCH] refactor: test on other os, update action, cleanup docker --- .dockerignore | 14 +++++++- .github/workflows/build-docker.yml | 10 +++--- .github/workflows/build-release.yml | 2 ++ .github/workflows/build-staging.yml | 1 + .github/workflows/run-tests.yml | 10 ++++-- Dockerfile | 34 +++++++++++++----- Dockerfile.remote | 56 ++++++++++++++++------------- 7 files changed, 85 insertions(+), 42 deletions(-) diff --git a/.dockerignore b/.dockerignore index eb563a67d..2bae9e5fe 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,13 @@ -openbullet2-web-client/node_modules \ No newline at end of file +Changelog/ +.github +.git +.gitignore +.dockerignore +Dockerfile +Dockerfile.build +Dockerfile.remote +docker-compose.yml +CONTRIBUTORS.md +LICENSE +README.md +openbullet2-web-client/node_modules diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index bdb91c0eb..535b94a26 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -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 diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 1a43446d2..a4775a9d5 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -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 diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 7b07a5db9..3c063fd77 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -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: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b0daebb02..79cddfd59 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 460d40e8c..ca0c5aca7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/Dockerfile.remote b/Dockerfile.remote index badd3af50..7602e8cfa 100644 --- a/Dockerfile.remote +++ b/Dockerfile.remote @@ -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