Skip to content

Commit

Permalink
Add Docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
kgrzybek committed Nov 26, 2020
1 parent 4f1cf11 commit c45909b
Show file tree
Hide file tree
Showing 57 changed files with 631 additions and 11 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,18 @@ This will fetch an access token for this user to make authorized API requests us

If you use a tool such as Postman to test your API, the token can be fetched and stored within the tool itself and appended to all API calls. Check your tool documentation for instructions.

### Run using Docker Compose

You can run whole application using [docker compose](https://docs.docker.com/compose/) from root folder:
```shell
docker-compose up
```

It will create following services: <br/>
- MS SQL Server Database
- Database Migrator
- Application

## 6. Contribution

This project is still under analysis and development. I assume its maintenance for a long time and I would appreciate your contribution to it. Please let me know by creating an Issue or Pull Request.
Expand All @@ -1839,6 +1851,7 @@ List of features/tasks/approaches to add:
| Continuous Integration | Completed | 2020-09-01 |
| StyleCop Static Code Analysis | Completed | 2020-09-05 |
| FrontEnd SPA application | Completed | 2020-11-08 |
| Docker support | Completed | 2020-11-26 |
| Meeting comments feature | | |
| Notifications feature | | |
| Messages feature | | |
Expand Down
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3.4'

services:

backend:
container_name: mymeetings_backend
build:
context: ./src/
ports:
- "5000:80"
networks:
- starfish-crm-network
environment:
- Meetings_MeetingsConnectionString=Server=mymeetingsdb,1433;Database=MyMeetings;User=sa;Password=Test@12345
depends_on:
- migrator
restart: on-failure

mymeetingsdb:
build: ./src/Database/
ports:
- 1445:1433
networks:
- starfish-crm-network

migrator:
container_name: mymeetings_db_migrator
build:
context: ./src/Database/
dockerfile: Dockerfile_DatabaseMigrator
networks:
- starfish-crm-network
environment:
- ASPNETCORE_MyMeetings_IntegrationTests_ConnectionString=Server=mymeetingsdb,1433;Database=MyMeetings;User=sa;Password=Test@12345
command: ["./wait-for-it.sh", "mymeetingsdb:1433", "--timeout=60", "--", "/bin/bash", "/entrypoint_DatabaseMigrator.sh"]
restart: on-failure


networks:
starfish-crm-network:
25 changes: 25 additions & 0 deletions src/.dockerignore
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,26 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>2b9855d3-f073-44d2-aa45-b15e896794b9</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
<Configurations>Debug;Release;Production</Configurations>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp2.2\CompanyName.MyMeetings.API\CompanyName.MyMeetings.API.xml</DocumentationFile>
<DocumentationFile>bin\Debug\netcoreapp3.1\CompanyName.MyMeetings.API\CompanyName.MyMeetings.API.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Production|AnyCPU'">
<DocumentationFile>bin\Production\netcoreapp3.1\CompanyName.MyMeetings.API\CompanyName.MyMeetings.API.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp3.1\CompanyName.MyMeetings.API.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<Compile Remove="logs\**" />
<Content Remove="logs\**" />
Expand All @@ -27,6 +40,7 @@
<PackageReference Include="FluentValidation" Version="8.6.2" />
<PackageReference Include="Hellang.Middleware.ProblemDetails" Version="4.2.0" />
<PackageReference Include="IdentityServer4" Version="3.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
Expand All @@ -49,6 +63,9 @@
</ItemGroup>

<ItemGroup>
<Content Update="appsettings.Production.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
24 changes: 16 additions & 8 deletions src/API/CompanyName.MyMeetings.API/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:57869",
"sslPort": 44368
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
Expand All @@ -21,10 +21,18 @@
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"Meetings_MeetingsConnectionString": "aaa"
},
"applicationUrl": "http://localhost:5000"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values",
"publishAllPorts": true,
"useSSL": true
}
}
}
3 changes: 3 additions & 0 deletions src/API/CompanyName.MyMeetings.API/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ public Startup(IWebHostEnvironment env)
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env.EnvironmentName}.json")
.AddUserSecrets<Startup>()
.AddEnvironmentVariables("Meetings_")
.Build();

_loggerForApi.Information("Connection string:" + _configuration[MeetingsConnectionString]);

AuthorizationChecker.CheckAllEndpoints();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
4 changes: 4 additions & 0 deletions src/API/CompanyName.MyMeetings.API/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
sleep 30 ;

dotnet CompanyName.MyMeetings.API.dll
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;Production</Configurations>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;Production</Configurations>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;Production</Configurations>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;Production</Configurations>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>

<Configurations>Debug;Release;Production</Configurations>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;Production</Configurations>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit c45909b

Please sign in to comment.