2023-08-28 00:03:24 -05:00
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
2023-08-29 21:23:40 -05:00
# Use the ASP.NET base image
2023-08-28 00:03:24 -05:00
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
2023-08-29 21:23:40 -05:00
# Use the SDK image for building
2023-08-28 00:03:24 -05:00
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
2023-08-29 21:23:40 -05:00
# Copy the project file and restore dependencies
2023-08-28 00:03:24 -05:00
COPY [ "DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj" , "DamageAssesment.Api.Attachments/" ]
RUN dotnet restore "DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj"
2023-08-29 21:23:40 -05:00
# Copy the source code
2023-08-28 00:03:24 -05:00
COPY . .
WORKDIR "/src/DamageAssesment.Api.Attachments"
2023-08-29 21:23:40 -05:00
# Build the application
2023-08-28 00:03:24 -05:00
RUN dotnet build "DamageAssesment.Api.Attachments.csproj" -c Release -o /app/build
2023-08-29 21:23:40 -05:00
# Publish the application
2023-08-28 00:03:24 -05:00
FROM build AS publish
RUN dotnet publish "DamageAssesment.Api.Attachments.csproj" -c Release -o /app/publish /p:UseAppHost= false
2023-08-29 21:23:40 -05:00
# Set up the final image
2023-08-28 00:03:24 -05:00
FROM base AS final
WORKDIR /app
2023-08-29 21:23:40 -05:00
# Copy the published files
2023-08-28 00:03:24 -05:00
COPY --from= publish /app/publish .
2023-08-29 21:23:40 -05:00
2023-08-28 00:03:24 -05:00
# Create directories for attachments and set permissions
RUN mkdir -p /app/DMS_Attachments/Active && \
mkdir -p /app/DMS_Attachments/Deleted && \
chown -R www-data:www-data /app/DMS_Attachments
2023-08-29 21:23:40 -05:00
# Update appsettings.json with the correct paths for attachments
2023-08-28 00:03:24 -05:00
RUN sed -i 's#"folderpath": "DMS_Attachments/Active"#"folderpath": "/app/DMS_Attachments/Active"#' appsettings.json && \
sed -i 's#"Deletepath": "DMS_Attachments/Deleted"#"Deletepath": "/app/DMS_Attachments/Deleted"#' appsettings.json
2023-08-29 21:23:40 -05:00
## Set up the volume and copy the XML comments
#VOLUME /xmlcomments
#COPY ["DamageAssesment.Api.Attachments/bin/Release/net6.0/DamageAssesment.Api.Attachments.xml", "/xmlcomments/"]
#
# Specify the entry point for the container
ENTRYPOINT [ "dotnet" , "DamageAssesment.Api.Attachments.dll" ]