Merge pull request 'feature/ci-cd' (#1) from feature/ci-cd into main
All checks were successful
Build and Deploy API / build-and-deploy (push) Successful in 3s
Build and Deploy Frontend / build-and-deploy (push) Successful in 4s

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2026-02-28 23:04:37 -06:00
10 changed files with 175 additions and 3 deletions

View File

@@ -0,0 +1,42 @@
name: Build and Deploy API
run-name: "${{ gitea.event.head_commit.message }}: Deploy API"
on:
push:
branches:
- main
paths:
- "api/**"
- ".gitea/workflows/deploy-api.yaml"
jobs:
build-and-deploy:
runs-on: debian12
container:
image: git.vxbard.net/homeburger/bard-cpp-builder:1.0
steps:
- name: Checkout code
uses: actions/checkout@v3
# needs this in order to push to the registry
- name: Validate Registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.vxbard.net \
-u ${{ secrets.REGISTRY_USERNAME }} \
--password-stdin
- name: Build image
run: |
docker build -t git.vxbard.net/homeburger/agologum-api:latest ./api
- name: Push image
run: |
docker push git.vxbard.net/homeburger/agologum-api:latest
- name: Deploy container
run: |
docker compose -f ./api/docker-compose.prod.yaml pull agologum-api
docker compose -f ./api/docker-compose.prod.yaml up -d --force-recreate agologum-api

View File

@@ -0,0 +1,42 @@
name: Build and Deploy Frontend
run-name: "${{ gitea.event.head_commit.message }}: Deploy Client"
on:
push:
branches:
- main
paths:
- "client/**"
- ".gitea/workflows/deploy-client.yaml"
jobs:
build-and-deploy:
runs-on: debian12
container:
image: git.vxbard.net/homeburger/bard-cpp-builder:1.0
steps:
- name: Checkout code
uses: actions/checkout@v3
# needs this in order to push to the registry
- name: Validate Registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.vxbard.net \
-u ${{ secrets.REGISTRY_USERNAME }} \
--password-stdin
- name: Build image
run: |
docker build -t git.vxbard.net/homeburger/agologum-client:latest ./client
- name: Push
run: |
docker push git.vxbard.net/homeburger/agologum-client:latest
- name: Deploy
run: |
docker compose -f ./client/docker-compose.prod.yaml pull agologum-client
docker compose -f ./client/docker-compose.prod.yaml up -d --force-recreate agologum-client

20
api/Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
# build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o /app/publish
# run
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:5000
COPY --from=build /app/publish ./
EXPOSE 5000
ENTRYPOINT ["dotnet", "agologum-api.dll"]

View File

@@ -1,11 +1,27 @@
using Microsoft.AspNetCore.HttpOverrides;
var builder = WebApplication.CreateBuilder(args);
// configuration for behind my nginx proxy
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor |
ForwardedHeaders.XForwardedProto;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
var app = builder.Build();
app.UseForwardedHeaders();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
@@ -14,12 +30,14 @@ if (app.Environment.IsDevelopment())
app.UseHttpsRedirection();
// below is a placeholder endpoint
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
app.MapGet("/weatherforecast", () =>
app.MapGet("api/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast

View File

@@ -5,5 +5,6 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"https_port": 443
}

View File

@@ -0,0 +1,8 @@
services:
agologum-api:
image: git.vxbard.net/homeburger/agologum-api:latest
container_name: agologum-api
restart: always
ports:
- "5000:5000"

20
client/Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
# build vue app
FROM node:current-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# serve to nginx
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -0,0 +1,9 @@
services:
agologum-client:
image: git.vxbard.net/homeburger/agologum-client:latest
container_name: agologum-client
restart: always
ports:
- "8080:80"

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
<title>homeburger place</title>
</head>
<body>
<div id="app"></div>

12
client/nginx.conf Normal file
View File

@@ -0,0 +1,12 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}