Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upk8s #151

Closed
wants to merge 2 commits into from
Closed

Upk8s #151

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ bundle.js
appsettings.Production.json
appsettings.Development.json
*.log
*.pubxml
*.pubxml
.DS_Store
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY Kahla.Server/Kahla.Server.csproj Kahla.Server/
COPY Kahla.SDK/Kahla.SDK.csproj Kahla.SDK/
RUN dotnet restore "Kahla.Server/Kahla.Server.csproj"
COPY . .
WORKDIR "/src/Kahla.Server"
RUN dotnet build "Kahla.Server.csproj" -c Release -o /app/build

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Kahla.Server.dll"]
Binary file added Kahla.Server/.DS_Store
Binary file not shown.
20 changes: 20 additions & 0 deletions Kahla.Server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY Kahla.Server/Kahla.Server.csproj Kahla.Server/
COPY Kahla.SDK/Kahla.SDK.csproj Kahla.SDK/
RUN dotnet restore "Kahla.Server/Kahla.Server.csproj"
COPY . .
WORKDIR "/src/Kahla.Server"
RUN dotnet build "Kahla.Server.csproj" -c Release -o /app/build

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Kahla.Server.dll"]
1 change: 1 addition & 0 deletions Kahla.Server/Kahla.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/AiursoftWeb/Kahla.git</RepositoryUrl>
<DockerComposeProjectPath>../docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 14 additions & 1 deletion Kahla.Server/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Aiursoft.Pylon;
using Aiursoft.Pylon.Middlewares;
using Kahla.SDK.Models;
using Kahla.Server.Data;
using Kahla.Server.Middlewares;
Expand Down Expand Up @@ -57,7 +58,19 @@ public void ConfigureServices(IServiceCollection services)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseMiddleware<HandleKahlaOptionsMiddleware>();
app.UseAiurAPIHandler(env.IsDevelopment());

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseMiddleware<HandleRobotsMiddleware>();
app.UseMiddleware<UserFriendlyServerExceptionMiddeware>();
app.UseMiddleware<UserFriendlyNotFoundMiddeware>();
}

app.UseAiursoftDefault();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Kahla.Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
],
"ConnectionStrings": {
"DatabaseConnection": "Server=(localdb)\\mssqllocaldb;Database=KahlaLocal;Trusted_Connection=True;MultipleActiveResultSets=true"
"DatabaseConnection": "Data Source=192.168.1.118;Initial Catalog=KahlaLocal;User ID=sa;Password=Xr111900$$$;"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this may cause my environment stop working.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change at my working. working end I'm revert it.

},
"EmailAppDomain": "https://web.kahla.app",
"MailUser": "[email protected]",
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
staging:
docker build . -t aiursoftweb/kahla-server-api:staging
docker push aiursoftweb/kahla-server-api:staging

production:
docker build . -t aiursoftweb/kahla-server-api:production
docker push aiursoftweb/kahla-server-api:production
57 changes: 57 additions & 0 deletions k8s-deploy-production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kahla-deployment
namespace: aiursoft-kahla-production
labels:
name: kahla
spec:
replicas: 1
selector:
matchLabels:
name: kahla
template:
metadata:
labels:
name: kahla
spec:
containers:
- name: kahla-pod
image: aiursoftweb/kahla-server-api:production
ports:
- containerPort: 80
imagePullPolicy: Always

---

kind: Service
apiVersion: v1
metadata:
name: kahla-service
namespace: aiursoft-kahla-production
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
selector:
name: kahla
---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kahla-ingress
namespace: aiursoft-kahla-production
spec:
rules:
- host: server.kahla.app
http:
paths:
- path: /
backend:
serviceName: kahla-service
servicePort: 80

---
57 changes: 57 additions & 0 deletions k8s-deploy-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kahla-deployment
namespace: aiursoft-kahla-staging
labels:
name: kahla
spec:
replicas: 1
selector:
matchLabels:
name: kahla
template:
metadata:
labels:
name: kahla
spec:
containers:
- name: kahla-pod
image: aiursoftweb/kahla-server-api:staging
ports:
- containerPort: 80
imagePullPolicy: Always

---

kind: Service
apiVersion: v1
metadata:
name: kahla-service
namespace: aiursoft-kahla-staging
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
selector:
name: kahla
---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kahla-ingress
namespace: aiursoft-kahla-staging
spec:
rules:
- host: server.kahla.app
http:
paths:
- path: /
backend:
serviceName: kahla-service
servicePort: 80

---