Spaces:
Running
Running
Commit
·
d7c7c9b
1
Parent(s):
1279c6b
- Dockerfile +72 -0
- appsettings.json +12 -0
- build-docker-command +2 -0
- commit +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use the official Debian 12 (Bookworm) base image
|
| 2 |
+
FROM debian:12
|
| 3 |
+
|
| 4 |
+
# Set environment variables to avoid interactive prompts during package installation
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
+
|
| 7 |
+
# Install system-level dependencies as root
|
| 8 |
+
RUN apt-get update && \
|
| 9 |
+
apt-get install -y \
|
| 10 |
+
curl \
|
| 11 |
+
git \
|
| 12 |
+
wget \
|
| 13 |
+
vim
|
| 14 |
+
|
| 15 |
+
# Create a non-root user and set up their environment
|
| 16 |
+
RUN useradd -m user && \
|
| 17 |
+
mkdir -p /home/user/code && \
|
| 18 |
+
chown -R user:user /home/user
|
| 19 |
+
|
| 20 |
+
# Switch to the non-root user
|
| 21 |
+
USER user
|
| 22 |
+
WORKDIR /home/user
|
| 23 |
+
|
| 24 |
+
RUN mkdir -p /home/user/code/models && \
|
| 25 |
+
mkdir -p /home/user/code/app/wwwroot
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# Install .NET 9.0 as the non-root user
|
| 32 |
+
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \
|
| 33 |
+
chmod +x dotnet-install.sh && \
|
| 34 |
+
./dotnet-install.sh --channel 9.0
|
| 35 |
+
|
| 36 |
+
# Set persistent environment variables
|
| 37 |
+
ENV DOTNET_ROOT=/home/user/.dotnet
|
| 38 |
+
ENV PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
|
| 39 |
+
|
| 40 |
+
# Verify .NET installation and current user
|
| 41 |
+
RUN whoami && dotnet --version
|
| 42 |
+
|
| 43 |
+
# Clone repositories using the GITHUB_TOKEN secret
|
| 44 |
+
RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
|
| 45 |
+
git clone https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/Mungert69/NetworkMonitor.git /home/user/code/NetworkMonitor && \
|
| 46 |
+
git clone https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/Mungert69/NetworkMonitorAgent.git /home/user/code/NetworkMonitorAgent && \
|
| 47 |
+
git clone https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/Mungert69/NetworkMonitorBlazor.git /home/user/code/NetworkMonitorBlazor
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# Copy files into the container as the non-root user
|
| 51 |
+
COPY --chown=user:user appsettings.json /home/user/code/app/appsettings.json
|
| 52 |
+
COPY --chown=user:user wwwroot /home/user/code/app/wwwroot
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
# Expose port 7860 for Hugging Face Spaces
|
| 57 |
+
EXPOSE 7860
|
| 58 |
+
# Set the working directory
|
| 59 |
+
WORKDIR /home/user/code/NetworkMonitorBlazor
|
| 60 |
+
|
| 61 |
+
# Build the .NET project as the non-root user
|
| 62 |
+
RUN dotnet restore && \
|
| 63 |
+
dotnet build -c Release
|
| 64 |
+
|
| 65 |
+
RUN cp -r /home/user/code/NetworkMonitorBlazor/bin/Release/net9.0/* /home/user/code/app/ && \
|
| 66 |
+
rm -rf /home/user/code/NetworkMonitor /home/user/code/NetworkMonitorBlazor /home/user/code/NetworkMonitorAgent
|
| 67 |
+
|
| 68 |
+
# Set the working directory to the `app` directory
|
| 69 |
+
WORKDIR /home/user/code/app
|
| 70 |
+
|
| 71 |
+
# Run the .NET app as the non-root user
|
| 72 |
+
CMD ["dotnet", "NetworkMonitorBlazor.dll", "--urls", "http://0.0.0.0:7860"]
|
appsettings.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Logging": {
|
| 3 |
+
"LogLevel": {
|
| 4 |
+
"Default": "Information",
|
| 5 |
+
"Microsoft.AspNetCore": "Warning"
|
| 6 |
+
}
|
| 7 |
+
},
|
| 8 |
+
"AllowedHosts": "*",
|
| 9 |
+
"ChatServer": "devchatsrv.freenetworkmonitor.click",
|
| 10 |
+
"TranscribeAudioUrl" : "https://transcribe.freenetworkmonitor.click/transcribe_audio"
|
| 11 |
+
}
|
| 12 |
+
|
build-docker-command
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
DOCKER_BUILDKIT=1 docker build --secret id=GITHUB_TOKEN,env=GITHUB_TOKEN -t netmonassistant .
|
| 2 |
+
|
commit
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
git add .
|
| 2 |
+
git commit -m "$*"
|
| 3 |
+
git push
|