Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions HomeWork31/HomeWork31/.dockerignore
Original file line number Diff line number Diff line change
@@ -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/**
68 changes: 68 additions & 0 deletions HomeWork31/HomeWork31/Controllers/StoreController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using HomeWork31.Models;
using Microsoft.AspNetCore.Mvc;

namespace HomeWork31.Controllers
{
[ApiController]
[Route("[controller]")]
public class StoreController : ControllerBase
{
private Item[] Summaries =
{
new Item()
{
Name = "Aplle",
Price = 20
},
new Item()
{
Name = "Banana",
Price = 50
},
new Item()
{
Name = "Orange",
Price = 60
},
new Item()
{
Name = "Mango",
Price = 45,
},
new Item()
{
Name = "Coconuts",
Price = 20
}
};

private readonly ILogger<StoreController> _logger;

public StoreController(ILogger<StoreController> logger)
{
_logger = logger;
}

[HttpGet("GetListFruits")]
public IEnumerable<Item> Get()
{
return Summaries;
}

[HttpPost("AddItem")]
public string Post(Item input)
{
var result = new Item[Summaries.Length];

for (int i = 0; i < Summaries.Length; i++)
{
result[i] = Summaries[i];
}

result[^1] = input;
Summaries = result;

return $"item seccusfull add, id item = {result.Length}";
}
}
}
23 changes: 23 additions & 0 deletions HomeWork31/HomeWork31/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["HomeWork31.csproj", "."]
RUN dotnet restore "./././HomeWork31.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "./HomeWork31.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./HomeWork31.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HomeWork31.dll"]
18 changes: 18 additions & 0 deletions HomeWork31/HomeWork31/HomeWork31.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<UserSecretsId>bcadb0d9-86c3-49a8-800c-a53eb852e961</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions HomeWork31/HomeWork31/HomeWork31.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
<NameOfLastUsedPublishProfile>D:\Projects\Alevel\HomeWork31\HomeWork31\Properties\PublishProfiles\registry.hub.docker.com_redaggressor.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>
6 changes: 6 additions & 0 deletions HomeWork31/HomeWork31/HomeWork31.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@HomeWork31_HostAddress = http://localhost:5051

GET {{HomeWork31_HostAddress}}/weatherforecast/
Accept: application/json

###
25 changes: 25 additions & 0 deletions HomeWork31/HomeWork31/HomeWork31.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HomeWork31", "HomeWork31.csproj", "{47208C51-6610-43EF-8576-9BFB3D74277A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{47208C51-6610-43EF-8576-9BFB3D74277A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47208C51-6610-43EF-8576-9BFB3D74277A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47208C51-6610-43EF-8576-9BFB3D74277A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47208C51-6610-43EF-8576-9BFB3D74277A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BD2811C6-C342-47A2-A701-1327DF99694D}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions HomeWork31/HomeWork31/Models/Item.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace HomeWork31.Models
{
public class Item
{
public string? Name { get; set; }
public double Price { get; set; }
}
}
20 changes: 20 additions & 0 deletions HomeWork31/HomeWork31/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseAuthorization();

app.MapControllers();

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<WebPublishMethod>Custom</WebPublishMethod>
<DockerPublish>true</DockerPublish>
<RegistryUrl>https://registry.hub.docker.com/redaggressor</RegistryUrl>
<UserName>redaggressor</UserName>
<PublishImageTag>latest</PublishImageTag>
<PublishProvider>ContainerRegistry</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<ProjectGuid>47208c51-6610-43ef-8576-9bfb3d74277a</ProjectGuid>
<_TargetId>DockerContainerRegistry</_TargetId>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<EncryptedPassword>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAuPIlVrxFIE6tOmj7WnPv8gAAAAACAAAAAAAQZgAAAAEAACAAAAAAx4bgDuTGBBhG0y+ERyaA02oC6smSePBwAbbfdunYYQAAAAAOgAAAAAIAACAAAAAM6M+ESvMgqG37/k5dAYJG4qqX2CKnGt6c4HI4nC+wRyAAAAA4diMcHajYv5O48PaK75HJoVvrogmzDxURjHO+6nsA0kAAAAA/+6hKiuUzJWWZdBvxG6gtNurHuIoN1WJRi0fMceLiHh2iM4kxZjBTxxsUlfkX4/dEykDo/bvW2xje4lF8bgzr</EncryptedPassword>
<TimeStampOfAssociatedLegacyPublishXmlFile />
<History>True|2024-05-13T17:38:45.6220760Z;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
8 changes: 8 additions & 0 deletions HomeWork31/HomeWork31/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions HomeWork31/HomeWork31/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
29 changes: 29 additions & 0 deletions HomeWork31/HomeWork31/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.8'

services:
catalog.api:
build:
context: .
dockerfile: Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:5000
ports:
- 5000:5000
nginx:
image: nginx:latest
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx.conf

networks:
shop_default:
driver: bridge
internal: false
attachable: true
ipam:
driver: default
config:
- subnet: 192.168.0.0/24
gateway: 192.168.0.1
8 changes: 8 additions & 0 deletions HomeWork31/HomeWork31/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 80;
server_name localhost;

location / {
proxy_pass http://www.alevelwebsite.com:5000;
}
}