Skip to content

Instantly share code, notes, and snippets.

@rebelweb
Created February 10, 2020 03:06
Show Gist options
  • Save rebelweb/ecb567d793ed36f6012a6288ddca8d61 to your computer and use it in GitHub Desktop.
Save rebelweb/ecb567d793ed36f6012a6288ddca8d61 to your computer and use it in GitHub Desktop.
Dot Net Core API Docker Setup
$version=git describe --abbrev=0
$repo=""
$versionTag = "$($repo):$($version)"
$(aws ecr get-login --no-include-email --region us-west-2) | Invoke-Expression
docker build -t $versionTag -f API.Dockerfile .
docker push $versionTag
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
# Set working directory
WORKDIR /app
# Copy source code
COPY . ./
# Restore packages
RUN cd src && dotnet restore
# build the app
RUN cd /app/src/DayHiker.API && dotnet publish -c Release -o /app/out
# build Runtime Image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .
RUN sed -i "s|DEFAULT@SECLEVEL=2|DEFAULT@SECLEVEL=1|g" /etc/ssl/openssl.cnf
ENTRYPOINT ["dotnet", "DayHiker.API.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment