Skip to content

Commit

Permalink
having the new docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Popescu committed Jun 27, 2024
1 parent a2b5c8c commit 068567f
Showing 1 changed file with 27 additions and 35 deletions.
62 changes: 27 additions & 35 deletions Src/DfT.DTRO/Dockerfile
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

# 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
ENV FeatureManagement__DtroWrite=True \
FeatureManagement__SchemasRead=True \
FeatureManagement__SchemaWrite=True \
FeatureManagement__DtroRead=True
ENV ASPNETCORE_ENVIRONMENT=Development

# build runtime image for publish service
FROM runtime AS publish-service
ENV FeatureManagement__DtroWrite=True
ENV FeatureManagement__SchemasRead=True
ENV FeatureManagement__SchemaWrite=True

# Run the application
ENTRYPOINT ["./DfT.DTRO"]

# build runtime image for search service
FROM runtime AS search-service
WORKDIR /app
COPY --from=build-env /app/out .
# # 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 FeatureManagement__DtroRead=True
# ENV DOTNET_CLI_TELEMETRY_OPTOUT 1

ENTRYPOINT ["./DfT.DTRO"]
# COPY *.csproj ./
# RUN dotnet restore

# COPY . ./

# 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
#
#COPY *.csproj ./
#RUN dotnet restore
#
#COPY . ./
#
#ENTRYPOINT ["/bin/sh", "-c", "dotnet tool restore && dotnet ef database update"]
# ENTRYPOINT ["/bin/sh", "-c", "dotnet tool restore && dotnet ef database update"]

0 comments on commit 068567f

Please sign in to comment.