From 0cd646f030d58fc11cb01573ed0daa7a82dccfa9 Mon Sep 17 00:00:00 2001 From: Ruri Date: Thu, 11 Jul 2024 17:11:23 +0200 Subject: [PATCH] [build-docker] Fixed docker build --- .github/workflows/build-docker.yml | 3 +- .github/workflows/build-release.yml | 1 + Dockerfile | 6 +-- Dockerfile.build | 2 + Dockerfile.remote | 31 +++++++++++++++ OpenBullet2.Web/Dockerfile | 58 ----------------------------- 6 files changed, 39 insertions(+), 62 deletions(-) create mode 100644 Dockerfile.remote delete mode 100644 OpenBullet2.Web/Dockerfile diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 2ef83445f..bdb91c0eb 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -36,5 +36,6 @@ jobs: uses: docker/build-push-action@v2 with: push: true - platforms: linux/arm64/v8,linux/amd64 + file: ./Dockerfile.remote + platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 tags: openbullet/openbullet2:latest,openbullet/openbullet2:${{ env.VERSION }} diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index f23202281..0bd2fb1b9 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -128,5 +128,6 @@ jobs: uses: docker/build-push-action@v2 with: push: true + file: ./Dockerfile.remote platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 tags: openbullet/openbullet2:latest,openbullet/openbullet2:${{ env.VERSION }} diff --git a/Dockerfile b/Dockerfile index c2cf9d983..460d40e8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,6 @@ +# This Dockerfile is meant to be run locally to build the OpenBullet2 project +# for normal usage via docker. + # ------- # BACKEND # ------- @@ -62,8 +65,5 @@ 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"] - \ No newline at end of file diff --git a/Dockerfile.build b/Dockerfile.build index 4e4a83647..c0765115e 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -1,3 +1,5 @@ +# This Dockerfile is meant to be run in a CI/CD pipeline to build the OpenBullet2 project. + # ------- # BACKEND # ------- diff --git a/Dockerfile.remote b/Dockerfile.remote new file mode 100644 index 000000000..92c67f3a5 --- /dev/null +++ b/Dockerfile.remote @@ -0,0 +1,31 @@ +# This Dockerfile pulls the latest build of the OpenBullet2 project from +# the latest release on GitHub and wraps it in a Docker container. + +FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim + +ENV DEBIAN_FRONTEND=noninteractive + +# 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 + +# Get OpenBullet2.Web from the latest release on GitHub +RUN wget https://github.com/openbullet/openbullet2/releases/latest/download/OpenBullet2.Web.zip +RUN unzip OpenBullet2.Web.zip +RUN rm OpenBullet2.Web.zip + +EXPOSE 5000 +CMD ["dotnet", "./OpenBullet2.Web.dll", "--urls=http://*:5000"] diff --git a/OpenBullet2.Web/Dockerfile b/OpenBullet2.Web/Dockerfile deleted file mode 100644 index 9fd72d1e1..000000000 --- a/OpenBullet2.Web/Dockerfile +++ /dev/null @@ -1,58 +0,0 @@ -# ------- -# BACKEND -# ------- -FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS backend - -WORKDIR /code - -COPY . . - -#Disable Beauty to avoid Errors -RUN sed -i 's/False<\/DisableBeauty>/True<\/DisableBeauty>/' OpenBullet2.Web/OpenBullet2.Web.csproj - -RUN dotnet publish OpenBullet2.Web -c Release -o /build - -WORKDIR /build - -# Remove all .xml files -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.3.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 - -# --- -# RUN -# --- -FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim - -WORKDIR /app - -# TODO: Add other dependencies (e.g. node, python, etc.) -RUN apt-get update -yq && apt-get install -y --no-install-recommends curl - -COPY --from=backend /build . -COPY --from=frontend /build ./wwwroot -COPY OpenBullet2.Web/dbip-country-lite.mmdb . - -# Create a text file with all the files and folders in the current directory, not recursive, to be used by the updater -RUN ls -1 > build-files.txt - -EXPOSE 5000 - -CMD ["dotnet", "./OpenBullet2.Web.dll", "--urls=http://*:5000"]