Première tentative de dockerisation, docker compose ne fonctionne pas mais le conteneur de l'api se lance de manière correctement indépendante

pull/9/head
Clement FERRERE 3 years ago
parent 7c71bba88c
commit 1b65998d19
  1. 25
      Collaborateur_Epa_Back/.dockerignore
  2. 6
      Collaborateur_Epa_Back/.env
  3. 20
      Collaborateur_Epa_Back/docker-compose.dcproj
  4. 14
      Collaborateur_Epa_Back/docker-compose.override.yml
  5. 38
      Collaborateur_Epa_Back/docker-compose.yml
  6. 29
      Collaborateur_Epa_Back/espacecollab.backend.api/Dockerfile
  7. 17
      Collaborateur_Epa_Back/espacecollab.backend.api/Properties/launchSettings.json
  8. 2
      Collaborateur_Epa_Back/espacecollab.backend.api/appsettings.json
  9. 4
      Collaborateur_Epa_Back/espacecollab.backend.api/espacecollab.backend.api.csproj
  10. 8
      Collaborateur_Epa_Back/espacecollab.backend.sln

@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

@ -0,0 +1,6 @@
DATABASE_HOSTNAME=localhost
DATABASE_PORT=3306
DATABASE_NAME=collaborateur_epa
APP_DB_USERNAME=root
APP_DB_PASSWORD=root
APP_DB_ROOT_PASSWORD=root

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>815b6abd-7550-4d79-a53b-e84f4d4a7475</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
<DockerServiceName>espacecollab.backend.api</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="certificat-apsdigit-ca.pem" />
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
<None Include=".env" />
</ItemGroup>
</Project>

@ -0,0 +1,14 @@
version: '3.4'
services:
espacecollab.backend.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
- ASPNETCORE_Kestrel__Certificates__Default__Password=password
- ASPNETCORE_Kestrel__Certificates__Default__Path=${APPDATA}/ASP.NET/Https/espacecollab.pfx
ports:
- "8001:80"
- "8000:443"
volumes:
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro

@ -0,0 +1,38 @@
version: '3.4'
volumes:
data-volume: {}
services:
maria_db:
image: "mariadb:10.7.1"
restart: always
ports:
- 3304:3306
environment:
- MYSQL_DATABASE=${DATABASE_NAME}
- MYSQL_USERNAME=${APP_DB_USERNAME}
- MYSQL_PASSWORD=${APP_DB_PASSWORD}
- MYSQL_ROOT_PASSWORD=${APP_DB_ROOT_PASSWORD}
volumes:
- data-volume:/var/lib/mysql
espacecollab.backend.api:
image: ${DOCKER_REGISTRY-}espacecollabbackendapi
build:
context: .
dockerfile: espacecollab.backend.api/Dockerfile
ports:
- "5000:80"
- "5001:443"
links:
- maria_db
environment:
- DATABASE_HOSTNAME=maria_db
- DATABASE_PORT=3306
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_USERNAME=${APP_DB_USERNAME}
- DATABASE_PASSWORD=${APP_DB_PASSWORD}

@ -0,0 +1,29 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["espacecollab.backend.api/espacecollab.backend.api.csproj", "espacecollab.backend.api/"]
COPY ["espacecollab.backend.appservices/espacecollab.backend.appservices.csproj", "espacecollab.backend.appservices/"]
COPY ["espacecollab.backend.appservices.dtos/espacecollab.backend.appservices.dtos.csproj", "espacecollab.backend.appservices.dtos/"]
COPY ["espacecollab.backend.infrastructure.sql.dtos/espacecollab.backend.infrastructure.sql.dtos.csproj", "espacecollab.backend.infrastructure.sql.dtos/"]
COPY ["espacecollab.backend.appservices.interfaces/espacecollab.backend.appservices.interfaces.csproj", "espacecollab.backend.appservices.interfaces/"]
COPY ["espacecollab.backend.infrastructure.sql/espacecollab.backend.infrastructure.sql.csproj", "espacecollab.backend.infrastructure.sql/"]
COPY ["espacecollab.backend.infrastructure.interfaces/espacecollab.backend.infrastructure.interfaces.csproj", "espacecollab.backend.infrastructure.interfaces/"]
COPY ["espacecollab.backend.infrastructure.fake/espacecollab.backend.infrastructure.fake.csproj", "espacecollab.backend.infrastructure.fake/"]
RUN dotnet restore "espacecollab.backend.api/espacecollab.backend.api.csproj"
COPY . .
WORKDIR "/src/espacecollab.backend.api"
RUN dotnet build "espacecollab.backend.api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "espacecollab.backend.api.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "espacecollab.backend.api.dll"]

@ -1,4 +1,4 @@
{ {
"$schema": "https://json.schemastore.org/launchsettings.json", "$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": { "iisSettings": {
"windowsAuthentication": false, "windowsAuthentication": false,
@ -11,13 +11,13 @@
"profiles": { "profiles": {
"espacecollab.backend.api": { "espacecollab.backend.api": {
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "swagger",
"applicationUrl": "https://localhost:7125;http://localhost:5125",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} },
"applicationUrl": "https://localhost:8081;http://localhost:8080",
"dotnetRunMessages": true
}, },
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
@ -26,6 +26,13 @@
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
} }
} }
} }

@ -7,7 +7,7 @@
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"Sql": { "Sql": {
"LoadFake": false, "LoadFake": true,
"ConnectionString": "server=localhost;user=root;password=root;database=collaborateur_epa" "ConnectionString": "server=localhost;user=root;password=root;database=collaborateur_epa"
} }
} }

@ -4,10 +4,14 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>5a7cf5e2-2bf7-4dae-aea9-2522da3cf955</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup> </ItemGroup>

@ -25,7 +25,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.infras
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.appservices.interfaces", "espacecollab.backend.appservices.interfaces\espacecollab.backend.appservices.interfaces.csproj", "{7872657E-46E2-44A1-AFA6-0D3B9E45084A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.appservices.interfaces", "espacecollab.backend.appservices.interfaces\espacecollab.backend.appservices.interfaces.csproj", "{7872657E-46E2-44A1-AFA6-0D3B9E45084A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "espacecollab.backend.api.tests", "espacecollab.backend.api.tests\espacecollab.backend.api.tests.csproj", "{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.api.tests", "espacecollab.backend.api.tests\espacecollab.backend.api.tests.csproj", "{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{815B6ABD-7550-4D79-A53B-E84F4D4A7475}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -69,6 +71,10 @@ Global
{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Release|Any CPU.ActiveCfg = Release|Any CPU {5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Release|Any CPU.Build.0 = Release|Any CPU {5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Release|Any CPU.Build.0 = Release|Any CPU
{815B6ABD-7550-4D79-A53B-E84F4D4A7475}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{815B6ABD-7550-4D79-A53B-E84F4D4A7475}.Debug|Any CPU.Build.0 = Debug|Any CPU
{815B6ABD-7550-4D79-A53B-E84F4D4A7475}.Release|Any CPU.ActiveCfg = Release|Any CPU
{815B6ABD-7550-4D79-A53B-E84F4D4A7475}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Loading…
Cancel
Save