Compare commits

..

3 Commits

Author SHA1 Message Date
Jukoga 5428475717 added Database support vis Docker 2024-11-26 21:11:35 +01:00
Jukoga 44405f092f updated .gitignore 2024-11-23 18:31:39 +01:00
Jukoga d75518d1ff added A PostgressDB via Docker 2024-11-23 18:31:04 +01:00
17 changed files with 427 additions and 49 deletions

2
.gitignore vendored
View File

@ -2,7 +2,7 @@
## files generated by popular Visual Studio add-ons. ## files generated by popular Visual Studio add-ons.
## ##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
.idea
# User-specific files # User-specific files
*.rsuser *.rsuser
*.suo *.suo

View File

@ -10,19 +10,19 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.10" /> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Data\" />
<Folder Include="Migrations\" /> <Folder Include="Migrations\" />
</ItemGroup> </ItemGroup>

View File

@ -5,6 +5,11 @@ VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BHServer", "BHServer.csproj", "{84BDA934-6556-40C9-A550-EB1B894CFAC0}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BHServer", "BHServer.csproj", "{84BDA934-6556-40C9-A550-EB1B894CFAC0}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AB5CF1F1-2CBD-4F37-BC7D-E8952804FC0C}"
ProjectSection(SolutionItems) = preProject
docker-compose.yaml = docker-compose.yaml
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU

View File

@ -1,42 +1,33 @@
using Microsoft.AspNetCore.Mvc; using BHServer.Data;
using Microsoft.AspNetCore.Mvc;
using BHServer.Models;
using Newtonsoft.Json;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace BHServer.Controllers namespace BHServer.Controllers
{ {
[Route("api/[controller]")]
public class AssaultTroopController : ControllerBase public class AssaultTroopController : ControllerBase
{ {
List<string> MockData = [ private readonly ApplicationDbContext _db;
"{\"id\": 1, \"name\": \"First Infantry Division\", \"faction\": 2, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 1}", public AssaultTroopController(ApplicationDbContext db)
"{\"id\": 2, \"name\": \"First Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
"{\"id\": 3, \"name\": \"Second Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
"{\"id\": 4, \"name\": \"Third Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
"{\"id\": 5, \"name\": \"Cheeki Breeki Boys\", \"faction\": 2, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 3}",
"{\"id\": 6, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
"{\"id\": 7, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
"{\"id\": 8, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
"{\"id\": 9, \"name\": \"Cheeki Breeki Boys\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 3}",
"{\"id\": 10, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
"{\"id\": 11, \"name\": \"Fifth Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": -1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 5}",
"{\"id\": 12, \"name\": \"Fifth Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": -1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 5}",
"{\"id\": 13, \"name\": \"First Armor Division\", \"faction\": 1, \"type\": 4, \"province\": 2, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
"{\"id\": 14, \"name\": \"Second Armor Division\", \"faction\": 1, \"type\": 4, \"province\": 2, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
"{\"id\": 15, \"name\": \"Cheeki Breeki Tonks\", \"faction\": 2, \"type\": 4, \"province\": 2, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 3}"
];
// GET: /<APIController>
[HttpGet]
public IEnumerable<string> Get()
{ {
return MockData; _db = db;
} }
/*public IActionResult Index()
{
List<AssaultTroop> ObjectAssaultTroopList = _db.AssaultTroops.ToList();
// If the above line faulters then ensure SQL Server is running
return View(ObjectAssaultTroopList);
}*/
// GET /<APIController>/5 // GET /<APIController>/5
[HttpGet("{id}")] [HttpGet]
public string Get(int id) public string Get()
{ {
var entry = MockData.ElementAt(id); List<AssaultTroop> assaultTroopList = _db.assault_troop.ToList();
return entry; return JsonConvert.SerializeObject(assaultTroopList);
} }
// POST /<APIController> // POST /<APIController>

View File

@ -3,6 +3,7 @@ using System;
namespace BHServer.Controllers namespace BHServer.Controllers
{ {
[Route("api/[controller]")]
public class ProvinceController : Controller public class ProvinceController : Controller
{ {
List<string> MockData = [ List<string> MockData = [

View File

@ -0,0 +1,20 @@
using BHServer.Models;
using Microsoft.EntityFrameworkCore;
namespace BHServer.Data
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
// this will pass along the options from the implementation to the definition
{
}
public DbSet<Province> province { get; set; } // specify the table and it's class
// to run migrations, run `add-migration <name of the migration>` in the NuGet console
// then make the migrations from the console by using `update-database`
// to rollback migrations run the command `remove-migration <name>`
public DbSet<AssaultTroop> assault_troop { get; set; }
}
}

View File

@ -0,0 +1,98 @@
// <auto-generated />
using BHServer.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace BHServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20241124152636_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("BHServer.Models.AssaultTroop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ATId")
.HasColumnType("integer");
b.Property<int>("Faction")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Orders")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Owner")
.HasColumnType("integer");
b.Property<int>("Province")
.HasColumnType("integer");
b.Property<int>("Type")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("AssaultTroop");
});
modelBuilder.Entity("BHServer.Models.Province", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ATs")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Faction")
.HasColumnType("integer");
b.Property<int>("Multiplier")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ProvinceId")
.HasColumnType("integer");
b.Property<int>("State")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Province");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace BHServer.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AssaultTroop",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ATId = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Faction = table.Column<int>(type: "integer", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false),
Province = table.Column<int>(type: "integer", nullable: false),
Orders = table.Column<string>(type: "text", nullable: false),
Owner = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AssaultTroop", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Province",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ProvinceId = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Faction = table.Column<int>(type: "integer", nullable: false),
Multiplier = table.Column<int>(type: "integer", nullable: false),
ATs = table.Column<string>(type: "text", nullable: false),
State = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Province", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AssaultTroop");
migrationBuilder.DropTable(
name: "Province");
}
}
}

