-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,43 @@ | ||
FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build-env | ||
# Base image to build application | ||
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build | ||
WORKDIR /app | ||
|
||
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 | ||
|
||
# copy csproj and restore as distinct layers | ||
# Copy the project file and restore dependencies | ||
COPY *.csproj ./ | ||
RUN dotnet restore | ||
RUN dotnet restore -r alpine-x64 | ||
RUN dotnet tool restore && dotnet ef database update | ||
|
||
# copy everything else and build | ||
COPY . ./ | ||
RUN dotnet restore -r alpine-x64 /p:PublishReadyToRun=true | ||
RUN dotnet publish --framework net6.0 -o out -c Release -r alpine-x64 --self-contained true /p:PublishReadyToRun=true /p:PublishSingleFile=true | ||
# Copy the rest of the files and build | ||
COPY . . | ||
RUN dotnet publish -o out -c Release -r alpine-x64 \ | ||
--self-contained true /p:PublishReadyToRun=true /p:PublishSingleFile=true | ||
|
||
# build common runtime image | ||
FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS runtime | ||
# Base image to run application | ||
FROM --platform=amd64 mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS runtime | ||
WORKDIR /app | ||
COPY --from=build-env /app/out . | ||
COPY --from=build /app/out . | ||
|
||
# Expose the application port and set environment variables | ||
EXPOSE 8080 | ||
ENV ASPNETCORE_URLS=http://*:8080 | ||
|
||
# build runtime image for publish service | ||
FROM runtime AS publish-service | ||
ENV FeatureManagement__DtroWrite=True | ||
ENV FeatureManagement__SchemasRead=True | ||
ENV FeatureManagement__SchemaWrite=True | ||
|
||
ENTRYPOINT ["./DfT.DTRO"] | ||
|
||
# build runtime image for search service | ||
FROM runtime AS search-service | ||
WORKDIR /app | ||
COPY --from=build-env /app/out . | ||
|
||
ENV FeatureManagement__DtroRead=True | ||
ENV ASPNETCORE_URLS=http://*:8080 \ | ||
FeatureManagement__DtroWrite=True \ | ||
FeatureManagement__SchemasRead=True \ | ||
FeatureManagement__SchemaWrite=True \ | ||
FeatureManagement__DtroRead=True | ||
|
||
# Run the application | ||
ENTRYPOINT ["./DfT.DTRO"] | ||
|
||
# build image for Postgres migrations job | ||
FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:6.0-alpine AS postgres-migrations-job | ||
WORKDIR /app | ||
# # build image for Postgres migrations job | ||
# FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:6.0-alpine AS postgres-migrations-job | ||
# WORKDIR /app | ||
|
||
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 | ||
# ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 | ||
|
||
COPY *.csproj ./ | ||
RUN dotnet restore | ||
# COPY *.csproj ./ | ||
# RUN dotnet restore | ||
|
||
COPY . ./ | ||
# COPY . ./ | ||
|
||
ENTRYPOINT ["/bin/sh", "-c", "dotnet tool restore && dotnet ef database update"] | ||
# ENTRYPOINT ["/bin/sh", "-c", "dotnet tool restore && dotnet ef database update"] |