Servicii pe docker cu diverse aplicatii: python, node, php, .net

This commit is contained in:
2025-12-12 09:00:05 +00:00
parent 498b01ddd1
commit 3525523167
41 changed files with 468 additions and 9 deletions

View File

View File

@@ -1,12 +1,53 @@
version: "3.9"
services: services:
php: nginx:
build: image: nginx:latest
context: .
dockerfile: docker/php/Dockerfile
container_name: itschool-php84
volumes:
- ./src:/var/www/html
ports: ports:
- "8080:80" - "8080:80"
volumes:
- ./src:/var/www/src
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
restart: unless-stopped
php:
image: php:8.3-fpm
volumes:
- ./src:/var/www/src
restart: unless-stopped
python:
image: python:3.12-slim
container_name: alex-python
working_dir: /app
volumes:
- .:/app
command: python /app/www/script_python2.py
ports:
- "8088:8088"
restart: unless-stopped
dotnet:
image: mcr.microsoft.com/dotnet/sdk:8.0
container_name: alex-dotnet
working_dir: /app
volumes:
- ./www/programDotNet:/app
command: dotnet run --urls http://0.0.0.0:8085
ports:
- "8085:8085"
restart: unless-stopped
node:
image: node:20-alpine
container_name: alex-node
working_dir: /app
volumes:
- .:/app
environment:
- PORT=8090
command: node /app/www/node_script.js
ports:
- "8090:8090"
restart: unless-stopped

5
docker/dotnet/Docker Normal file
View File

@@ -0,0 +1,5 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY . .
EXPOSE 8088
ENTRYPOINT ["dotnet", "SimpleDotnetServer.dll"]

22
docker/nginx/default.conf Normal file
View File

@@ -0,0 +1,22 @@
server {
listen 80;
server_name localhost;
root /var/www/src;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}

12
www/node_script.js Normal file
View File

@@ -0,0 +1,12 @@
const http = require("http");
const PORT = process.env.PORT || 8090;
const server = http.createServer((req, res) => {
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
res.end("Salut! Node.js rulează pe portul " + PORT + "\n");
});
server.listen(PORT, "0.0.0.0", () => {
console.log(`Node server: http://0.0.0.0:${PORT}`);
});

View File

@@ -0,0 +1,10 @@
var builder = WebApplication.CreateBuilder(args);
// ascultă pe 0.0.0.0:8085
builder.WebHost.UseUrls("http://0.0.0.0:8085");
var app = builder.Build();
app.MapGet("/", () => "Salut! .NET rulează pe 8085. fisier updatat");
app.Run();

Binary file not shown.

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"programDotNet/1.0.0": {
"runtime": {
"programDotNet.dll": {}
}
}
}
},
"libraries": {
"programDotNet/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,19 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "8.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1 @@
{"Version":1,"ManifestType":"Build","Endpoints":[]}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]

Binary file not shown.

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("programDotNet")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("programDotNet")]
[assembly: System.Reflection.AssemblyTitleAttribute("programDotNet")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
ef4e0c11006f2dd239d8ab66d729a68f61d4fa32924b55c8329b555050161ab2

View File

@@ -0,0 +1,23 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetFrameworkIdentifier = .NETCoreApp
build_property.TargetFrameworkVersion = v8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb = true
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = programDotNet
build_property.RootNamespace = programDotNet
build_property.ProjectDir = /app/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.RazorLangVersion = 8.0
build_property.SupportLocalizedComponentNames =
build_property.GenerateRazorMetadataSourceChecksumAttributes =
build_property.MSBuildProjectDirectory = /app
build_property._RazorSourceGeneratorDebug =
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,17 @@
// <auto-generated/>
global using Microsoft.AspNetCore.Builder;
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.Routing;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
global using System;
global using System.Collections.Generic;
global using System.IO;
global using System.Linq;
global using System.Net.Http;
global using System.Net.Http.Json;
global using System.Threading;
global using System.Threading.Tasks;

View File

@@ -0,0 +1 @@
78e56dd823ebe82c5116b011dea1d4f07d11c07a6cbca67c3b275ceeafa27f13

View File

@@ -0,0 +1,26 @@
/app/obj/Debug/net8.0/programDotNet.GeneratedMSBuildEditorConfig.editorconfig
/app/obj/Debug/net8.0/programDotNet.AssemblyInfoInputs.cache
/app/obj/Debug/net8.0/programDotNet.AssemblyInfo.cs
/app/obj/Debug/net8.0/programDotNet.csproj.CoreCompileInputs.cache
/app/obj/Debug/net8.0/programDotNet.MvcApplicationPartsAssemblyInfo.cache
/app/bin/Debug/net8.0/programDotNet
/app/bin/Debug/net8.0/programDotNet.deps.json
/app/bin/Debug/net8.0/programDotNet.runtimeconfig.json
/app/bin/Debug/net8.0/programDotNet.dll
/app/bin/Debug/net8.0/programDotNet.pdb
/app/obj/Debug/net8.0/staticwebassets.build.json
/app/obj/Debug/net8.0/staticwebassets.development.json
/app/obj/Debug/net8.0/scopedcss/bundle/programDotNet.styles.css
/app/obj/Debug/net8.0/programDotNet.dll
/app/obj/Debug/net8.0/refint/programDotNet.dll
/app/obj/Debug/net8.0/programDotNet.pdb
/app/obj/Debug/net8.0/programDotNet.genruntimeconfig.cache
/app/obj/Debug/net8.0/ref/programDotNet.dll
/app/bin/Debug/net8.0/programDotNet.staticwebassets.endpoints.json
/app/obj/Debug/net8.0/rpswa.dswa.cache.json
/app/obj/Debug/net8.0/rjimswa.dswa.cache.json
/app/obj/Debug/net8.0/rjsmrazor.dswa.cache.json
/app/obj/Debug/net8.0/rjsmcshtml.dswa.cache.json
/app/obj/Debug/net8.0/staticwebassets.build.json.cache
/app/obj/Debug/net8.0/staticwebassets.build.endpoints.json
/app/obj/Debug/net8.0/swae.build.ex.cache

Binary file not shown.

View File

@@ -0,0 +1 @@
6c6db989a285f699deea041ae91957c98d32357a05190823d5ccb6d286e83fec

Binary file not shown.

View File

@@ -0,0 +1 @@
{"GlobalPropertiesHash":"fLV7naKvKWbTYVUHjkIjTJtm/olHDr/EnsWwdgzzqYA=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["bzO0TEjhBVNhYEvqtsf/ty9AgBtGHyRIrjLs/G4sxxw="],"CachedAssets":{},"CachedCopyCandidates":{}}

View File

@@ -0,0 +1 @@
{"GlobalPropertiesHash":"MMRCzYhPUzk/dvjkevA6gVPm5Xq+/bKRMXBsywen2EU=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["bzO0TEjhBVNhYEvqtsf/ty9AgBtGHyRIrjLs/G4sxxw="],"CachedAssets":{},"CachedCopyCandidates":{}}

View File

@@ -0,0 +1 @@
{"Version":1,"ManifestType":"Build","Endpoints":[]}

View File

@@ -0,0 +1 @@
{"Version":1,"Hash":"R9B4kODIeQ+F5JrbWKZU4XVNo0G1PgbmB01uJL2Dn04=","Source":"programDotNet","BasePath":"/","Mode":"Root","ManifestType":"Build","ReferencedProjectsConfiguration":[],"DiscoveryPatterns":[],"Assets":[],"Endpoints":[]}

View File

@@ -0,0 +1 @@
R9B4kODIeQ+F5JrbWKZU4XVNo0G1PgbmB01uJL2Dn04=

View File

@@ -0,0 +1,84 @@
{
"format": 1,
"restore": {
"/app/programDotNet.csproj": {}
},
"projects": {
"/app/programDotNet.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/app/programDotNet.csproj",
"projectName": "programDotNet",
"projectPath": "/app/programDotNet.csproj",
"packagesPath": "/root/.nuget/packages/",
"outputPath": "/app/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/root/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "10.0.100"
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[8.0.22, 8.0.22]"
},
{
"name": "Microsoft.NETCore.App.Host.linux-arm64",
"version": "[8.0.22, 8.0.22]"
},
{
"name": "Microsoft.NETCore.App.Ref",
"version": "[8.0.22, 8.0.22]"
}
],
"frameworkReferences": {
"Microsoft.AspNetCore.App": {
"privateAssets": "none"
},
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/10.0.101/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/root/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/root/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">7.0.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/root/.nuget/packages/" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,89 @@
{
"version": 3,
"targets": {
"net8.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net8.0": []
},
"packageFolders": {
"/root/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/app/programDotNet.csproj",
"projectName": "programDotNet",
"projectPath": "/app/programDotNet.csproj",
"packagesPath": "/root/.nuget/packages/",
"outputPath": "/app/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/root/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "10.0.100"
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[8.0.22, 8.0.22]"
},
{
"name": "Microsoft.NETCore.App.Host.linux-arm64",
"version": "[8.0.22, 8.0.22]"
},
{
"name": "Microsoft.NETCore.App.Ref",
"version": "[8.0.22, 8.0.22]"
}
],
"frameworkReferences": {
"Microsoft.AspNetCore.App": {
"privateAssets": "none"
},
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/10.0.101/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,12 @@
{
"version": 2,
"dgSpecHash": "83bfm2dKkvU=",
"success": true,
"projectFilePath": "/app/programDotNet.csproj",
"expectedPackageFiles": [
"/root/.nuget/packages/microsoft.netcore.app.ref/8.0.22/microsoft.netcore.app.ref.8.0.22.nupkg.sha512",
"/root/.nuget/packages/microsoft.aspnetcore.app.ref/8.0.22/microsoft.aspnetcore.app.ref.8.0.22.nupkg.sha512",
"/root/.nuget/packages/microsoft.netcore.app.host.linux-arm64/8.0.22/microsoft.netcore.app.host.linux-arm64.8.0.22.nupkg.sha512"
],
"logs": []
}

View File

@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

17
www/script_python2.py Normal file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env python3
from http.server import BaseHTTPRequestHandler, HTTPServer
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-Type", "text/plain; charset=utf-8")
self.end_headers()
self.wfile.write(b"Salut! Server Python 2 ruleaza pe portul 8088")
def main():
server = HTTPServer(("0.0.0.0", 8088), Handler)
print("Python server pornit pe http://0.0.0.0:8088")
server.serve_forever()
if __name__ == "__main__":
main()