Skip to content
Open
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
94 changes: 47 additions & 47 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
# syntax=docker/dockerfile:1

# ----- build -----
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /source

# restore first so the layer is cached until a project file changes
COPY src/Taskist.sln ./
COPY src/Libraries/Taskist.Core/Taskist.Core.csproj Libraries/Taskist.Core/
COPY src/Libraries/Taskist.Data/Taskist.Data.csproj Libraries/Taskist.Data/
COPY src/Libraries/Taskist.Service/Taskist.Service.csproj Libraries/Taskist.Service/
COPY src/Presentation/Taskist.Web/Taskist.Web.csproj Presentation/Taskist.Web/

# restore the web project, not the solution: the solution also lists the test project, which is not copied here
RUN dotnet restore Presentation/Taskist.Web/Taskist.Web.csproj

COPY src/ ./

RUN dotnet publish Presentation/Taskist.Web/Taskist.Web.csproj \
-c Release \
-o /app \
--no-restore

# ----- runtime -----
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app

# curl backs the container health check
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /app ./

# data protection keys must outlive the container (attachments live in the database)
RUN mkdir -p /app/App_Data/DataProtectionKeys \
&& chown -R $APP_UID:$APP_UID /app/App_Data

# run as the non-root user provided by the base image
USER $APP_UID

ENV ASPNETCORE_ENVIRONMENT=Production \
ASPNETCORE_HTTP_PORTS=8080

EXPOSE 8080

ENTRYPOINT ["dotnet", "Taskist.Web.dll"]
# syntax=docker/dockerfile:1
# ----- build -----
FROM mcr.microsoft.com/dotnet/sdk:11.0 AS build
WORKDIR /source
# restore first so the layer is cached until a project file changes
COPY src/Taskist.sln ./
COPY src/Libraries/Taskist.Core/Taskist.Core.csproj Libraries/Taskist.Core/
COPY src/Libraries/Taskist.Data/Taskist.Data.csproj Libraries/Taskist.Data/
COPY src/Libraries/Taskist.Service/Taskist.Service.csproj Libraries/Taskist.Service/
COPY src/Presentation/Taskist.Web/Taskist.Web.csproj Presentation/Taskist.Web/
# restore the web project, not the solution: the solution also lists the test project, which is not copied here
RUN dotnet restore Presentation/Taskist.Web/Taskist.Web.csproj
COPY src/ ./
RUN dotnet publish Presentation/Taskist.Web/Taskist.Web.csproj \
-c Release \
-o /app \
--no-restore
# ----- runtime -----
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
# curl backs the container health check
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /app ./
# data protection keys must outlive the container (attachments live in the database)
RUN mkdir -p /app/App_Data/DataProtectionKeys \
&& chown -R $APP_UID:$APP_UID /app/App_Data
# run as the non-root user provided by the base image
USER $APP_UID
ENV ASPNETCORE_ENVIRONMENT=Production \
ASPNETCORE_HTTP_PORTS=8080
EXPOSE 8080
ENTRYPOINT ["dotnet", "Taskist.Web.dll"]
114 changes: 57 additions & 57 deletions Dockerfile.migrate
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
# syntax=docker/dockerfile:1

# Applies EF Core migrations and the seed scripts, then exits.
# Run as an init step before the application container starts.

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /source

RUN dotnet tool install --global dotnet-ef --version 10.*

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

COPY src/Taskist.sln ./
COPY src/Libraries/Taskist.Core/Taskist.Core.csproj Libraries/Taskist.Core/
COPY src/Libraries/Taskist.Data/Taskist.Data.csproj Libraries/Taskist.Data/
COPY src/Libraries/Taskist.Service/Taskist.Service.csproj Libraries/Taskist.Service/
COPY src/Presentation/Taskist.Web/Taskist.Web.csproj Presentation/Taskist.Web/

# the bundle is published self-contained, so restore must target that runtime.
# restore the startup project, not the solution: the solution also lists the test project, which is not copied here
RUN dotnet restore Libraries/Taskist.Data/Taskist.Data.csproj -r linux-x64

COPY src/ ./

# a self-contained bundle avoids needing the SDK at run time; the connection is passed by the entrypoint.
# Taskist.Data is its own startup project (design-time factory; the web project has no EF Design reference).
RUN dotnet ef migrations bundle \
--project Libraries/Taskist.Data/Taskist.Data.csproj \
--startup-project Libraries/Taskist.Data/Taskist.Data.csproj \
--configuration Release \
--self-contained \
--runtime linux-x64 \
--output /migrate/efbundle

# ----- runtime -----
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0 AS runtime
WORKDIR /migrate

# mssql-tools18 provides sqlcmd for the seed scripts; the repository follows the base image's distro
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl gnupg ca-certificates \
&& . /etc/os-release \
&& curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/${ID}/${VERSION_ID}/prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install -y --no-install-recommends mssql-tools18 unixodbc \
&& rm -rf /var/lib/apt/lists/*

ENV PATH="${PATH}:/opt/mssql-tools18/bin"

COPY --from=build /migrate/efbundle ./efbundle
COPY sql-scripts/ ./seed/
COPY docker/migrate-entrypoint.sh ./migrate-entrypoint.sh

RUN chmod +x ./efbundle ./migrate-entrypoint.sh

ENTRYPOINT ["./migrate-entrypoint.sh"]
# syntax=docker/dockerfile:1
# Applies EF Core migrations and the seed scripts, then exits.
# Run as an init step before the application container starts.
FROM mcr.microsoft.com/dotnet/sdk:11.0 AS build
WORKDIR /source
RUN dotnet tool install --global dotnet-ef --version 10.*
ENV PATH="${PATH}:/root/.dotnet/tools"
COPY src/Taskist.sln ./
COPY src/Libraries/Taskist.Core/Taskist.Core.csproj Libraries/Taskist.Core/
COPY src/Libraries/Taskist.Data/Taskist.Data.csproj Libraries/Taskist.Data/
COPY src/Libraries/Taskist.Service/Taskist.Service.csproj Libraries/Taskist.Service/
COPY src/Presentation/Taskist.Web/Taskist.Web.csproj Presentation/Taskist.Web/
# the bundle is published self-contained, so restore must target that runtime.
# restore the startup project, not the solution: the solution also lists the test project, which is not copied here
RUN dotnet restore Libraries/Taskist.Data/Taskist.Data.csproj -r linux-x64
COPY src/ ./
# a self-contained bundle avoids needing the SDK at run time; the connection is passed by the entrypoint.
# Taskist.Data is its own startup project (design-time factory; the web project has no EF Design reference).
RUN dotnet ef migrations bundle \
--project Libraries/Taskist.Data/Taskist.Data.csproj \
--startup-project Libraries/Taskist.Data/Taskist.Data.csproj \
--configuration Release \
--self-contained \
--runtime linux-x64 \
--output /migrate/efbundle
# ----- runtime -----
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0 AS runtime
WORKDIR /migrate
# mssql-tools18 provides sqlcmd for the seed scripts; the repository follows the base image's distro
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl gnupg ca-certificates \
&& . /etc/os-release \
&& curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/${ID}/${VERSION_ID}/prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install -y --no-install-recommends mssql-tools18 unixodbc \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="${PATH}:/opt/mssql-tools18/bin"
COPY --from=build /migrate/efbundle ./efbundle
COPY sql-scripts/ ./seed/
COPY docker/migrate-entrypoint.sh ./migrate-entrypoint.sh
RUN chmod +x ./efbundle ./migrate-entrypoint.sh
ENTRYPOINT ["./migrate-entrypoint.sh"]
Loading