feature/ci-cd #1
42
.gitea/workflows/deploy-api.yaml
Normal file
42
.gitea/workflows/deploy-api.yaml
Normal 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
|
||||
42
.gitea/workflows/deploy-client.yaml
Normal file
42
.gitea/workflows/deploy-client.yaml
Normal 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
20
api/Dockerfile
Normal 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"]
|
||||
@@ -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
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"https_port": 443
|
||||
}
|
||||
|
||||
8
api/docker-compose.prod.yaml
Normal file
8
api/docker-compose.prod.yaml
Normal 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
20
client/Dockerfile
Normal 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;"]
|
||||
9
client/docker-compose.prod.yaml
Normal file
9
client/docker-compose.prod.yaml
Normal 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"
|
||||
|
||||
@@ -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
12
client/nginx.conf
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user