View File

@ -0,0 +1,95 @@
// <auto-generated />
using BHServer.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace BHServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("BHServer.Models.AssaultTroop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ATId")
.HasColumnType("integer");
b.Property<int>("Faction")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Orders")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Owner")
.HasColumnType("integer");
b.Property<int>("Province")
.HasColumnType("integer");
b.Property<int>("Type")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("AssaultTroop");
});
modelBuilder.Entity("BHServer.Models.Province", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ATs")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Faction")
.HasColumnType("integer");
b.Property<int>("Multiplier")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ProvinceId")
.HasColumnType("integer");
b.Property<int>("State")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Province");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -5,19 +5,18 @@ namespace BHServer.Models
public class AssaultTroop public class AssaultTroop
{ {
[Key] [Key]
public int Id { get; set; } public int id { get; set; }
public int ATId { get; set; }
[Required] [Required]
public string Name { get; set; } public string name { get; set; }
[Required] [Required]
public int Faction { get; set; } // 0 - Neutral, 1 - Allies, 2 - Axis public int faction { get; set; } // 0 - Neutral, 1 - Allies, 2 - Axis
[Required] [Required]
public int Type { get; set; } // 1 - infantry, 4 - Armor public int type { get; set; } // 1 - infantry, 4 - Armor
[Required] [Required]
public int Province { get; set; } // -1 - not deployed, provinces id public int province { get; set; } // -1 - not deployed, provinces id
[Required] [Required]
public string Orders { get; set; } // Json String public string orders { get; set; } // Json String
[Required] [Required]
public int Owner { get; set; } // owner id public int owner { get; set; } // owner id
} }
} }

View File

@ -5,17 +5,16 @@ namespace BHServer.Models
public class Province public class Province
{ {
[Key] [Key]
public int Id { get; set; } public int id { get; set; }
public int ProvinceId { get; set; }
[Required] [Required]
public string Name { get; set; } public string name { get; set; }
[Required] [Required]
public int Faction { get; set; } // 0 - Neutral, 1 - Allies, 2 - Axis public int faction { get; set; } // 0 - Neutral, 1 - Allies, 2 - Axis
[Required] [Required]
public int Multiplier { get; set; } // 0-1 public int multiplier { get; set; } // 0-1
[Required] [Required]
public string ATs { get; set; } // Json String public string ats { get; set; } // Json String
[Required] [Required]
public int State { get; set; } // 0 - Peace, 1 - War public int state { get; set; } // 0 - Peace, 1 - War
} }
} }

13
PostgressDB/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
# Use the official PostgreSQL image as the base image
FROM postgres:latest
# Set environment variables for PostgreSQL
ENV POSTGRES_DB=mydatabase
ENV POSTGRES_USER=myuser
ENV POSTGRES_PASSWORD=mypassword
# Copy initialization scripts into the Docker image
COPY init.sql /docker-entrypoint-initdb.d/
# Expose the PostgreSQL port
EXPOSE 5432

53
PostgressDB/init.sql Normal file
View File

