для докера

This commit is contained in:
Professional 2025-03-21 18:18:27 +07:00
parent 53dd6272e6
commit 9f9aa0274f
5 changed files with 82 additions and 0 deletions

30
.dockerignore Normal file
View File

@ -0,0 +1,30 @@
**/.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
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**

25
Dockerfile Normal file
View File

@ -0,0 +1,25 @@
# Используем официальный образ .NET SDK для сборки
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
# Копируем файлы проекта и восстанавливаем зависимости
COPY . ./
RUN dotnet restore
# Сборка проекта
RUN dotnet publish -c Release -o out
# Используем официальный образ .NET Runtime для запуска
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/out .
# Устанавливаем переменные окружения
ENV ASPNETCORE_URLS=http://+:5000
ENV DOTNET_RUNNING_IN_CONTAINER=true
# Открываем порт
EXPOSE 5000
# Запускаем приложение
ENTRYPOINT ["dotnet", "ТГ бот.dll"]

View File

@ -0,0 +1,10 @@
{
"profiles": {
"ТГ бот": {
"commandName": "Project"
},
"Container (Dockerfile)": {
"commandName": "Docker"
}
}
}

14
docker-compose.yml Normal file
View File

@ -0,0 +1,14 @@
version: '3.8'
services:
bot:
build: .
container_name: telegram_bot
ports:
- "5000:5000"
environment:
- ASPNETCORE_ENVIRONMENT=Production
volumes:
- ./logs:/app/logs
restart: always

View File

@ -6,10 +6,13 @@
<RootNamespace>ТГ_бот</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />