Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +10 -24
Dockerfile
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
# Use the official Debian 13 (Trixie) base image
|
| 2 |
FROM debian:13
|
| 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
|
|
@@ -10,7 +9,7 @@ RUN apt-get update && \
|
|
| 10 |
curl \
|
| 11 |
git \
|
| 12 |
wget \
|
| 13 |
-
vim
|
| 14 |
libicu-dev
|
| 15 |
|
| 16 |
# Create a non-root user and set up their environment
|
|
@@ -18,24 +17,19 @@ RUN useradd -m user && \
|
|
| 18 |
mkdir -p /home/user/code && \
|
| 19 |
chown -R user:user /home/user
|
| 20 |
|
| 21 |
-
# Switch to the non-root user
|
| 22 |
USER user
|
| 23 |
WORKDIR /home/user
|
| 24 |
|
| 25 |
-
RUN mkdir -p /home/user/code/models
|
| 26 |
-
mkdir -p /home/user/code/app/wwwroot
|
| 27 |
|
| 28 |
-
|
| 29 |
-
# Install .NET 9.0 as the non-root user
|
| 30 |
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \
|
| 31 |
chmod +x dotnet-install.sh && \
|
| 32 |
./dotnet-install.sh --channel 10.0
|
| 33 |
|
| 34 |
-
# Set persistent environment variables
|
| 35 |
ENV DOTNET_ROOT=/home/user/.dotnet
|
| 36 |
ENV PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
|
| 37 |
|
| 38 |
-
# Verify .NET installation and current user
|
| 39 |
RUN whoami && dotnet --version
|
| 40 |
|
| 41 |
# Clone repositories using the GITHUB_TOKEN secret
|
|
@@ -44,27 +38,19 @@ RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
|
|
| 44 |
git clone https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/Mungert69/NetworkMonitorChatRazorLib.git /home/user/code/NetworkMonitorChatRazorLib && \
|
| 45 |
git clone https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/Mungert69/NetworkMonitorBlazor.git /home/user/code/NetworkMonitorBlazor
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
# Copy wwwroot from the cloned repo (inside container)
|
| 50 |
-
RUN cp -r /home/user/code/NetworkMonitorBlazor/wwwroot /home/user/code/app/
|
| 51 |
-
# After cloning all repositories
|
| 52 |
-
|
| 53 |
EXPOSE 7860
|
| 54 |
-
# Set the working directory
|
| 55 |
-
WORKDIR /home/user/code/NetworkMonitorBlazor
|
| 56 |
|
| 57 |
-
# Build
|
|
|
|
| 58 |
RUN dotnet restore && \
|
| 59 |
-
dotnet
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
rm -rf /home/user/code/NetworkMonitorLib /home/user/code/NetworkMonitorBlazor /home/user/code/NetworkMonitorChatRazorLib
|
| 63 |
-
# Copy files into the container as the non-root user
|
| 64 |
COPY --chown=user:user appsettings.json /home/user/code/app/appsettings.json
|
| 65 |
|
| 66 |
-
# Set the working directory to the `app` directory
|
| 67 |
WORKDIR /home/user/code/app
|
| 68 |
|
| 69 |
-
# Run the .NET app as the non-root user
|
| 70 |
CMD ["dotnet", "NetworkMonitorBlazor.dll", "--urls", "http://0.0.0.0:7860"]
|
|
|
|
| 1 |
# Use the official Debian 13 (Trixie) base image
|
| 2 |
FROM debian:13
|
| 3 |
|
|
|
|
| 4 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
|
| 6 |
# Install system-level dependencies as root
|
|
|
|
| 9 |
curl \
|
| 10 |
git \
|
| 11 |
wget \
|
| 12 |
+
vim \
|
| 13 |
libicu-dev
|
| 14 |
|
| 15 |
# Create a non-root user and set up their environment
|
|
|
|
| 17 |
mkdir -p /home/user/code && \
|
| 18 |
chown -R user:user /home/user
|
| 19 |
|
|
|
|
| 20 |
USER user
|
| 21 |
WORKDIR /home/user
|
| 22 |
|
| 23 |
+
RUN mkdir -p /home/user/code/models
|
|
|
|
| 24 |
|
| 25 |
+
# Install .NET 10 as the non-root user
|
|
|
|
| 26 |
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \
|
| 27 |
chmod +x dotnet-install.sh && \
|
| 28 |
./dotnet-install.sh --channel 10.0
|
| 29 |
|
|
|
|
| 30 |
ENV DOTNET_ROOT=/home/user/.dotnet
|
| 31 |
ENV PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
|
| 32 |
|
|
|
|
| 33 |
RUN whoami && dotnet --version
|
| 34 |
|
| 35 |
# Clone repositories using the GITHUB_TOKEN secret
|
|
|
|
| 38 |
git clone https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/Mungert69/NetworkMonitorChatRazorLib.git /home/user/code/NetworkMonitorChatRazorLib && \
|
| 39 |
git clone https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/Mungert69/NetworkMonitorBlazor.git /home/user/code/NetworkMonitorBlazor
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
EXPOSE 7860
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
# Build + publish the Blazor app
|
| 44 |
+
WORKDIR /home/user/code/NetworkMonitorBlazor
|
| 45 |
RUN dotnet restore && \
|
| 46 |
+
dotnet publish -c Release -o /home/user/code/app
|
| 47 |
+
|
| 48 |
+
# Clean up repos (optional)
|
| 49 |
+
RUN rm -rf /home/user/code/NetworkMonitorLib /home/user/code/NetworkMonitorChatRazorLib /home/user/code/NetworkMonitorBlazor
|
| 50 |
|
| 51 |
+
# Copy config into publish folder
|
|
|
|
|
|
|
| 52 |
COPY --chown=user:user appsettings.json /home/user/code/app/appsettings.json
|
| 53 |
|
|
|
|
| 54 |
WORKDIR /home/user/code/app
|
| 55 |
|
|
|
|
| 56 |
CMD ["dotnet", "NetworkMonitorBlazor.dll", "--urls", "http://0.0.0.0:7860"]
|