@ -0,0 +1,53 @@
-- Create the AssaultTroop table
CREATE TABLE assault_troop (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
faction INT NOT NULL, -- 0 - Neutral, 1 - Allies, 2 - Axis
type INT NOT NULL, -- 1 - Infantry, 4 - Armor
province INT NOT NULL, -- -1 - Not deployed, Province IDs
orders JSONB NOT NULL, -- JSON String
owner INT NOT NULL -- Owner ID
);
INSERT INTO assault_troop (id, name, faction, type, province, orders, owner) VALUES
(1, 'First Infantry Division', 2, 1, 0, '{"Dep": [], "Mov": []}', 1),
(2, 'First Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2),
(3, 'Second Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2),
(4, 'Third Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2),
(5, 'Cheeki Breeki Boys', 2, 1, 0, '{"Dep": [], "Mov": []}', 3),
(6, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4),
(7, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4),
(8, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4),
(9, 'Cheeki Breeki Boys', 2, 1, 1, '{"Dep": [], "Mov": []}', 3),
(10, 'Hitlers Men', 2, 1, 0, '{"Dep": [], "Mov": []}', 4),
(11, 'Fifth Infantry Division', 1, 1, -1, '{"Dep": [], "Mov": []}', 5),
(12, 'Fifth Infantry Division', 1, 1, -1, '{"Dep": [], "Mov": []}', 5),
(13, 'First Armor Division', 1, 4, 2, '{"Dep": [], "Mov": []}', 2),
(14, 'Second Armor Division', 1, 4, 2, '{"Dep": [], "Mov": []}', 2),
(15, 'Cheeki Breeki Tonks', 2, 4, 2, '{"Dep": [], "Mov": []}', 3);
-- Create the Province table
CREATE TABLE province (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
faction INT NOT NULL, -- 0 - Neutral, 1 - Allies, 2 - Axis
multiplier DECIMAL(3, 2) NOT NULL, -- 0-1
ats JSONB NOT NULL, -- JSON String
state INT NOT NULL -- 0 - Peace, 1 - War
);
INSERT INTO province (id, name, faction, multiplier, ats, state) VALUES
(0, 'Hessen', 2, 1.00, '{"Allies": [2, 3, 4], "Axis": [1, 5, 9, 10]}', 1),
(1, 'Thuringen', 2, 1.00, '{"Allies": [], "Axis": [6, 7, 8]}', 0),
(2, 'Rheinland-Pfalz', 1, 1.00, '{"Allies": [13, 14], "Axis": [15]}', 1),
(4, 'Baden-Wurttemberg', 1, 1.00, '{"Allies": [17, 19], "Axis": []}', 0),
(3, 'Saarland', 1, 1.00, '{"Allies": [16, 17, 18], "Axis": []}', 0),
(5, 'Bayern', 1, 1.00, '{"Allies": [20, 21], "Axis": []}', 0),
(6, 'Sachsen', 1, 1.00, '{"Allies": [23], "Axis": []}', 0),
(7, 'Brandenburg', 2, 1.00, '{"Allies": [], "Axis": [25, 26, 27, 28]}', 0),
(8, 'Berlin', 2, 1.00, '{"Allies": [], "Axis": [29, 30, 31]}', 0),
(9, 'Schleswig-Holstein', 2, 1.00, '{"Allies": [], "Axis": [33]}', 0),
(10, 'Hamburg', 2, 1.00, '{"Allies": [], "Axis": [34]}', 0),
(11, 'Niedersachsen', 2, 1.00, '{"Allies": [], "Axis": [35]}', 0),
(12, 'Nordreihn-Westfalen', 1, 1.00, '{"Allies": [36, 37], "Axis": []}', 0);

View File

@ -1,3 +1,4 @@
using BHServer.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -5,6 +6,12 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<ApplicationDbContext>(
options => options.UseNpgsql(connectionString)
// `ConnectionString` is defined in the appsettings.json file
);
var app = builder.Build(); var app = builder.Build();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.

View File

@ -4,5 +4,8 @@
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
},
"ConnectionStrings": {
"DefaultConnection": "Server=db;Username=APIUser;Password=APIUserPw;Database=BHDB;Port=5432;SearchPath=public"
} }
} }

View File

@ -5,6 +5,9 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=db;Username=APIUser;Password=APIUserPw;Database=BHDB;Port=5432;SearchPath=public"
}
// This also needs to be changed // This also needs to be changed
} }

29
docker-compose.yml Normal file
View File

@ -0,0 +1,29 @@
services:
db:
build: ./PostgressDB
container_name: Beyond_Heroes_War_DB
ports:
- "6732:5432"
environment:
POSTGRES_DB: BHDB
POSTGRES_USER: APIUser
POSTGRES_PASSWORD: APIUserPw
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_INITDB_ARGS: --auth-host=trust --auth-local=trust
volumes:
- ./PostgressDB/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- bhnetwork
bhserver:
container_name: Beyond_Heroes_War_Server
build:
context: .
dockerfile: Dockerfile
ports:
- "32770:8080"
networks:
- bhnetwork
networks:
bhnetwork:
driver: bridge