Skip to content

Commit e818f0b

Browse files
author
heungbae
committed
docker 실습 자료 추가
1 parent 5d8dc07 commit e818f0b

File tree

12 files changed

+1322
-1
lines changed

12 files changed

+1322
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@
7878
- [Docker 알아보아요! (2019)](https://mysetting.io/slides/docker-basic )
7979
- [생활 코딩 - docker](https://opentutorials.org/course/4781/30609 )
8080
- [Best practices for writing Dockerfiles 요약](https://docs.google.com/document/d/1gSJW9agm--xyeO3MuDzTT3XsFxdo3k250H_GrnRUQ9k/edit?usp=sharing )
81-
81+
82+
- 실습 자료
83+
- [2024-01 김성연님 실습 자료](/docker/docker-202301_ksy)
84+
8285

8386
<br>
8487

docker/docker-202301_ksy/.gitignore

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2+
[Bb]in/
3+
[Oo]bj/
4+
5+
# Logs
6+
Logs/
7+
8+
# Generated files
9+
project.lock.json
10+
.vs/
11+
12+
# mstest test results
13+
TestResults
14+
15+
## Ignore Visual Studio temporary files, build results, and
16+
## files generated by popular Visual Studio add-ons.
17+
18+
# User-specific files
19+
*.suo
20+
*.user
21+
*.sln.docstates
22+
23+
# Build results
24+
[Dd]ebug/
25+
[Rr]elease/
26+
x64/
27+
*_i.c
28+
*_p.c
29+
*.ilk
30+
*.meta
31+
*.obj
32+
*.pch
33+
*.pdb
34+
*.pgc
35+
*.pgd
36+
*.rsp
37+
*.sbr
38+
*.tlb
39+
*.tli
40+
*.tlh
41+
*.tmp
42+
*.log
43+
*.vspscc
44+
*.vssscc
45+
*.dll
46+
*.exe
47+
.builds
48+
49+
# Visual C++ cache files
50+
ipch/
51+
*.aps
52+
*.ncb
53+
*.opensdf
54+
*.sdf
55+
56+
# Visual Studio profiler
57+
*.psess
58+
*.vsp
59+
*.vspx
60+
61+
# Guidance Automation Toolkit
62+
*.gpState
63+
64+
# ReSharper is a .NET coding add-in
65+
_ReSharper*
66+
67+
# NCrunch
68+
*.ncrunch*
69+
.*crunch*.local.xml
70+
71+
# Installshield output folder
72+
[Ee]xpress
73+
74+
# DocProject is a documentation generator add-in
75+
DocProject/buildhelp/
76+
DocProject/Help/*.HxT
77+
DocProject/Help/*.HxC
78+
DocProject/Help/*.hhc
79+
DocProject/Help/*.hhk
80+
DocProject/Help/*.hhp
81+
DocProject/Help/Html2
82+
DocProject/Help/html
83+
84+
# Click-Once directory
85+
publish
86+
87+
# Publish Web Output
88+
*.Publish.xml
89+
90+
# NuGet Packages Directory
91+
packages
92+
93+
# Windows Azure Build Output
94+
csx
95+
*.build.csdef
96+
97+
# Windows Store app package directory
98+
AppPackages/
99+
100+
# Others
101+
[Bb]in
102+
[Oo]bj
103+
sql
104+
TestResults
105+
[Tt]est[Rr]esult*
106+
*.Cache
107+
ClientBin
108+
[Ss]tyle[Cc]op.*
109+
~$*
110+
*.dbmdl
111+
Generated_Code #added for RIA/Silverlight projects
112+
113+
# Backup & report files from converting an old project file to a newer
114+
# Visual Studio version. Backup files are not needed, because we have git ;-)
115+
_UpgradeReport_Files/
116+
Backup*/
117+
UpgradeLog*.XML
118+
src/.vs/config/applicationhost.config
119+
120+
# JetBrains Rider's auto generated files
121+
.idea/
122+
appsettings.*
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
2+
3+
WORKDIR /App
4+
5+
COPY *.csproj ./
6+
RUN dotnet restore
7+
8+
COPY . ./
9+
RUN dotnet publish -c Release -o out
10+
EXPOSE 11500
11+
12+
# Build runtime image
13+
FROM mcr.microsoft.com/dotnet/aspnet:8.0
14+
WORKDIR /App
15+
COPY --from=build-env /App/out .
16+
ENTRYPOINT ["dotnet", "APIServer.dll"]
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using System.IO;
2+
using APIServer.Repository;
3+
using APIServer.Repository.Interfaces;
4+
using APIServer.Services;
5+
using APIServer.Servicies;
6+
using APIServer.Servicies.Interfaces;
7+
using Microsoft.AspNetCore.Builder;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.DependencyInjection;
10+
using Microsoft.Extensions.Logging;
11+
using ZLogger;
12+
13+
14+
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
15+
16+
IConfiguration configuration = builder.Configuration;
17+
18+
builder.Services.Configure<DbConfig>(configuration.GetSection(nameof(DbConfig)));
19+
20+
builder.Services.AddTransient<IGameDb, GameDb>();
21+
builder.Services.AddSingleton<IMemoryDb, MemoryDb>();
22+
builder.Services.AddSingleton<IMasterDb, MasterDb>();
23+
builder.Services.AddTransient<IAuthService, AuthService>();
24+
builder.Services.AddTransient<IFriendService, FriendService>();
25+
builder.Services.AddTransient<IGameService, GameService>();
26+
builder.Services.AddTransient<IItemService, ItemService>();
27+
builder.Services.AddTransient<IMailService, MailService>();
28+
builder.Services.AddTransient<IUserService, UserService>();
29+
builder.Services.AddTransient<IAttendanceService, AttendanceService>();
30+
builder.Services.AddTransient<IDataLoadService, DataLoadService>();
31+
builder.Services.AddControllers();
32+
33+
SettingLogger();
34+
35+
builder.Services.AddCors(options =>
36+
{
37+
options.AddDefaultPolicy(policy => policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
38+
});
39+
40+
WebApplication app = builder.Build();
41+
42+
if(!await app.Services.GetService<IMasterDb>().Load())
43+
{
44+
return;
45+
}
46+
47+
//log setting
48+
ILoggerFactory loggerFactory = app.Services.GetRequiredService<ILoggerFactory>();
49+
50+
app.UseCors();
51+
app.UseAuthentication();
52+
app.UseAuthorization();
53+
54+
app.UseMiddleware<APIServer.Middleware.VersionCheck>();
55+
app.UseMiddleware<APIServer.Middleware.CheckUserAuthAndLoadUserData>();
56+
57+
app.UseRouting();
58+
59+
60+
61+
#pragma warning disable ASP0014
62+
app.UseEndpoints(endpoints => { _ = endpoints.MapControllers(); });
63+
#pragma warning restore ASP0014
64+
65+
IMasterDb masterDataDB = app.Services.GetRequiredService<IMasterDb>();
66+
await masterDataDB.Load();
67+
68+
app.Run(configuration["ServerAddress"]);
69+
70+
void SettingLogger()
71+
{
72+
ILoggingBuilder logging = builder.Logging;
73+
logging.ClearProviders();
74+
75+
var fileDir = configuration["logdir"];
76+
77+
var exists = Directory.Exists(fileDir);
78+
79+
if (!exists)
80+
{
81+
Directory.CreateDirectory(fileDir);
82+
}
83+
84+
logging.AddZLoggerRollingFile(
85+
options =>
86+
{
87+
options.UseJsonFormatter();
88+
options.FilePathSelector = (timestamp, sequenceNumber) => $"{fileDir}{timestamp.ToLocalTime():yyyy-MM-dd}_{sequenceNumber:000}.log";
89+
options.RollingInterval = ZLogger.Providers.RollingInterval.Day;
90+
options.RollingSizeKB = 1024;
91+
});
92+
93+
logging.AddZLoggerConsole(options =>
94+
{
95+
options.UseJsonFormatter();
96+
});
97+
98+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
실제 APIServer는 아래 링크에서 확인할 수 있습니다.
2+
3+
https://github.com/thatslifebro/MiniGameHeavenAPIServer
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM mysql:8.2
2+
3+
ENV MYSQL_ROOT_PASSWORD=Rlatjd095980!
4+
5+
COPY ./Dump.sql /docker-entrypoint-initdb.d/
6+
7+
EXPOSE 3306
8+
9+
CMD ["mysqld","--character-set-server=utf8", "--collation-server=utf8_general_ci"]

0 commit comments

Comments
 (0)