Skip to content

Commit

Permalink
Merge pull request #4472 from cisagov/feature/dockerize-backend
Browse files Browse the repository at this point in the history
feature: dockerize backend
  • Loading branch information
randywoods authored Mar 4, 2025
2 parents e62a18d + 227640d commit 214ee61
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
28 changes: 28 additions & 0 deletions CSETWebApi/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 4 additions & 0 deletions CSETWebApi/etc/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Run the API
dotnet run --project CSETWeb_Api/CSETWeb_ApiCore
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 214ee61

Please sign in to comment.