├── .dockerignore
├── .gitattributes
├── .gitignore
├── .idea
└── .idea.Docker-compose-dotnet-core-and-mysql
│ ├── .idea
│ ├── indexLayout.xml
│ ├── markdown-navigator.xml
│ ├── markdown-navigator
│ │ └── profiles_settings.xml
│ ├── modules.xml
│ └── vcs.xml
│ └── riderModule.iml
├── Aspnetcoreapp
├── Aspnetcoreapp.csproj
├── Controllers
│ └── ProductsController.cs
├── Dockerfile
├── Program.cs
├── Properties
│ └── launchSettings.json
├── Startup.cs
├── appsettings.Development.json
└── appsettings.json
├── Db
├── Dockerfile
└── prepare.sql
├── Docker-compose-dotnet-core-and-mysql.sln
├── LICENSE
├── ProductLibrary
├── Product.cs
├── ProductLibrary.csproj
└── ProductsProvider.cs
├── README.md
└── docker-compose.yml
/.dockerignore:
--------------------------------------------------------------------------------
1 | .dockerignore
2 | .env
3 | .git
4 | .gitignore
5 | .vs
6 | .vscode
7 | */bin
8 | */obj
9 | **/.toolstarget
10 | .idea
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # taken from https://github.com/aspnet/SignalR-samples/blob/master/.gitattributes
2 |
3 | # Auto detect text files and perform LF normalization
4 | * text=auto
5 |
6 | *.doc diff=astextplain
7 | *.DOC diff=astextplain
8 | *.docx diff=astextplain
9 | *.DOCX diff=astextplain
10 | *.dot diff=astextplain
11 | *.DOT diff=astextplain
12 | *.pdf diff=astextplain
13 | *.PDF diff=astextplain
14 | *.rtf diff=astextplain
15 | *.RTF diff=astextplain
16 |
17 | *.jpg binary
18 | *.png binary
19 | *.gif binary
20 |
21 | *.cs text=auto diff=csharp
22 | *.vb text=auto
23 | *.resx text=auto
24 | *.c text=auto
25 | *.cpp text=auto
26 | *.cxx text=auto
27 | *.h text=auto
28 | *.hxx text=auto
29 | *.py text=auto
30 | *.rb text=auto
31 | *.java text=auto
32 | *.html text=auto
33 | *.htm text=auto
34 | *.css text=auto
35 | *.scss text=auto
36 | *.sass text=auto
37 | *.less text=auto
38 | *.js text=auto
39 | *.lisp text=auto
40 | *.clj text=auto
41 | *.sql text=auto
42 | *.php text=auto
43 | *.lua text=auto
44 | *.m text=auto
45 | *.asm text=auto
46 | *.erl text=auto
47 | *.fs text=auto
48 | *.fsx text=auto
49 | *.hs text=auto
50 |
51 | *.csproj text=auto
52 | *.vbproj text=auto
53 | *.fsproj text=auto
54 | *.dbproj text=auto
55 | *.sln text=auto eol=crlf
56 |
57 | *.sh eol=lf
58 |
59 | #####
60 | # End of core list, below put you custom 'per project' settings
61 | #####
62 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/rider,visualstudio,visualstudiocode
3 | # Edit at https://www.gitignore.io/?templates=rider,visualstudio,visualstudiocode
4 |
5 | ### Rider ###
6 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
7 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
8 |
9 | # User-specific stuff
10 | .idea/**/workspace.xml
11 | .idea/**/tasks.xml
12 | .idea/**/usage.statistics.xml
13 | .idea/**/dictionaries
14 | .idea/**/shelf
15 |
16 | # Generated files
17 | .idea/**/contentModel.xml
18 |
19 | # Sensitive or high-churn files
20 | .idea/**/dataSources/
21 | .idea/**/dataSources.ids
22 | .idea/**/dataSources.local.xml
23 | .idea/**/sqlDataSources.xml
24 | .idea/**/dynamic.xml
25 | .idea/**/uiDesigner.xml
26 | .idea/**/dbnavigator.xml
27 |
28 | # Gradle
29 | .idea/**/gradle.xml
30 | .idea/**/libraries
31 |
32 | # Gradle and Maven with auto-import
33 | # When using Gradle or Maven with auto-import, you should exclude module files,
34 | # since they will be recreated, and may cause churn. Uncomment if using
35 | # auto-import.
36 | # .idea/modules.xml
37 | # .idea/*.iml
38 | # .idea/modules
39 |
40 | # CMake
41 | cmake-build-*/
42 |
43 | # Mongo Explorer plugin
44 | .idea/**/mongoSettings.xml
45 |
46 | # File-based project format
47 | *.iws
48 |
49 | # IntelliJ
50 | out/
51 |
52 | # mpeltonen/sbt-idea plugin
53 | .idea_modules/
54 |
55 | # JIRA plugin
56 | atlassian-ide-plugin.xml
57 |
58 | # Cursive Clojure plugin
59 | .idea/replstate.xml
60 |
61 | # Crashlytics plugin (for Android Studio and IntelliJ)
62 | com_crashlytics_export_strings.xml
63 | crashlytics.properties
64 | crashlytics-build.properties
65 | fabric.properties
66 |
67 | # Editor-based Rest Client
68 | .idea/httpRequests
69 |
70 | # Android studio 3.1+ serialized cache file
71 | .idea/caches/build_file_checksums.ser
72 |
73 | # JetBrains templates
74 | **___jb_tmp___
75 |
76 | ### VisualStudioCode ###
77 | .vscode/*
78 | !.vscode/settings.json
79 | !.vscode/tasks.json
80 | !.vscode/launch.json
81 | !.vscode/extensions.json
82 |
83 | ### VisualStudioCode Patch ###
84 | # Ignore all local history of files
85 | .history
86 |
87 | ### VisualStudio ###
88 | ## Ignore Visual Studio temporary files, build results, and
89 | ## files generated by popular Visual Studio add-ons.
90 | ##
91 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
92 |
93 | # User-specific files
94 | *.rsuser
95 | *.suo
96 | *.user
97 | *.userosscache
98 | *.sln.docstates
99 |
100 | # User-specific files (MonoDevelop/Xamarin Studio)
101 | *.userprefs
102 |
103 | # Mono auto generated files
104 | mono_crash.*
105 |
106 | # Build results
107 | [Dd]ebug/
108 | [Dd]ebugPublic/
109 | [Rr]elease/
110 | [Rr]eleases/
111 | x64/
112 | x86/
113 | [Aa][Rr][Mm]/
114 | [Aa][Rr][Mm]64/
115 | bld/
116 | [Bb]in/
117 | [Oo]bj/
118 | [Ll]og/
119 |
120 | # Visual Studio 2015/2017 cache/options directory
121 | .vs/
122 | # Uncomment if you have tasks that create the project's static files in wwwroot
123 | #wwwroot/
124 |
125 | # Visual Studio 2017 auto generated files
126 | Generated\ Files/
127 |
128 | # MSTest test Results
129 | [Tt]est[Rr]esult*/
130 | [Bb]uild[Ll]og.*
131 |
132 | # NUNIT
133 | *.VisualState.xml
134 | TestResult.xml
135 |
136 | # Build Results of an ATL Project
137 | [Dd]ebugPS/
138 | [Rr]eleasePS/
139 | dlldata.c
140 |
141 | # Benchmark Results
142 | BenchmarkDotNet.Artifacts/
143 |
144 | # .NET Core
145 | project.lock.json
146 | project.fragment.lock.json
147 | artifacts/
148 |
149 | # StyleCop
150 | StyleCopReport.xml
151 |
152 | # Files built by Visual Studio
153 | *_i.c
154 | *_p.c
155 | *_h.h
156 | *.ilk
157 | *.meta
158 | *.obj
159 | *.iobj
160 | *.pch
161 | *.pdb
162 | *.ipdb
163 | *.pgc
164 | *.pgd
165 | *.rsp
166 | *.sbr
167 | *.tlb
168 | *.tli
169 | *.tlh
170 | *.tmp
171 | *.tmp_proj
172 | *_wpftmp.csproj
173 | *.log
174 | *.vspscc
175 | *.vssscc
176 | .builds
177 | *.pidb
178 | *.svclog
179 | *.scc
180 |
181 | # Chutzpah Test files
182 | _Chutzpah*
183 |
184 | # Visual C++ cache files
185 | ipch/
186 | *.aps
187 | *.ncb
188 | *.opendb
189 | *.opensdf
190 | *.sdf
191 | *.cachefile
192 | *.VC.db
193 | *.VC.VC.opendb
194 |
195 | # Visual Studio profiler
196 | *.psess
197 | *.vsp
198 | *.vspx
199 | *.sap
200 |
201 | # Visual Studio Trace Files
202 | *.e2e
203 |
204 | # TFS 2012 Local Workspace
205 | $tf/
206 |
207 | # Guidance Automation Toolkit
208 | *.gpState
209 |
210 | # ReSharper is a .NET coding add-in
211 | _ReSharper*/
212 | *.[Rr]e[Ss]harper
213 | *.DotSettings.user
214 |
215 | # JustCode is a .NET coding add-in
216 | .JustCode
217 |
218 | # TeamCity is a build add-in
219 | _TeamCity*
220 |
221 | # DotCover is a Code Coverage Tool
222 | *.dotCover
223 |
224 | # AxoCover is a Code Coverage Tool
225 | .axoCover/*
226 | !.axoCover/settings.json
227 |
228 | # Visual Studio code coverage results
229 | *.coverage
230 | *.coveragexml
231 |
232 | # NCrunch
233 | _NCrunch_*
234 | .*crunch*.local.xml
235 | nCrunchTemp_*
236 |
237 | # MightyMoose
238 | *.mm.*
239 | AutoTest.Net/
240 |
241 | # Web workbench (sass)
242 | .sass-cache/
243 |
244 | # Installshield output folder
245 | [Ee]xpress/
246 |
247 | # DocProject is a documentation generator add-in
248 | DocProject/buildhelp/
249 | DocProject/Help/*.HxT
250 | DocProject/Help/*.HxC
251 | DocProject/Help/*.hhc
252 | DocProject/Help/*.hhk
253 | DocProject/Help/*.hhp
254 | DocProject/Help/Html2
255 | DocProject/Help/html
256 |
257 | # Click-Once directory
258 | publish/
259 |
260 | # Publish Web Output
261 | *.[Pp]ublish.xml
262 | *.azurePubxml
263 | # Note: Comment the next line if you want to checkin your web deploy settings,
264 | # but database connection strings (with potential passwords) will be unencrypted
265 | *.pubxml
266 | *.publishproj
267 |
268 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
269 | # checkin your Azure Web App publish settings, but sensitive information contained
270 | # in these scripts will be unencrypted
271 | PublishScripts/
272 |
273 | # NuGet Packages
274 | *.nupkg
275 | # The packages folder can be ignored because of Package Restore
276 | **/[Pp]ackages/*
277 | # except build/, which is used as an MSBuild target.
278 | !**/[Pp]ackages/build/
279 | # Uncomment if necessary however generally it will be regenerated when needed
280 | #!**/[Pp]ackages/repositories.config
281 | # NuGet v3's project.json files produces more ignorable files
282 | *.nuget.props
283 | *.nuget.targets
284 |
285 | # Microsoft Azure Build Output
286 | csx/
287 | *.build.csdef
288 |
289 | # Microsoft Azure Emulator
290 | ecf/
291 | rcf/
292 |
293 | # Windows Store app package directories and files
294 | AppPackages/
295 | BundleArtifacts/
296 | Package.StoreAssociation.xml
297 | _pkginfo.txt
298 | *.appx
299 | *.appxbundle
300 | *.appxupload
301 |
302 | # Visual Studio cache files
303 | # files ending in .cache can be ignored
304 | *.[Cc]ache
305 | # but keep track of directories ending in .cache
306 | !?*.[Cc]ache/
307 |
308 | # Others
309 | ClientBin/
310 | ~$*
311 | *~
312 | *.dbmdl
313 | *.dbproj.schemaview
314 | *.jfm
315 | *.pfx
316 | *.publishsettings
317 | orleans.codegen.cs
318 |
319 | # Including strong name files can present a security risk
320 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
321 | #*.snk
322 |
323 | # Since there are multiple workflows, uncomment next line to ignore bower_components
324 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
325 | #bower_components/
326 |
327 | # RIA/Silverlight projects
328 | Generated_Code/
329 |
330 | # Backup & report files from converting an old project file
331 | # to a newer Visual Studio version. Backup files are not needed,
332 | # because we have git ;-)
333 | _UpgradeReport_Files/
334 | Backup*/
335 | UpgradeLog*.XML
336 | UpgradeLog*.htm
337 | ServiceFabricBackup/
338 | *.rptproj.bak
339 |
340 | # SQL Server files
341 | *.mdf
342 | *.ldf
343 | *.ndf
344 |
345 | # Business Intelligence projects
346 | *.rdl.data
347 | *.bim.layout
348 | *.bim_*.settings
349 | *.rptproj.rsuser
350 | *- Backup*.rdl
351 |
352 | # Microsoft Fakes
353 | FakesAssemblies/
354 |
355 | # GhostDoc plugin setting file
356 | *.GhostDoc.xml
357 |
358 | # Node.js Tools for Visual Studio
359 | .ntvs_analysis.dat
360 | node_modules/
361 |
362 | # Visual Studio 6 build log
363 | *.plg
364 |
365 | # Visual Studio 6 workspace options file
366 | *.opt
367 |
368 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
369 | *.vbw
370 |
371 | # Visual Studio LightSwitch build output
372 | **/*.HTMLClient/GeneratedArtifacts
373 | **/*.DesktopClient/GeneratedArtifacts
374 | **/*.DesktopClient/ModelManifest.xml
375 | **/*.Server/GeneratedArtifacts
376 | **/*.Server/ModelManifest.xml
377 | _Pvt_Extensions
378 |
379 | # Paket dependency manager
380 | .paket/paket.exe
381 | paket-files/
382 |
383 | # FAKE - F# Make
384 | .fake/
385 |
386 | # CodeRush personal settings
387 | .cr/personal
388 |
389 | # Python Tools for Visual Studio (PTVS)
390 | __pycache__/
391 | *.pyc
392 |
393 | # Cake - Uncomment if you are using it
394 | # tools/**
395 | # !tools/packages.config
396 |
397 | # Tabs Studio
398 | *.tss
399 |
400 | # Telerik's JustMock configuration file
401 | *.jmconfig
402 |
403 | # BizTalk build output
404 | *.btp.cs
405 | *.btm.cs
406 | *.odx.cs
407 | *.xsd.cs
408 |
409 | # OpenCover UI analysis results
410 | OpenCover/
411 |
412 | # Azure Stream Analytics local run output
413 | ASALocalRun/
414 |
415 | # MSBuild Binary and Structured Log
416 | *.binlog
417 |
418 | # NVidia Nsight GPU debugger configuration file
419 | *.nvuser
420 |
421 | # MFractors (Xamarin productivity tool) working folder
422 | .mfractor/
423 |
424 | # Local History for Visual Studio
425 | .localhistory/
426 |
427 | # BeatPulse healthcheck temp database
428 | healthchecksdb
429 |
430 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
431 | MigrationBackup/
432 |
433 | # End of https://www.gitignore.io/api/rider,visualstudio,visualstudiocode
434 |
435 | # Directory for invoke measurement test
436 | **/sharedData/
437 |
--------------------------------------------------------------------------------
/.idea/.idea.Docker-compose-dotnet-core-and-mysql/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Db
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/.idea.Docker-compose-dotnet-core-and-mysql/.idea/markdown-navigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/.idea/.idea.Docker-compose-dotnet-core-and-mysql/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/.idea.Docker-compose-dotnet-core-and-mysql/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/.idea.Docker-compose-dotnet-core-and-mysql/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/.idea.Docker-compose-dotnet-core-and-mysql/riderModule.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Aspnetcoreapp/Aspnetcoreapp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.2
5 | InProcess
6 | aspnetcoreapp
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | <_ContentIncludedByDefault Remove="wwwroot\css\site.css" />
18 | <_ContentIncludedByDefault Remove="wwwroot\favicon.ico" />
19 | <_ContentIncludedByDefault Remove="wwwroot\js\site.js" />
20 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.css" />
21 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.css.map" />
22 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.min.css" />
23 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.min.css.map" />
24 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap-reboot.css" />
25 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap-reboot.css.map" />
26 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap-reboot.min.css" />
27 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap-reboot.min.css.map" />
28 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap.css" />
29 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap.css.map" />
30 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap.min.css" />
31 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\css\bootstrap.min.css.map" />
32 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\js\bootstrap.bundle.js" />
33 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\js\bootstrap.bundle.js.map" />
34 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\js\bootstrap.bundle.min.js" />
35 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\js\bootstrap.bundle.min.js.map" />
36 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\js\bootstrap.js" />
37 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\js\bootstrap.js.map" />
38 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\js\bootstrap.min.js" />
39 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\dist\js\bootstrap.min.js.map" />
40 | <_ContentIncludedByDefault Remove="wwwroot\lib\bootstrap\LICENSE" />
41 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery-validation-unobtrusive\jquery.validate.unobtrusive.js" />
42 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery-validation-unobtrusive\jquery.validate.unobtrusive.min.js" />
43 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery-validation-unobtrusive\LICENSE.txt" />
44 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery-validation\dist\additional-methods.js" />
45 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery-validation\dist\additional-methods.min.js" />
46 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery-validation\dist\jquery.validate.js" />
47 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery-validation\dist\jquery.validate.min.js" />
48 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery-validation\LICENSE.md" />
49 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery\dist\jquery.js" />
50 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery\dist\jquery.min.js" />
51 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery\dist\jquery.min.map" />
52 | <_ContentIncludedByDefault Remove="wwwroot\lib\jquery\LICENSE.txt" />
53 | <_ContentIncludedByDefault Remove="wwwroot\software-developer-blog-logo.jpg" />
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Aspnetcoreapp/Controllers/ProductsController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.AspNetCore.Mvc;
4 | using ProductLibrary;
5 |
6 | namespace aspnetcoreapp.Controllers
7 | {
8 | [Route("")]
9 | public class ProductsController : ControllerBase
10 | {
11 | private readonly ProductsProvider _provider = new ProductsProvider();
12 |
13 | [HttpGet]
14 | public ActionResult> Get()
15 | {
16 | try
17 | {
18 | return _provider.GetAll();
19 | }
20 | catch (Exception e)
21 | {
22 | Console.WriteLine("Exception during providing products, maybe DB is not fully initialized yet? " +
23 | $"Try again in a few minutes and if it doesn't help, check your docker-compose configuration.\n{e}");
24 |
25 | return new Product[0];
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/Aspnetcoreapp/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
2 | WORKDIR /app
3 |
4 | COPY . ./
5 | RUN dotnet publish Aspnetcoreapp -c Release -o out
6 |
7 | FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
8 | WORKDIR /app
9 | COPY --from=build-env /app/Aspnetcoreapp/out .
10 |
11 | ENTRYPOINT ["dotnet", "Aspnetcoreapp.dll"]
--------------------------------------------------------------------------------
/Aspnetcoreapp/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore;
2 | using Microsoft.AspNetCore.Hosting;
3 |
4 | namespace aspnetcoreapp
5 | {
6 | public static class Program
7 | {
8 | public static void Main(string[] args)
9 | {
10 | CreateWebHostBuilder(args).Build().Run();
11 | }
12 |
13 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
14 | WebHost.CreateDefaultBuilder(args)
15 | .UseStartup();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Aspnetcoreapp/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "aspnetcoreapp": {
4 | "commandName": "Project",
5 | "launchBrowser": true,
6 | "applicationUrl": "http://localhost:5000",
7 | "environmentVariables": {
8 | "ASPNETCORE_ENVIRONMENT": "Development"
9 | }
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Aspnetcoreapp/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.AspNetCore.Mvc;
4 | using Microsoft.Extensions.Configuration;
5 | using Microsoft.Extensions.DependencyInjection;
6 |
7 | namespace aspnetcoreapp
8 | {
9 | public class Startup
10 | {
11 | public Startup(IConfiguration configuration) => Configuration = configuration;
12 |
13 | public IConfiguration Configuration { get; }
14 |
15 | public void ConfigureServices(IServiceCollection services)
16 | {
17 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
18 | }
19 |
20 | public void Configure(IApplicationBuilder app, IHostingEnvironment env)
21 | {
22 | if (env.IsDevelopment())
23 | app.UseDeveloperExceptionPage();
24 |
25 | app.UseMvc();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Aspnetcoreapp/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Debug",
5 | "System": "Information",
6 | "Microsoft": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Aspnetcoreapp/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Warning"
5 | }
6 | },
7 | "AllowedHosts": "*"
8 | }
9 |
--------------------------------------------------------------------------------
/Db/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mysql:5.7.13
2 | COPY *.sql /docker-entrypoint-initdb.d
3 |
4 | ENV MYSQL_ROOT_PASSWORD myPass
5 |
6 | EXPOSE 3306
7 |
--------------------------------------------------------------------------------
/Db/prepare.sql:
--------------------------------------------------------------------------------
1 | CREATE DATABASE `product-db` /*!40100 COLLATE 'latin1_swedish_ci' */;
2 |
3 | USE `product-db`;
4 |
5 | CREATE TABLE `product` (
6 | `Id` INT NOT NULL AUTO_INCREMENT,
7 | `Name` TEXT NOT NULL,
8 | `Description` TEXT NOT NULL,
9 | INDEX `Id` (`Id`)
10 | )
11 | COLLATE='latin1_swedish_ci';
12 |
13 | INSERT IGNORE INTO product (Id, Name, Description)
14 | VALUES
15 | (1, "Dependency Injection Principles, Practices, and Patterns", "Book by Steven van Deursen and Mark Seemann"),
16 | (2, "Agile Software Development, Principles, Patterns, and Practices", "Book by Robert C. Martin");
17 |
18 |
--------------------------------------------------------------------------------
/Docker-compose-dotnet-core-and-mysql.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductLibrary", "ProductLibrary\ProductLibrary.csproj", "{51D23AEF-044A-444C-89D7-8856B9FCDDEA}"
4 | EndProject
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspnetcoreapp", "Aspnetcoreapp\Aspnetcoreapp.csproj", "{F85093C7-F081-40AA-8E21-52FB5E1A82B0}"
6 | EndProject
7 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{9E982AA6-2E24-40A4-B641-DE4DCC711F13}"
8 | ProjectSection(SolutionItems) = preProject
9 | docker-compose.yml = docker-compose.yml
10 | .dockerignore = .dockerignore
11 | EndProjectSection
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {51D23AEF-044A-444C-89D7-8856B9FCDDEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {51D23AEF-044A-444C-89D7-8856B9FCDDEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {51D23AEF-044A-444C-89D7-8856B9FCDDEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {51D23AEF-044A-444C-89D7-8856B9FCDDEA}.Release|Any CPU.Build.0 = Release|Any CPU
23 | {F85093C7-F081-40AA-8E21-52FB5E1A82B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {F85093C7-F081-40AA-8E21-52FB5E1A82B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {F85093C7-F081-40AA-8E21-52FB5E1A82B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {F85093C7-F081-40AA-8E21-52FB5E1A82B0}.Release|Any CPU.Build.0 = Release|Any CPU
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 SoftwareDeveloperBlog
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ProductLibrary/Product.cs:
--------------------------------------------------------------------------------
1 | namespace ProductLibrary
2 | {
3 | public class Product
4 | {
5 | public int Id { get; }
6 | public string Name { get; }
7 | public string Description { get; }
8 |
9 | public Product(int id, string name, string description)
10 | {
11 | Id = id;
12 | Name = name;
13 | Description = description;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/ProductLibrary/ProductLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.2
5 | ProductLibrary
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ProductLibrary/ProductsProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Dapper;
3 | using MySql.Data.MySqlClient;
4 |
5 | namespace ProductLibrary
6 | {
7 | public class ProductsProvider
8 | {
9 | private const string CONN_STRING = "Server=db;Port=3306;Database=product-db;Uid=root; Pwd=myPass;";
10 | private const string QUERY = "SELECT Id, Name, Description FROM product";
11 |
12 | public Product[] GetAll()
13 | {
14 | using (var connection = new MySqlConnection(CONN_STRING))
15 | {
16 | return connection.Query(QUERY).ToArray();
17 | }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Docker compose Dotnet Core and MySQL example system
2 |
3 | Example docker-compose system, based on .NET Core project and MySQL database (accessed with _Dapper_).
4 |
5 | Dotnet Dockerfile and basic Docker setup based on [SoftwareDeveloper.Blog introduction to Docker](https://www.softwaredeveloper.blog/multi-project-dotnet-core-solution-in-docker-image).
6 |
7 | Docker-compose configuration used in this example is explained line by line in [SoftwareDeveloper.Blog introduction to docker-compose](https://www.softwaredeveloper.blog/docker-compose-introduction-dotnet-core-app-composed-with-mysql-database).
8 |
9 | ## Docker-compose up
10 | if you want to see this example running, you can just type `docker-compose up` from solution directory.
11 |
12 | ## Docker-compose up -d
13 | If you want run this example but without attaching console, run _docker-compose up_ in detach mode - `docker-compose up -d`.
14 |
15 | ## Docker-compose up --build
16 | If you have already composed system up, but then changed source code, you need to pass _--build_ parameter, when running _docker-compose up_ next time: `docker-compose up --build`.
17 | Of course it can be used along with detach parameter.
18 |
19 | ## Docker-compose down
20 | When you want to clean up containers and networks created by _docker-compose_, just type `docker-compose down` from solution directory.
21 |
22 | ## Check if system works
23 | If you want to see if this example system works properly, just access in your browser following GET address - `http://localhost:8080` and you should see following results taken from database:
24 |
25 | ``` json
26 | [
27 | {
28 | "id": 1,
29 | "name": "Dependency Injection Principles, Practices, and Patterns",
30 | "description": "Book by Steven van Deursen and Mark Seemann"
31 | },
32 | {
33 | "id": 2,
34 | "name": "Agile Software Development, Principles, Patterns, and Practices",
35 | "description": "Book by Robert C. Martin"
36 | }
37 | ]
38 | ```
39 |
40 | If you see empty result, wait a while and try again - maybe MyQSL database is not fully initialized yet.
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | db:
5 | build: ./Db
6 | app:
7 | build:
8 | context: .
9 | dockerfile: Aspnetcoreapp/Dockerfile
10 | ports:
11 | - 8080:80
12 | depends_on:
13 | - db
14 |
--------------------------------------------------------------------------------