API docker build updates

This commit is contained in:
Collin M. Barrett 2019-04-28 14:12:37 -05:00
parent 1065b9d31a
commit 8180eb9f22
4 changed files with 41 additions and 106 deletions

View file

@ -1,11 +1,11 @@
.git
.github
**/.git
**/.github
.gitattributes
.gitignore
.vs
.vscode
images
ops
**/.vs
**/.vscode
**/images
**/ops
codecov.yml
.dockerignore
docker-compose.yml
@ -13,5 +13,5 @@ docker-compose.*.yml
*.DotSettings*
FilterLists.postman_collection.json
LICENSE
*/bin
*/obj
**/bin
**/obj

View file

@ -1,78 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.202
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterLists.Api", "src\FilterLists.Api\FilterLists.Api.csproj", "{0115C4AD-63F2-4075-98F4-DF97A1A961B0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterLists.Data", "src\FilterLists.Data\FilterLists.Data.csproj", "{234B42ED-DE64-427A-9FAA-A4B4DA25BBFD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterLists.Services", "src\FilterLists.Services\FilterLists.Services.csproj", "{8FACA060-B344-46C5-8614-5CA4273D38C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterLists.Data.Tests", "tests\FilterLists.Data.Tests\FilterLists.Data.Tests.csproj", "{DB1E6B87-DF71-47B8-9235-BFCD1496EFA1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterLists.Services.Tests", "tests\FilterLists.Services.Tests\FilterLists.Services.Tests.csproj", "{2ACC8D42-9E7D-4447-BC2B-9449B8981CF0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B08FB2A1-A903-4C99-83E7-4991B49A9841}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{5D12BA97-CC9B-4195-8D9A-35012899D91C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "data", "data", "{95556DA4-5C8B-43E4-B0E7-29DCF7F81F8A}"
ProjectSection(SolutionItems) = preProject
data\Dependent.json = data\Dependent.json
data\FilterList.json = data\FilterList.json
data\FilterListLanguage.json = data\FilterListLanguage.json
data\FilterListMaintainer.json = data\FilterListMaintainer.json
data\FilterListTag.json = data\FilterListTag.json
data\Fork.json = data\Fork.json
data\Language.json = data\Language.json
data\License.json = data\License.json
data\Maintainer.json = data\Maintainer.json
data\Merge.json = data\Merge.json
data\Software.json = data\Software.json
data\SoftwareSyntax.json = data\SoftwareSyntax.json
data\Syntax.json = data\Syntax.json
data\Tag.json = data\Tag.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0115C4AD-63F2-4075-98F4-DF97A1A961B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0115C4AD-63F2-4075-98F4-DF97A1A961B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0115C4AD-63F2-4075-98F4-DF97A1A961B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0115C4AD-63F2-4075-98F4-DF97A1A961B0}.Release|Any CPU.Build.0 = Release|Any CPU
{234B42ED-DE64-427A-9FAA-A4B4DA25BBFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{234B42ED-DE64-427A-9FAA-A4B4DA25BBFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{234B42ED-DE64-427A-9FAA-A4B4DA25BBFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{234B42ED-DE64-427A-9FAA-A4B4DA25BBFD}.Release|Any CPU.Build.0 = Release|Any CPU
{8FACA060-B344-46C5-8614-5CA4273D38C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FACA060-B344-46C5-8614-5CA4273D38C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FACA060-B344-46C5-8614-5CA4273D38C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FACA060-B344-46C5-8614-5CA4273D38C4}.Release|Any CPU.Build.0 = Release|Any CPU
{DB1E6B87-DF71-47B8-9235-BFCD1496EFA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB1E6B87-DF71-47B8-9235-BFCD1496EFA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB1E6B87-DF71-47B8-9235-BFCD1496EFA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB1E6B87-DF71-47B8-9235-BFCD1496EFA1}.Release|Any CPU.Build.0 = Release|Any CPU
{2ACC8D42-9E7D-4447-BC2B-9449B8981CF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2ACC8D42-9E7D-4447-BC2B-9449B8981CF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2ACC8D42-9E7D-4447-BC2B-9449B8981CF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2ACC8D42-9E7D-4447-BC2B-9449B8981CF0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0115C4AD-63F2-4075-98F4-DF97A1A961B0} = {B08FB2A1-A903-4C99-83E7-4991B49A9841}
{234B42ED-DE64-427A-9FAA-A4B4DA25BBFD} = {B08FB2A1-A903-4C99-83E7-4991B49A9841}
{8FACA060-B344-46C5-8614-5CA4273D38C4} = {B08FB2A1-A903-4C99-83E7-4991B49A9841}
{DB1E6B87-DF71-47B8-9235-BFCD1496EFA1} = {5D12BA97-CC9B-4195-8D9A-35012899D91C}
{2ACC8D42-9E7D-4447-BC2B-9449B8981CF0} = {5D12BA97-CC9B-4195-8D9A-35012899D91C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2A61003B-647A-4A20-A9D0-BE5AF9077426}
EndGlobalSection
EndGlobal

View file

@ -4,32 +4,44 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine AS build
# restore
COPY ./FilterLists.Api.sln ./
COPY src/*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p src/${file%.*}/ && mv $file src/${file%.*}/; done
COPY tests/*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p tests/${file%.*}/ && mv $file tests/${file%.*}/; done
WORKDIR /src/
COPY src/FilterLists.Data/FilterLists.Data.csproj ./FilterLists.Data/
COPY src/FilterLists.Services/FilterLists.Services.csproj ./FilterLists.Services/
COPY src/FilterLists.Api/FilterLists.Api.csproj ./FilterLists.Api/
WORKDIR /src/FilterLists.Api/
RUN dotnet restore
# build
# publish
WORKDIR /src/
COPY src/FilterLists.Data/. ./FilterLists.Data/
COPY src/FilterLists.Services/. ./FilterLists.Services/
COPY src/FilterLists.Api/. ./FilterLists.Api/
COPY tests/FilterLists.Data.Tests/. ./tests/FilterLists.Data.Tests/
COPY tests/FilterLists.Services.Tests/. ./tests/FilterLists.Services.Tests/
RUN dotnet build -c Release --no-restore
WORKDIR /src/FilterLists.Api/
RUN dotnet publish -c Release -o out --no-restore
# test
RUN dotnet test "./tests/FilterLists.Data.Tests/FilterLists.Data.Tests.csproj" -c Release --no-build --no-restore
RUN dotnet test "./tests/FilterLists.Services.Tests/FilterLists.Services.Tests.csproj" -c Release --no-build --no-restore
# restore data tests
# FROM build AS test-data
# COPY tests/FilterLists.Data.Tests/FilterLists.Data.Tests.csproj ./tests/FilterLists.Data.Tests/
# RUN dotnet restore tests/FilterLists.Data.Tests/FilterLists.Data.Tests.csproj
# publish
RUN dotnet publish FilterLists.Api/FilterLists.Api.csproj -c Release -o out --no-build --no-restore
# build data tests
# COPY tests/FilterLists.Data.Tests/. ./tests/FilterLists.Data.Tests/
# RUN dotnet build tests/FilterLists.Data.Tests/FilterLists.Data.Tests.csproj -c Release --no-restore
# ENTRYPOINT ["dotnet", "test", "./tests/FilterLists.Data.Tests/FilterLists.Data.Tests.csproj"]
# restore services tests
# FROM build AS test-services
# COPY tests/FilterLists.Services.Tests/FilterLists.Services.Tests.csproj ./tests/FilterLists.Services.Tests/
# RUN dotnet restore tests/FilterLists.Services.Tests/FilterLists.Services.Tests.csproj
# build services tests
# COPY tests/FilterLists.Services.Tests/. ./tests/FilterLists.Services.Tests/
# RUN dotnet build tests/FilterLists.Services.Tests/FilterLists.Services.Tests.csproj -c Release --no-restore
# ENTRYPOINT ["dotnet", "test", "./tests/FilterLists.Services.Tests/FilterLists.Services.Tests.csproj"]
# run
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine
ENV DataDirectory:Path="data"
ENV ASPNETCORE_URLS http://+:5000
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine as runtime
EXPOSE 5000
ENTRYPOINT ["dotnet", "FilterLists.Api.dll"]
COPY --from=build /FilterLists.Api/out ./
COPY --from=build /src/FilterLists.Api/out ./
COPY data/. ./data/

View file

@ -18,8 +18,9 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/collinbarrett/FilterLists</RepositoryUrl>
<ServerGarbageCollection>false</ServerGarbageCollection>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\..\docker-compose.dcproj</DockerComposeProjectPath>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">