File is not found in docker

This is my Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:8.0 as build
WORKDIR /app
EXPOSE 80

COPY TotechsThunder.sln TotechsThunder.sln
COPY mock/programminglanguages/programminglanguage.js mock/programminglanguages/programminglanguage.js
COPY src/LightningLanes/API/LightningLanes.csproj src/LightningLanes/API/LightningLanes.csproj
COPY src/LightningLanes/Core/LightningLanes.Core/LightningLanes.Core.csproj src/LightningLanes/Core/LightningLanes.Core/LightningLanes.Core.csproj
COPY src/LightningLanes/Jobs/LightningLanes.HangfireJobHost/LightningLanes.HangfireJobHost.csproj src/LightningLanes/Jobs/LightningLanes.HangfireJobHost/LightningLanes.HangfireJobHost.csproj
COPY src/Features/GitHubFeatures/Logics/Logics.csproj src/Features/GitHubFeatures/Logics/Logics.csproj
COPY src/Features/GitHubFeatures/Tests/Tests.csproj src/Features/GitHubFeatures/Tests/Tests.csproj
COPY src/Technologies/Technologies.csproj src/Technologies/Technologies.csproj
COPY src/Projects/Projects.csproj src/Projects/Projects.csproj
COPY src/Contracts/Contracts.csproj src/Contracts/Contracts.csproj
COPY src/IdentityServer/IdentityServer.csproj src/IdentityServer/IdentityServer.csproj
COPY src/Gateway/Gateway.csproj src/Gateway/Gateway.csproj

RUN dotnet restore TotechsThunder.sln

COPY src/Technologies src/Technologies
COPY src/Contracts src/Contracts
WORKDIR /app/src/Technologies
RUN dotnet publish -c Release -o /app/src/out

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/src/out .
ENTRYPOINT [ "dotnet", "Technologies.dll" ]

I’m having trouble with the programminglanguage.js file. This file contains master data, which my ASP.NET Core app uses during initialization to seed data into the database migration. Everything works fine in my development environment, but when I run the project in a Docker environment, the file can’t be found.

When I run docker compose build, the service builds successfully. However, when the project runs in Docker, I encounter the following error:

2024-09-21 04:40:15 Unhandled exception. System.IO.FileNotFoundException: Could not find file '/app/..........mockprogramminglanguagesprogramminglanguage.js'

Here’s the code I’m using to read the file for seeding during migration:

string baseDir = AppDomain.CurrentDomain.BaseDirectory;
string relativePath = @"..........mockprogramminglanguagesprogramminglanguage.js";
string fullPath = Path.GetFullPath(Path.Combine(baseDir, relativePath));

In Docker, the issue seems to stem from the relative file path not being resolved correctly. I’d appreciate any help in resolving this so the app can find the file in the Docker environment.

Files location in my project

What I did try:

Trying to check inside the docker container if there’s a programminglanguage.js file in there, but the release + docker environment file system is just too unfamiliar for me to do an investigation

What I’m expecting:

programminglanguage.js is copied inside the container and the path

string relativePath = @"..........mockprogramminglanguagesprogramminglanguage.js";

that retrieve the file should not result no file

The problem may reside in using backslashes instead of normal ones, since Docker is running Linux-based images, Windows file paths will not be recognized well

Posting as an answer because comments require more reputation(???)

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật