(feature): dockerized client app

This commit is contained in:
Maksym Sadovnychyy 2023-05-26 15:35:34 +02:00
parent 740a5d2d75
commit cb4615b14d
26 changed files with 102 additions and 19 deletions

View File

@ -0,0 +1,6 @@
**/.dockerignore
**/.vs
**/.vscode
**/Dockerfile*
**/node_modules
!**/.env

View File

@ -3,7 +3,7 @@ BROWSER=none
REACT_APP_LOCAL_ONLY=Y REACT_APP_LOCAL_ONLY=Y
REACT_APP_FRONTEND=https://localhost:7174 REACT_APP_FRONTEND=https://localhost:7174
REACT_APP_API=https://localhost:7174/api REACT_APP_API=https://reverseproxy:7174/api
REACT_APP_SITEID=404c8232-9048-4519-bfba-6e78dc7005ca REACT_APP_SITEID=404c8232-9048-4519-bfba-6e78dc7005ca
REACT_APP_LOCALE=en-US REACT_APP_LOCALE=en-US

View File

@ -32,6 +32,14 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Content Include=".dockerignore">
<SubType>Content</SubType>
<DependentUpon>Dockerfile</DependentUpon>
</Content>
<None Include="Dockerfile" />
<Content Include=".env" />
<Content Include=".eslintrc.json" />
<Content Include="package-lock.json" />
<Content Include="src\components\FeatherIcons\icons.json" /> <Content Include="src\components\FeatherIcons\icons.json" />
<Content Include="src\components\Loader\scss\animations\ball-beat.scss" /> <Content Include="src\components\Loader\scss\animations\ball-beat.scss" />
<Content Include="src\components\Loader\scss\animations\ball-clip-rotate-multiple.scss" /> <Content Include="src\components\Loader\scss\animations\ball-clip-rotate-multiple.scss" />
@ -116,6 +124,7 @@
<Folder Include="src\enumerations\" /> <Folder Include="src\enumerations\" />
<Folder Include="src\functions\" /> <Folder Include="src\functions\" />
<Folder Include="src\functions\jwtDecode\" /> <Folder Include="src\functions\jwtDecode\" />
<Folder Include="src\interfaces\" />
<Folder Include="src\layouts\" /> <Folder Include="src\layouts\" />
<Folder Include="src\layouts\admin\" /> <Folder Include="src\layouts\admin\" />
<Folder Include="src\layouts\admin\NavMenu\" /> <Folder Include="src\layouts\admin\NavMenu\" />
@ -127,7 +136,6 @@
<Folder Include="src\layouts\public\NavMenu\" /> <Folder Include="src\layouts\public\NavMenu\" />
<Folder Include="src\layouts\public\scss\" /> <Folder Include="src\layouts\public\scss\" />
<Folder Include="src\layouts\scss\" /> <Folder Include="src\layouts\scss\" />
<Folder Include="src\models\" />
<Folder Include="src\pages\" /> <Folder Include="src\pages\" />
<Folder Include="src\pages\Blog\" /> <Folder Include="src\pages\Blog\" />
<Folder Include="src\pages\Blog\Catalog\" /> <Folder Include="src\pages\Blog\Catalog\" />
@ -178,6 +186,7 @@
<TypeScriptCompile Include="src\functions\jwtDecode\base64_url_decode.ts" /> <TypeScriptCompile Include="src\functions\jwtDecode\base64_url_decode.ts" />
<TypeScriptCompile Include="src\functions\jwtDecode\index.ts" /> <TypeScriptCompile Include="src\functions\jwtDecode\index.ts" />
<TypeScriptCompile Include="src\index.tsx" /> <TypeScriptCompile Include="src\index.tsx" />
<TypeScriptCompile Include="src\interfaces\index.ts" />
<TypeScriptCompile Include="src\layouts\admin\index.tsx" /> <TypeScriptCompile Include="src\layouts\admin\index.tsx" />
<TypeScriptCompile Include="src\layouts\admin\NavMenu\index.tsx" /> <TypeScriptCompile Include="src\layouts\admin\NavMenu\index.tsx" />
<TypeScriptCompile Include="src\layouts\admin\SideMenu\index.tsx" /> <TypeScriptCompile Include="src\layouts\admin\SideMenu\index.tsx" />
@ -186,12 +195,6 @@
<TypeScriptCompile Include="src\layouts\public\Footer\index.tsx" /> <TypeScriptCompile Include="src\layouts\public\Footer\index.tsx" />
<TypeScriptCompile Include="src\layouts\public\index.tsx" /> <TypeScriptCompile Include="src\layouts\public\index.tsx" />
<TypeScriptCompile Include="src\layouts\public\NavMenu\index.tsx" /> <TypeScriptCompile Include="src\layouts\public\NavMenu\index.tsx" />
<TypeScriptCompile Include="src\models\abstractions.ts" />
<TypeScriptCompile Include="src\models\index.ts" />
<TypeScriptCompile Include="src\models\pages.ts" />
<TypeScriptCompile Include="src\models\pageSections.ts" />
<TypeScriptCompile Include="src\models\requests.ts" />
<TypeScriptCompile Include="src\models\responses.ts" />
<TypeScriptCompile Include="src\pages\AdminHome.tsx" /> <TypeScriptCompile Include="src\pages\AdminHome.tsx" />
<TypeScriptCompile Include="src\pages\Blog\Catalog\index.tsx" /> <TypeScriptCompile Include="src\pages\Blog\Catalog\index.tsx" />
<TypeScriptCompile Include="src\pages\Blog\index.ts" /> <TypeScriptCompile Include="src\pages\Blog\index.ts" />
@ -221,7 +224,6 @@
<TypeScriptCompile Include="src\store\reducers\Content.ts" /> <TypeScriptCompile Include="src\store\reducers\Content.ts" />
<TypeScriptCompile Include="src\store\reducers\Counter.ts" /> <TypeScriptCompile Include="src\store\reducers\Counter.ts" />
<TypeScriptCompile Include="src\store\reducers\Header.ts" /> <TypeScriptCompile Include="src\store\reducers\Header.ts" />
<TypeScriptCompile Include="src\store\reducers\Loader.ts" />
<TypeScriptCompile Include="src\store\reducers\ShopCart.ts" /> <TypeScriptCompile Include="src\store\reducers\ShopCart.ts" />
<TypeScriptCompile Include="src\store\reducers\ShopCatalog.ts" /> <TypeScriptCompile Include="src\store\reducers\ShopCatalog.ts" />
<TypeScriptCompile Include="src\store\reducers\ShopCategories.ts" /> <TypeScriptCompile Include="src\store\reducers\ShopCategories.ts" />

14
src/ClientApp/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM node:lts as base
WORKDIR /app
ENV CI=true
ENV PORT=3000
EXPOSE 3000
FROM base as build
COPY ["ClientApp/", "/app"]
RUN npm ci
CMD [ "npm", "start" ]
#FROM build as final
#COPY ["ClientApp/build", "/app"]

View File

@ -82,5 +82,46 @@ namespace Extensions {
return false; return false;
} }
private static readonly string[] suffixes = { "Bytes", "KB", "MB", "GB", "TB", "PB" };
private static decimal FormatSize(int bytes, int index = 1) => (decimal)bytes / 1024 * index;
public static string ToKB(this int bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes, 1), suffixes[1]);
public static string ToKB(this byte[] bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes.Length, 1), suffixes[1]);
public static string ToMB(this int bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes, 2), suffixes[2]);
public static string ToMB(this byte[] bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes.Length, 2), suffixes[2]);
public static string ToGB(this int bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes, 3), suffixes[3]);
public static string ToGB(this byte[] bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes.Length, 3), suffixes[3]);
public static string ToTB(this int bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes, 4), suffixes[4]);
public static string ToTB(this byte[] bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes.Length, 4), suffixes[4]);
public static string ToPB(this int bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes, 5), suffixes[5]);
public static string ToPB(this byte[] bytes) =>
string.Format("{0:n1}{1}", FormatSize(bytes.Length, 5), suffixes[5]);
} }
} }

View File

@ -48,7 +48,7 @@
"cluster2": { "cluster2": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://localhost:3000/" "Address": "http://clientapp:3000/"
} }
} }
} }

View File

