Skip to content

Commit

Permalink
MIgrated to .net 7 sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Gio authored and Gio committed Nov 15, 2024
1 parent 4e8e91e commit d65b9b2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
# Use the .NET 7.0 runtime as the base image
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 5000

ENV ASPNETCORE_URLS=http://+:5000

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser

# build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
# Build stage using .NET 7.0 SDK
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
COPY ["src/Play.Catalog.Contracts/Play.Catalog.Contracts.csproj", "src/Play.Catalog.Contracts/"]
COPY ["src/Play.Catalog.Service/Play.Catalog.Service.csproj", "src/Play.Catalog.Service/"]

RUN --mount=type=secret,id=GH_OWNER,dst=/GH_OWNER --mount=type=secret,id=GH_PAT,dst=/GH_PAT \
# Configure GitHub Package Registry secrets for NuGet
RUN --mount=type=secret,id=GH_OWNER,dst=/GH_OWNER --mount=type=secret,id=GH_PAT,dst=/GH_PAT \
dotnet nuget add source --username USERNAME --password `cat /GH_PAT` --store-password-in-clear-text --name github "https://nuget.pkg.github.com/`cat /GH_OWNER`/index.json"

# Restore dependencies
RUN dotnet restore "src/Play.Catalog.Service/Play.Catalog.Service.csproj"

# Copy the source code
COPY ./src ./src
WORKDIR "/src/Play.Catalog.Service"

# Publish the application
RUN dotnet publish "Play.Catalog.Service.csproj" -c Release --no-restore -o /app/publish /p:UseAppHost=false

# Final stage using .NET 7.0 runtime
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
Expand Down

0 comments on commit d65b9b2

Please sign in to comment.