-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
37 lines (27 loc) · 1.01 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Stage 1: Build the application
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /source
# Copy the source code into the container
COPY sharpsnmplib-samples/ ./
# Change to the directory that contains the project file
WORKDIR /source/Samples/CSharpCore/snmpd
# Restore dependencies
RUN dotnet restore
# Build the application
RUN dotnet publish -c Release -o /app/publish
# Stage 2: Create the runtime image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime
WORKDIR /app
# Copy the build artifacts from the previous stage
COPY --from=build /app/publish .
# Expose the port that the application will run on (optional, change as necessary)
EXPOSE 161/udp
# Metadata indicating an image maintainer
LABEL maintainer="support@lextudio.com"
LABEL description="Docker image for running snmpd (C# SNMP Daemon)"
LABEL version="1.0"
# Set the entrypoint for the application
ENTRYPOINT ["dotnet", "snmpd.dll"]
# Optional: Add a health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s \
CMD pgrep dotnet || exit 1