@ -8,13 +8,11 @@ EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src WORKDIR /src
COPY ["WeatherForecast/WeatherForecast.csproj", "WeatherForecast/"] COPY ["WeatherForecast/WeatherForecast.csproj", "WeatherForecast/"]
COPY ["Services/FileSecurityService/FileSecurityService.csproj", "Services/FileSecurityService/"] COPY ["FileSecurityService/FileSecurityService.csproj", "Services/FileSecurityService/"]
COPY ["Extensions/Extensions.csproj", "Extensions/"] COPY ["Extensions/Extensions.csproj", "Extensions/"]
COPY ["Core/Core.csproj", "Core/"] COPY ["Core/Core.csproj", "Core/"]
COPY ["Services/ImageProvider/ImageProvider.csproj", "Services/ImageProvider/"] COPY ["ImageProvider/ImageProvider.csproj", "Services/ImageProvider/"]
COPY ["DataProviders/DataProviders.csproj", "DataProviders/"] COPY ["DataProviders/DataProviders.csproj", "DataProviders/"]
COPY ["Services/JWTService/JWTService.csproj", "Services/JWTService/"]
COPY ["Services/HashService/HashService.csproj", "Services/HashService/"]
RUN dotnet restore "WeatherForecast/WeatherForecast.csproj" RUN dotnet restore "WeatherForecast/WeatherForecast.csproj"
COPY . . COPY . .
WORKDIR "/src/WeatherForecast" WORKDIR "/src/WeatherForecast"

View File

@ -5,7 +5,7 @@
<DockerTargetOS>Linux</DockerTargetOS> <DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>7fc6f0ba-2dcb-4b53-a3b3-61ceef42b9d0</ProjectGuid> <ProjectGuid>7fc6f0ba-2dcb-4b53-a3b3-61ceef42b9d0</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction> <DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl> <DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
<DockerServiceName>reverseproxy</DockerServiceName> <DockerServiceName>reverseproxy</DockerServiceName>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,10 +1,25 @@
version: '3.4' version: '3.4'
# Settings and configurations that are common for all containers
x-env-file-common: &env-file-common
env_file:
- './ClientApp/.env'
- './docker-compose/variables.env'
networks: networks:
my-network: my-network:
driver: "bridge" driver: "bridge"
services: services:
clientapp:
<<: *env-file-common
#ports:
# - "3000:3000"
depends_on:
- reverseproxy
networks:
- "my-network"
reverseproxy: reverseproxy:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
@ -21,12 +36,14 @@ services:
- "my-network" - "my-network"
weatherforecast: weatherforecast:
<<: *env-file-common
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:7151;http://+:5133 - ASPNETCORE_URLS=https://+:7151;http://+:5133
ports:
- "7151:7151" #ports:
- "5133:5133" # - "7151:7151"
# - "5133:5133"
volumes: volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro

View File

@ -1,6 +1,11 @@
version: '3.4' version: '3.4'
services: services:
clientapp:
image: ${DOCKER_REGISTRY-}clientapp
build:
context: .
dockerfile: ClientApp/Dockerfile
weatherforecast: weatherforecast:
image: ${DOCKER_REGISTRY-}weatherforecast image: ${DOCKER_REGISTRY-}weatherforecast
build: build:

View File

@ -3,4 +3,4 @@ WiredTiger 10.0.2: (December 21, 2021)
WiredTiger version WiredTiger version
major=10,minor=0,patch=2 major=10,minor=0,patch=2
file:WiredTiger.wt file:WiredTiger.wt
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=0),value_format=S,verbose=[],version=(major=1,minor=1),write_timestamp_usage=none,checkpoint=(WiredTigerCheckpoint.127717=(addr="019681e4fb9f7e379f81e4f489d9b8a081e4070e71ea808080e301ffc0e3010fc0",order=127717,time=1681378661,size=81920,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=188,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=383947,run_write_gen=383679)),checkpoint_backup_info=,checkpoint_lsn=(82,75904) access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=0),value_format=S,verbose=[],version=(major=1,minor=1),write_timestamp_usage=none,checkpoint=(WiredTigerCheckpoint.127995=(addr="018081e4886024688181e4d73f01df8281e4e69d0e29808080e3021fc0e3010fc0",order=127995,time=1685108131,size=81920,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=298,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=384809,run_write_gen=384387)),checkpoint_backup_info=,checkpoint_lsn=(87,118016)

View File