Skip to content
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
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# directories
**/bin/
**/obj/
**/out/

# files
Dockerfile*
**/*.md
appsettings.*.json
**/appsettings.*.json
72 changes: 40 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
#
#multi-stage target: dev
#
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS dev

ENV ASPNETCORE_URLS=http://*:5000
ENV ASPNETCORE_ENVIRONMENT=DEVELOPMENT

COPY . /app
WORKDIR /app/src/Caster.Api
RUN dotnet publish -c Release -o /app/dist
CMD [ "dotnet", "run" ]

#
#multi-stage target: prod
#
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS prod
ARG commit
ENV COMMIT=$commit
ENV DOTNET_HOSTBUILDER__RELOADCONFIGCHANGE=false
COPY --from=dev /app/dist /app

WORKDIR /app
ENV ASPNETCORE_URLS=http://*:80
EXPOSE 80

CMD [ "dotnet", "Caster.Api.dll" ]

#Install git and set credential store
RUN apt-get update && \
apt-get install -y git jq curl && \
git config --global credential.helper store
# Adapted from https://github.com/dotnet/dotnet-docker/blob/main/samples/aspnetapp/Dockerfile.chiseled

# Build stage
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETARCH
WORKDIR /source

# Copy project files and restore as distinct layers
COPY --link src/Caster.Api/*.csproj ./src/Caster.Api/
WORKDIR /source/src/Caster.Api
RUN dotnet restore -a $TARGETARCH

# Copy source code and publish app
WORKDIR /source
COPY --link . .
WORKDIR /source/src/Caster.Api
RUN dotnet publish -a $TARGETARCH --no-restore -o /app

# Production Stage
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS prod
ARG commit
ENV COMMIT=$commit
ENV DOTNET_HOSTBUILDER__RELOADCONFIGCHANGE=false

# This can be removed after switching to IHost builder
ENV ASPNETCORE_URLS=http://*:8080

EXPOSE 8080
WORKDIR /app
COPY --link --from=build /app .

# Install git and set credential store
RUN apt-get update && \
apt-get install -y git jq curl unzip wget && \
git config --global credential.helper store

USER $APP_UID
ENTRYPOINT ["./Caster.Api"]


Loading