diff --git a/CSETWebApi/Dockerfile b/CSETWebApi/Dockerfile new file mode 100644 index 000000000..3bcd34258 --- /dev/null +++ b/CSETWebApi/Dockerfile @@ -0,0 +1,28 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build + +# Set the working directory inside the container +WORKDIR /app + +# Copy the project files (csproj) and restore dependencies +COPY ./CSETWeb_Api/CSETWeb_ApiCore/*.csproj ./ +RUN dotnet restore + +# Copy the rest of the application code +COPY . . + +# Build the application +RUN dotnet build CSETWeb_Api/CSETWeb_ApiCore --configuration Debug + +# Expose the port the app runs on (default for ASP.NET Core is 5000 for HTTP) +EXPOSE 5000 + +# Set environment variables for development mode +ENV ASPNETCORE_ENVIRONMENT=Development +ENV ASPNETCORE_URLS=http://0.0.0.0:5000 + + +COPY ./etc/entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod a+x /usr/local/bin/entrypoint.sh + +# Run the application +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/CSETWebApi/etc/entrypoint.sh b/CSETWebApi/etc/entrypoint.sh new file mode 100644 index 000000000..823457d6f --- /dev/null +++ b/CSETWebApi/etc/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Run the API +dotnet run --project CSETWeb_Api/CSETWeb_ApiCore diff --git a/docker-compose.yml b/docker-compose.yml index 049db4318..bde1a900b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,19 @@ --- services: + api: + container_name: cset-api + hostname: api + build: + context: CSETWebApi + restart: unless-stopped + extra_hosts: + - "host.docker.internal:host-gateway" + ports: + - "5000:5000" + volumes: + - ./CSETWebApi:/app + depends_on: + - sqlserver sqlserver: container_name: cset-mssql hostname: mssql