Add Kubernetes deployment: Dockerfile, CI/CD workflow, Seq logging
This commit is contained in:
48
.github/workflows/kub-deploy.yml
vendored
Normal file
48
.github/workflows/kub-deploy.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
name: Build and Deploy to Kubernetes
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- kub-stage
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: 194.5.195.53:30080
|
||||||
|
IMAGE_NAME: admin/backoffice-bff
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: docker:latest
|
||||||
|
options: --privileged
|
||||||
|
env:
|
||||||
|
HTTP_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
|
||||||
|
HTTPS_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
|
||||||
|
NO_PROXY: localhost,127.0.0.1,gitea-svc,194.5.195.53,10.0.0.0/8
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install git
|
||||||
|
run: apk add --no-cache git
|
||||||
|
|
||||||
|
- name: Clone repository
|
||||||
|
run: git clone --depth 1 --branch kub-stage http://gitea-svc:3000/admin/BackOffice.BFF.git .
|
||||||
|
|
||||||
|
- name: Start Docker daemon
|
||||||
|
run: |
|
||||||
|
mkdir -p /etc/docker
|
||||||
|
echo '{"insecure-registries": ["194.5.195.53:30080"]}' > /etc/docker/daemon.json
|
||||||
|
dockerd &
|
||||||
|
for i in $(seq 1 30); do docker info >/dev/null 2>&1 && break || sleep 2; done
|
||||||
|
|
||||||
|
- name: Build Docker Image
|
||||||
|
run: |
|
||||||
|
docker build -t $REGISTRY/$IMAGE_NAME:${{ github.sha }} \
|
||||||
|
-t $REGISTRY/$IMAGE_NAME:latest \
|
||||||
|
--build-arg HTTP_PROXY=$HTTP_PROXY \
|
||||||
|
--build-arg HTTPS_PROXY=$HTTPS_PROXY .
|
||||||
|
|
||||||
|
- name: Push to Registry
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login $REGISTRY -u admin --password-stdin
|
||||||
|
docker push $REGISTRY/$IMAGE_NAME:${{ github.sha }}
|
||||||
|
docker push $REGISTRY/$IMAGE_NAME:latest
|
||||||
25
Dockerfile
25
Dockerfile
@@ -1,15 +1,28 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY src/*.sln ./ 2>/dev/null || true
|
|
||||||
COPY src/*/*.csproj ./
|
# Copy solution and project files
|
||||||
RUN for file in *.csproj; do mkdir -p "${file%.*}" && mv "$file" "${file%.*}/"; done 2>/dev/null || true
|
COPY src/*.sln ./
|
||||||
RUN dotnet restore "BackOffice.BFF/BackOffice.BFF.csproj" || dotnet restore
|
COPY src/BackOffice.BFF.WebApi/*.csproj ./BackOffice.BFF.WebApi/
|
||||||
|
COPY src/BackOffice.BFF.Application/*.csproj ./BackOffice.BFF.Application/
|
||||||
|
COPY src/BackOffice.BFF.Infrastructure/*.csproj ./BackOffice.BFF.Infrastructure/
|
||||||
|
COPY src/BackOffice.BFF.Domain/*.csproj ./BackOffice.BFF.Domain/
|
||||||
|
COPY src/BackOffice.BFF.Contracts/*.csproj ./BackOffice.BFF.Contracts/
|
||||||
|
|
||||||
|
# Restore dependencies
|
||||||
|
RUN dotnet restore "BackOffice.BFF.WebApi/BackOffice.BFF.WebApi.csproj"
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
COPY src/ ./
|
COPY src/ ./
|
||||||
RUN dotnet publish "BackOffice.BFF/BackOffice.BFF.csproj" -c Release -o /app/publish
|
|
||||||
|
# Build and publish
|
||||||
|
RUN dotnet publish "BackOffice.BFF.WebApi/BackOffice.BFF.WebApi.csproj" -c Release -o /app/publish --no-restore
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app/publish .
|
COPY --from=build /app/publish .
|
||||||
|
|
||||||
ENV ASPNETCORE_URLS=http://+:8080
|
ENV ASPNETCORE_URLS=http://+:8080
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
ENTRYPOINT ["dotnet", "BackOffice.BFF.dll"]
|
|
||||||
|
ENTRYPOINT ["dotnet", "BackOffice.BFF.WebApi.dll"]
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
"GrpcChannelOptions": {
|
"GrpcChannelOptions": {
|
||||||
"FMSMSAddress": "https://dl.afrino.co",
|
"FMSMSAddress": "https://dl.afrino.co",
|
||||||
"CMSMSAddress": "https://cms.kbs1.ir"
|
"CMSMSAddress": "https://cms.kbs1.ir"
|
||||||
// "CMSMSAddress": "https://localhost:32846"
|
|
||||||
},
|
},
|
||||||
"Authentication": {
|
"Authentication": {
|
||||||
"Authority": "https://ids.domain.com/",
|
"Authority": "https://ids.domain.com/",
|
||||||
@@ -21,5 +20,9 @@
|
|||||||
"Kavenegar": {
|
"Kavenegar": {
|
||||||
"Sender": "1000001110100",
|
"Sender": "1000001110100",
|
||||||
"ApiKey": "497263626F32626A48685A6137524C4F78575A766E4C74694A556B79317648424964655030682B554545413D"
|
"ApiKey": "497263626F32626A48685A6137524C4F78575A766E4C74694A556B79317648424964655030682B554545413D"
|
||||||
|
},
|
||||||
|
"Seq": {
|
||||||
|
"ServerUrl": "http://seq-svc:5341",
|
||||||
|
"ApiKey": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/BackOffice.BFF.WebApi/appsettings.json.bak
Normal file
31
src/BackOffice.BFF.WebApi/appsettings.json.bak
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"JwtSecurityKey": "TvlZVx5TJaHs8e9HgUdGzhGP2CIidoI444nAj+8+g7c=",
|
||||||
|
"JwtIssuer": "https://localhost",
|
||||||
|
"JwtAudience": "https://localhost",
|
||||||
|
"JwtExpiryInDays": 365,
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"Kestrel": {
|
||||||
|
"EndpointDefaults": {
|
||||||
|
"Protocols": "Http2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GrpcChannelOptions": {
|
||||||
|
"FMSMSAddress": "https://dl.afrino.co",
|
||||||
|
"CMSMSAddress": "https://cms.kbs1.ir"
|
||||||
|
// "CMSMSAddress": "https://localhost:32846"
|
||||||
|
},
|
||||||
|
"Authentication": {
|
||||||
|
"Authority": "https://ids.domain.com/",
|
||||||
|
"Audience": "domain_api"
|
||||||
|
},
|
||||||
|
"Kavenegar": {
|
||||||
|
"Sender": "1000001110100",
|
||||||
|
"ApiKey": "497263626F32626A48685A6137524C4F78575A766E4C74694A556B79317648424964655030682B554545413D"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
,
|
||||||
|
"Seq": {
|
||||||
|
"ServerUrl": "http://seq-svc:5341",
|
||||||
|
"ApiKey": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user