Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix some bugs in dockerfiles #32

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
Loading