Skip to content

Commit

Permalink
Release v.0.2.2
Browse files Browse the repository at this point in the history
Release v.0.2.2
  • Loading branch information
MadL1me authored Nov 23, 2022
2 parents 8bdb81b + 86a1874 commit d2fa51c
Show file tree
Hide file tree
Showing 42 changed files with 148 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TEST_PROJ_NAME:MyProject

TEMPL_DOTNET_NAME:asp-awesome-spa
TEMPL_NAME:Asp.AwesomeTemplates.Spa
NUGET_FILE:Asp.AwesomeTemplates.Spa.0.2.2.nupkg
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ MainTemplate/.vs
MainTemplate/nupkg
Level X/.vs
Level X/nupkg
.env.prod
Asp.AwesomeTemplates.Spa/nupkg
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<PackageType>Template</PackageType>
<PackageVersion>0.2.1</PackageVersion>
<PackageId>Asp.AwesomeTemplates.Main</PackageId>
<Title>ASP.NET 6 awesome templates</Title>
<PackageVersion>0.2.2</PackageVersion>
<PackageId>Asp.AwesomeTemplates.Spa</PackageId>
<Title>ASP.NET 6 awesome SPA template</Title>
<Authors>Ilya Klimenko (MadL1me)</Authors>
<Description>ASP.NET 6 Easy-to-use, modern and awesome template</Description>
<Description>ASP.NET 6 Easy-to-use, modern and awesome template.</Description>
<PackageTags>dotnet-new;templates;aspnet;ez-template;webapp;aspnet-react;aspnet-vue</PackageTags>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>true</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"EnableSwaggerSupport": {
"longName": "swagger",
"shortName": "sw"
},
"UseEfDatabase": {
"longName": "database",
"shortName": "db"
},
"UseSpaFrontendFramework": {
"longName": "frontend",
"shortName": "f"
},
"AddExampleController": {
"longName": "with-examples",
"shortName": "e"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Ilya Klimenko (MadL1me)",
"classifications": [ "Webapp", "Asp net 6" ],
"identity": "Asp.AwesomeTemplates.Main.CSharp",
"classifications": ["Webapp", "Asp net 6"],
"identity": "Asp.AwesomeTemplates.Spa.CSharp",
"name": "ASP.NET 6 Easy-to-use, modern and awesome template",
"shortName": "asp-awesome-main",
"sourceName": "Asp.AwesomeTemplate",
"shortName": "asp-awesome-spa",
"sourceName": "_AWESOME_SPA_",
"tags": {
"type": "project",
"language": "C#"
Expand All @@ -20,18 +20,19 @@
},
"EnableSwaggerSupport": {
"type": "parameter",
"displayName": "swagger",
"descriptions": "Enables swagger support",
"datatype": "bool",
"defaultValue": "true"
},
"UseSpaFrontendFramework": {
"type": "parameter",
"descriptions": "Adds selected SPA framework (React/Vue)",
"descriptions": "Adds selected SPA framework (React)",
"datatype": "choice",
"defaultValue": "None",
"defaultValue": "ReactCra",
"choices": [
{
"choice": "React",
"choice": "ReactCra",
"description": "Use React.Ts created with create-react-app and configured to be better"
},
{
Expand Down Expand Up @@ -62,29 +63,23 @@
},
"UseReact": {
"type": "computed",
"value": "(UseSpaFrontendFramework == \"React\")"
"value": "(UseSpaFrontendFramework == \"ReactCra\")"
}
},
"sources": [
{
"modifiers": [
{
"condition": "(!AddExampleController)",
"exclude": [
"Controllers/ExampleController.cs"
]
"exclude": ["_AWESOME_SPA_/Controllers/ExampleController.cs"]
},
{
"condition": "(!UseReact)",
"exclude": [
"react-ui/**"
]
"exclude": ["react-ui/**"]
},
{
"condition": "(!UsePostgreSql)",
"exclude": [
"Data/Asp.AwesomeTemplateDbContext.cs"
]
"exclude": ["_AWESOME_SPA_/Data/Asp.AwesomeTemplateDbContext.cs"]
}
]
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc;

namespace Asp.AwesomeTemplate.Controllers;
namespace _AWESOME_SPA_.Controllers;

public record ExampleUserDto
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;

namespace Asp.AwesomeTemplate.Data;
namespace _AWESOME_SPA_.Data;

public sealed class Asp.AwesomeTemplateDbContext : DbContext
{
Expand Down
20 changes: 20 additions & 0 deletions Asp.AwesomeTemplates.Spa/Template/_AWESOME_SPA_/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim AS build
WORKDIR /src
COPY ["_AWESOME_SPA_.csproj", "_AWESOME_SPA_/"]
RUN dotnet restore "_AWESOME_SPA_/_AWESOME_SPA_.csproj"
COPY . ./_AWESOME_SPA_
WORKDIR "/src/_AWESOME_SPA_"
RUN dotnet build "_AWESOME_SPA_.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "_AWESOME_SPA_.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "_AWESOME_SPA_.dll"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#endif
#if (UsePostgreSql)
using Microsoft.EntityFrameworkCore;
using Asp.AwesomeTemplate.Data;
using _AWESOME_SPA_.Data;
#endif

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -19,7 +19,7 @@

builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Asp.AwesomeTemplate API", Version = "v1" });
c.SwaggerDoc("v1", new OpenApiInfo { Title = "_AWESOME_SPA_ API", Version = "v1" });
});
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
},
"profiles": {
"Asp.AwesomeTemplate": {
"_AWESOME_SPA_": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
# Asp.AwesomeTemplate Project
# _AWESOME_SPA_ Project

## Develop

***
---

### First Run
At first, you need to create TLS certificate. You can make it with this command:

At first, you need to create TLS certificate. You can make it with this command:

```sh
dotnet dev-certs https -ep ${HOME}/.aspnet/https/Asp.AwesomeTemplate.pfx -p PASSWORD
```
dotnet dev-certs https -ep ${HOME}/.aspnet/https/_AWESOME_SPA_.pfx -p PASSWORD
```

> (You can change PASSWORD to your custom certificate password, but then you need also to change it in `docker-compose.yaml`. Because this certificate is development only, I think you can use default password)
Then, trust the certificate:
Then, trust the certificate:

```sh
dotnet dev-certs https --trust
```

Congrats, you setuped your dev certificates

***
---

### Run

Now, you can simply run your app with one command in interactive mode:

```sh
docker compose up
docker compose up
```

<!--#if(EnableSwaggerSupport) -->

Back-end Swagger docs: https://localhost:443/swagger

<!--#endif -->

<!--#if(UseReact) -->

Front-end React-app: http://localhost:3000
<!--#endif -->

<!--#endif -->
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ services:
ports:
- "8000:80"
- "443:443"
container_name: "Asp.AwesomeTemplate"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
# Development certificate for TLS
- ASPNETCORE_Kestrel__Certificates__Default__Password=PASSWORD
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Asp.AwesomeTemplate.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/_AWESOME_SPA_.pfx
volumes:
# Development certificate volume
- ~/.aspnet/https:/https:ro
//#if(UseReact)
react-ui:
build:
context: ./react-ui
context: ../react-ui
ports:
- "3000:3000"
container_name: react-ui
stdin_open: true
tty: true
environment:
Expand All @@ -36,7 +34,6 @@ services:
//#endif
//#if(UsePostgreSql)
postgres:
container_name: postgres_container
image: postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
Expand All @@ -51,15 +48,13 @@ services:
restart: unless-stopped

pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- pgadmin:/var/lib/pgadmin

ports:
- "${PGADMIN_PORT:-5050}:80"
networks:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 0 additions & 20 deletions Level X/Template/Dockerfile

This file was deleted.

62 changes: 62 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: "3"

env:
TEMPL_DIR: Asp.AwesomeTemplates.Spa

dotenv: [".env.prod"]

tasks:
remove:
dir: '{{.TEMPL_DIR}}\nupkg\'
cmds:
- pwd
- dotnet new --uninstall $TEMPL_NAME
- rm -rf *
ignore_error: true

create:
dir: "{{.TEMPL_DIR}}"
cmds:
- dotnet pack
ignore_error: true

install:
dir: '{{.TEMPL_DIR}}\nupkg\'
cmds:
- dotnet new --install $NUGET_FILE
silent: false

new:
dir: '{{.TEMPL_DIR}}\nupkg\'
cmds:
- dotnet new $TEMPL_DOTNET_NAME -o $TEST_PROJ_NAME

run-dotnet:
dir: '{{.TEMPL_DIR}}\nupkg\{{.TEST_PROJ_NAME}}'
cmds:
- dotnet run

run:
dir: '{{.TEMPL_DIR}}\nupkg\{{.TEST_PROJ_NAME}}\{{.TEST_PROJ_NAME}}'
cmds:
- docker compose up

all:
cmds:
- task: remove
- task: create
- task: install
- task: new

list:
cmds:
- dotnet new -l

info:
cmds:
- dotnet new $TEMPL_DOTNET_NAME -h

deploy:
dir: '{{.TEMPL_DIR}}\nupkg'
cmds:
- dotnet nuget push $NUGET_FILE --api-key $NUGET_APIKEY --source https://api.nuget.org/v3/index.json

0 comments on commit d2fa51c

Please sign in to comment.