mirror of
https://github.com/MvDevsUnion/WPetition.git
synced 2026-05-05 14:33:06 +00:00
ci
This commit is contained in:
23
.build/dev/app.Dockerfile
Normal file
23
.build/dev/app.Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
||||||
|
USER $APP_UID
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 9755
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Debug
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["Submission.Api/Submission.Api.csproj", "Submission.Api/"]
|
||||||
|
RUN dotnet restore "Submission.Api/Submission.Api.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/Submission.Api"
|
||||||
|
RUN dotnet build "./Submission.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Debug
|
||||||
|
RUN dotnet publish "./Submission.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "Submission.Api.dll"]
|
||||||
32
.build/prod/app.Dockerfile
Normal file
32
.build/prod/app.Dockerfile
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
||||||
|
USER $APP_UID
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 9755
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
ARG CI_COMMIT_SHORT_SHA
|
||||||
|
ARG CI_COMMIT_SHA
|
||||||
|
ARG CI_COMMIT_BRANCH
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["Submission.Api/Submission.Api.csproj", "Submission.Api/"]
|
||||||
|
RUN dotnet restore "Submission.Api/Submission.Api.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/Submission.Api"
|
||||||
|
RUN dotnet build "./Submission.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "./Submission.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
ARG CI_COMMIT_SHORT_SHA
|
||||||
|
ARG CI_COMMIT_SHA
|
||||||
|
ARG CI_COMMIT_BRANCH
|
||||||
|
ENV CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA
|
||||||
|
ENV CI_COMMIT_SHA=$CI_COMMIT_SHA
|
||||||
|
ENV CI_COMMIT_BRANCH=$CI_COMMIT_BRANCH
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "Submission.Api.dll"]
|
||||||
16
.build/prod/compose.yml
Normal file
16
.build/prod/compose.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
services:
|
||||||
|
api:
|
||||||
|
build:
|
||||||
|
context: ../../
|
||||||
|
dockerfile: .build/prod/app.Dockerfile
|
||||||
|
hostname: api
|
||||||
|
image: git.shihaam.dev/mvdevsunion/wpetition/api
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: ../../
|
||||||
|
dockerfile: .build/prod/frontend.Dockerfile
|
||||||
|
hostname: frontend
|
||||||
|
image: git.shihaam.dev/mvdevsunion/wpetition/frontend
|
||||||
|
depends_on:
|
||||||
|
- api
|
||||||
12
.build/prod/frontend.Dockerfile
Normal file
12
.build/prod/frontend.Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Copy custom nginx configuration
|
||||||
|
COPY .build/prod/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
# Copy static frontend files
|
||||||
|
COPY Frontend/ /usr/share/nginx/html/
|
||||||
|
|
||||||
|
# Expose port 80
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
53
.build/prod/nginx.conf
Normal file
53
.build/prod/nginx.conf
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
# Gzip compression
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
# Serve static frontend files
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Proxy API requests to the backend
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://api:9755/api/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optional: Proxy Swagger if you want it accessible
|
||||||
|
location /swagger {
|
||||||
|
proxy_pass http://api:9755/swagger;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
.gitea/workflows/docker-build.yml
Normal file
45
.gitea/workflows/docker-build.yml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
name: Build and Push Docker Images
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
name: Build and Push Docker Images
|
||||||
|
runs-on: builder
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ${{ vars.DOCKER_REGISTRY_URL }}
|
||||||
|
username: ${{ vars.DOCKER_REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push docker images
|
||||||
|
working-directory: .build/prod
|
||||||
|
run: docker compose --progress build --push
|
||||||
|
|
||||||
|
|
||||||
|
- name: Deploy production
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
run: |
|
||||||
|
ssh root@10.0.1.39 -t "cd /mnt && \
|
||||||
|
docker compose --progress plain pull && \
|
||||||
|
docker compose --progress plain down && \
|
||||||
|
docker compose --progress plain up -d"
|
||||||
|
|
||||||
|
- name: Clean up dangling images
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
run: ssh root@10.0.1.39 -t "docker image prune -f"
|
||||||
19
.github/workflows/mirror-to-sargitea.yml
vendored
Normal file
19
.github/workflows/mirror-to-sargitea.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: Sync Gitea Mirror on Push
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-mirror:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Trigger Gitea Mirror Sync
|
||||||
|
run: |
|
||||||
|
curl -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.SAR_GITEA_TOKEN }}" \
|
||||||
|
-H "Accept: application/json" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
https://git.shihaam.dev/api/v1/repos/${{ vars.SAR_GITEA_REPO_OWNER }}/${{ vars.SAR_GITEA_REPO_NAME }}/mirror-sync
|
||||||
Reference in New Issue
Block a user