Skip to content

Commit e36f338

Browse files
Initial commit
0 parents  commit e36f338

File tree

15 files changed

+351
-0
lines changed

15 files changed

+351
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bin/
2+
obj/
3+
/packages/
4+
riderModule.iml
5+
/_ReSharper.Caches/

OptimizelyTestContainers.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Optimizely.TestContainers", "src\Web\Optimizely.TestContainers.csproj", "{E65E2A81-3213-498F-80B0-4C12CF2CBB6C}"
4+
EndProject
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OptimizelyTestContainers.Tests", "test\OptimizelyTestContainers.Tests\OptimizelyTestContainers.Tests.csproj", "{60DAC0B9-1D46-4D3A-BC27-4B7BE193AB4E}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{E65E2A81-3213-498F-80B0-4C12CF2CBB6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{E65E2A81-3213-498F-80B0-4C12CF2CBB6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{E65E2A81-3213-498F-80B0-4C12CF2CBB6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{E65E2A81-3213-498F-80B0-4C12CF2CBB6C}.Release|Any CPU.Build.0 = Release|Any CPU
17+
{60DAC0B9-1D46-4D3A-BC27-4B7BE193AB4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{60DAC0B9-1D46-4D3A-BC27-4B7BE193AB4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{60DAC0B9-1D46-4D3A-BC27-4B7BE193AB4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{60DAC0B9-1D46-4D3A-BC27-4B7BE193AB4E}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal

src/Web/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
App_Data/
2+
node_modules/
3+
artifacts/
4+
5+
# Visual Studio files
6+
*.user
7+
*.lock.json
8+
.vscode/
9+
.vs/
10+
.nuget/
11+
packages/
12+
bin/
13+
obj/
14+
15+
# Optimizely files
16+
*license.config
17+
modules/
18+
19+
# OS crap
20+
.DS_Store
21+
thumbs.db
22+
ehthumbs.db
23+
desktop.ini
24+
.idea

src/Web/Models/NewsPage.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Optimizely.TestContainers.Models;
2+
3+
[ContentType(
4+
GUID = "7B873919-11AC-4DF4-B9E8-09F414F76164",
5+
DisplayName = "News Page")]
6+
public class NewsPage : PageData
7+
{
8+
public virtual string Title { get; set; }
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<Nullable>enable</Nullable>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Using Include="EPiServer"/>
10+
<Using Include="EPiServer.Core"/>
11+
<Using Include="EPiServer.DataAbstraction"/>
12+
<Using Include="EPiServer.DataAnnotations"/>
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="EPiServer.CMS" Version="12.29.0" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<EmbeddedResource Include="Resources\Translations\**\*" />
21+
</ItemGroup>
22+
</Project>

src/Web/Program.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Optimizely.TestContainers;
2+
3+
public class Program
4+
{
5+
public static void Main(string[] args) => CreateHostBuilder(args).Build().Run();
6+
7+
public static IHostBuilder CreateHostBuilder(string[] args) =>
8+
Host.CreateDefaultBuilder(args)
9+
.ConfigureCmsDefaults()
10+
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"profiles": {
3+
"Optimizely.TestContainers": {
4+
"commandName": "Project",
5+
"launchBrowser": true,
6+
"applicationUrl": "https://localhost:5000/",
7+
"environmentVariables": {
8+
"ASPNETCORE_ENVIRONMENT": "Development"
9+
}
10+
}
11+
}
12+
}

src/Web/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Empty CMS template
2+
3+
## How to run
4+
5+
Chose one of the following options to get started.
6+
7+
### Windows
8+
9+
Prerequisities
10+
- .NET SDK 8+
11+
- SQL Server 2016 Express LocalDB (or later)
12+
13+
```bash
14+
$ dotnet run
15+
````
16+
17+
### Any OS with Docker
18+
19+
Prerequisities
20+
- Docker
21+
- Enable Docker support when applying the template
22+
- Review the .env file and make changes where necessary to the Docker-related variables
23+
24+
```bash
25+
$ docker-compose up
26+
````
27+
28+
> Note that this Docker setup is just configured for local development. Follow this [guide to enable HTTPS](https://github.com/dotnet/dotnet-docker/blob/main/samples/run-aspnetcore-https-development.md).
29+
30+
#### Reclaiming Docker Image Space
31+
32+
1. Backup the App_Data/\${DB_NAME}.mdf and App_Data/\${DB_NAME}.ldf DB restoration files for safety
33+
2. Run `docker compose down --rmi all` to remove containers, networks, and images associated with the specific project instance
34+
3. In the future, run `docker compose up` anytime you want to recreate the images and containers
35+
36+
### Any OS with external database server
37+
38+
Prerequisities
39+
- .NET SDK 8+
40+
- SQL Server 2016 (or later) on a external server, e.g. Azure SQL
41+
42+
Create an empty database on the external database server and update the connection string accordingly.
43+
44+
```bash
45+
$ dotnet run
46+
````
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<languages>
3+
<language name="English" id="en"></language>
4+
</languages>

src/Web/Startup.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using EPiServer.Cms.Shell;
2+
using EPiServer.Cms.UI.AspNetIdentity;
3+
using EPiServer.Scheduler;
4+
using EPiServer.ServiceLocation;
5+
using EPiServer.Web.Routing;
6+
7+
namespace Optimizely.TestContainers;
8+
9+
public class Startup
10+
{
11+
private readonly IWebHostEnvironment _webHostingEnvironment;
12+
13+
public Startup(IWebHostEnvironment webHostingEnvironment)
14+
{
15+
_webHostingEnvironment = webHostingEnvironment;
16+
}
17+
18+
public void ConfigureServices(IServiceCollection services)
19+
{
20+
if (_webHostingEnvironment.IsDevelopment())
21+
{
22+
AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(_webHostingEnvironment.ContentRootPath, "App_Data"));
23+
24+
services.Configure<SchedulerOptions>(options => options.Enabled = false);
25+
}
26+
27+
services
28+
.AddCmsAspNetIdentity<ApplicationUser>()
29+
.AddCms()
30+
.AddAdminUserRegistration()
31+
.AddEmbeddedLocalization<Startup>();
32+
}
33+
34+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
35+
{
36+
if (env.IsDevelopment())
37+
{
38+
app.UseDeveloperExceptionPage();
39+
}
40+
41+
app.UseStaticFiles();
42+
app.UseRouting();
43+
app.UseAuthentication();
44+
app.UseAuthorization();
45+
46+
app.UseEndpoints(endpoints =>
47+
{
48+
endpoints.MapContent();
49+
});
50+
}
51+
}

0 commit comments

Comments
 (0)