From b82b1ef5becc1f6d2355df796b7b37f269bfaf49 Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Sun, 15 Feb 2026 22:18:18 -0800 Subject: [PATCH] Start work on the docker container --- Todo.txt | 1 + docker-compose.yml | 8 +++++ dockerfile | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 Todo.txt create mode 100644 docker-compose.yml create mode 100644 dockerfile diff --git a/Todo.txt b/Todo.txt new file mode 100644 index 00000000..ff8fbb43 --- /dev/null +++ b/Todo.txt @@ -0,0 +1 @@ +Move the python stuff from venv into a docker \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..421af4fb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + + web-server: + container_name: web_server + build: . + restart: always + ports: + - 5000:5000 \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 00000000..c3e66a8f --- /dev/null +++ b/dockerfile @@ -0,0 +1,84 @@ +####################### +## Build Webserver ## +####################### + +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build-Webserver +WORKDIR /WebServer + +# Copy the csproj +COPY ./WebServer/Webserver.csproj ./ + +# Restore the Server +RUN dotnet restore './Webserver.csproj' + +# Copy the rest of the backend over +COPY ./WebServer/ ./ + +# Get the target arch +ARG TARGETARCH + +# Build the source +RUN set -e && \ + if [ "$TARGETARCH" = "arm64" ]; then RID="linux-arm64"; \ + elif [ "$TARGETARCH" = "amd64" ]; then RID="linux-x64"; \ + else echo "Unsupported ARCH: $TARGETARCH"; exit 1; \ + fi && \ + dotnet publish './Server.csproj' -c Release -r ${RID} -o /app/publish + +################ +## Publish ## +################ + +FROM mcr.microsoft.com/dotnet/aspnet:9.0 + +# Pull in required libraries to build python from source +RUN apt update && apt upgrade && apt install -y \ + build-essential \ + zlib1g-dev \ + libncurses5-dev \ + libgdbm-dev \ + libnss3-dev \ + libssl-dev \ + libreadline-dev \ + libffi-dev \ + libsqlite3-dev \ + libbz2-dev \ + wget \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Download, extract, configure, and compile python 3.11 +# Use Hardlinks and altinstall to not break system components that rely on the builtin python +RUN wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz && \ + tar -xf Python-3.11.0.tgz && \ + cd Python-3.11.0 && \ + ./configure --enable-optimizations && \ + make -j$(nproc) && \ + make altinstall && \ + cd .. && \ + rm -rf Python-3.11.0.tgz Python-3.11.0 && \ + ln -s /usr/local/bin/python3.11 /usr/local/bin/python && \ + ln -s /usr/local/bin/pip3.11 /usr/local/bin/pip + +RUN pip install --upgrade pip && \ + pip install tensorflow \ + fastparquet \ + openpyxl \ + yfinance + +WORKDIR /app + +ENV ASPNETCORE_HTTP_PORTS=5000 +ENV StripeKey=null +ENV MySQLServer=null +ENV MySQLUser=null +ENV MySQLPass=null +ENV MySQLDatabase=Mistox + +EXPOSE 5000 + +# Copy in the webserver +COPY --from=build-Webserver /app/publish ./ + +# Start the container +ENTRYPOINT ["dotnet", "MistoxWebsite.Server.dll", "--url", "http://localhost:5000"] \ No newline at end of file