Skip to content

Instantly share code, notes, and snippets.

@sebug
Created January 5, 2018 18:46
Show Gist options
  • Save sebug/1c365276f3844154e08c4c440d25ac0c to your computer and use it in GitHub Desktop.
Save sebug/1c365276f3844154e08c4c440d25ac0c to your computer and use it in GitHub Desktop.
Pass connection string via docker -e to Entity Framework Core
FROM microsoft/aspnetcore-build:2.0.4-2.1.3-nanoserver-sac2016 AS build-env
WORKDIR /app
COPY *.sln ./
RUN mkdir Sample
COPY Sample/*.csproj ./Sample/
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/aspnetcore:2.0.4
WORKDIR /app
COPY --from=build-env /app/Sample/out .
ENTRYPOINT setx SAMPLE_ConnectionString $env:SAMPLE_ConnectionString ; dotnet Sample.dll
@sebug
Copy link
Author

sebug commented Jan 5, 2018

setx SAMPLE_ConnectionString "Data Source=tcp:1.2.3.4\Sample;Initial Catalog=Sample_Testing;User ID=srvc-sample;Password=..."

docker run -d -p 1492:80 -e SAMPLE_ConnectionString sample:1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment