Skip to content

Commit

Permalink
Merge pull request #32 from Star-Academy/refactor/dockerfiles
Browse files Browse the repository at this point in the history
fix: fix some bugs in dockerfiles
  • Loading branch information
msm1984 authored Sep 5, 2024
2 parents 58f3925 + bcad7e2 commit 346be34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
12 changes: 5 additions & 7 deletions backend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
# Use the official .NET SDK image to build the app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app

# Copy everything and restore as distinct layers

COPY . ./
RUN dotnet restore

# Build and publish the app to the out directory

RUN dotnet publish src/Web/Web.csproj -c Release -o out

# Use the official ASP.NET image to serve the app

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/out ./

# Environment variables for the database connection

ENV ASPNETCORE_ENVIRONMENT=Development
ENV ConnectionStrings__DefaultConnection=Host=db;Database=YourDatabaseName;Username=yourusername;Password=yourpassword
ENV ASPNETCORE_URLS=http://*:80
EXPOSE 80


# Start the application

ENTRYPOINT ["dotnet", "Web.dll"]


Expand Down
8 changes: 3 additions & 5 deletions migrate.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# Use the .NET SDK image as the base image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

# Set the working directory inside the container

WORKDIR /app

RUN dotnet tool install --global dotnet-ef

# Ensure the global tools are in the PATH

ENV PATH="$PATH:/root/.dotnet/tools"

# Copy the project files into the container

COPY . .


# Run the EF database update command directly
CMD ["dotnet", "ef", "database", "update", "--project", "src/Infrastructure/Infrastructure.csproj", "--startup-project", "src/Web/Web.csproj"]

0 comments on commit 346be34

Please sign in to comment.