build containers
This commit is contained in:
116
.gitea/workflows/buildContainers.yml
Normal file
116
.gitea/workflows/buildContainers.yml
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
|
||||||
|
name: Build Docker Images
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- ddd-refactor
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: build-${{ github.ref }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup .NET 8
|
||||||
|
uses: https://github.com/actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: 8.0.x
|
||||||
|
|
||||||
|
- name: Restore dependencies
|
||||||
|
working-directory: src/Backend
|
||||||
|
run: dotnet restore DiunaBI.sln
|
||||||
|
|
||||||
|
- name: Build solution and prepare plugins
|
||||||
|
working-directory: src/Backend
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
dotnet build DiunaBI.sln --configuration Release
|
||||||
|
dotnet build DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj --configuration Release
|
||||||
|
mkdir -p DiunaBI.Tests/bin/Release/net8.0/Plugins
|
||||||
|
cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Plugins.Morska.dll DiunaBI.Tests/bin/Release/net8.0/Plugins/ || true
|
||||||
|
ls -la DiunaBI.Tests/bin/Release/net8.0/Plugins/ || true
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
working-directory: src/Backend
|
||||||
|
run: |
|
||||||
|
dotnet test DiunaBI.Tests/DiunaBI.Tests.csproj \
|
||||||
|
--configuration Release \
|
||||||
|
--no-restore \
|
||||||
|
--logger "trx;LogFileName=test-results.trx" \
|
||||||
|
--collect:"XPlat Code Coverage" \
|
||||||
|
--filter "Category!=LocalOnly" || true
|
||||||
|
|
||||||
|
- name: Publish Test Results
|
||||||
|
uses: https://github.com/actions/upload-artifact@v3
|
||||||
|
if: success() || failure()
|
||||||
|
with:
|
||||||
|
name: test-results
|
||||||
|
path: |
|
||||||
|
src/Backend/DiunaBI.Tests/TestResults/*.trx
|
||||||
|
src/Backend/DiunaBI.Tests/TestResults/**/coverage.cobertura.xml
|
||||||
|
retention-days: 7
|
||||||
|
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
if: success() || failure()
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Gitea Container Registry
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login code.bim-it.pl -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
|
|
||||||
|
- name: Build and push API image
|
||||||
|
working-directory: src/Backend
|
||||||
|
run: |
|
||||||
|
docker buildx build \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--label "org.opencontainers.image.source=https://code.bim-it.pl/mz/DiunaBI" \
|
||||||
|
-f DiunaBI.API/Dockerfile \
|
||||||
|
-t code.bim-it.pl/mz/diunabi-api:latest \
|
||||||
|
-t code.bim-it.pl/mz/diunabi-api:build-${{ github.run_id }} \
|
||||||
|
--push \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Build and push UI image
|
||||||
|
working-directory: src/Backend
|
||||||
|
run: |
|
||||||
|
docker buildx build \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--label "org.opencontainers.image.source=https://code.bim-it.pl/mz/DiunaBI" \
|
||||||
|
-f DiunaBI.UI.Web/Dockerfile \
|
||||||
|
-t code.bim-it.pl/mz/diunabi-ui:latest \
|
||||||
|
-t code.bim-it.pl/mz/diunabi-ui:build-${{ github.run_id }} \
|
||||||
|
--push \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Output build info
|
||||||
|
run: |
|
||||||
|
echo "## 🐳 Docker Images Built" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Build ID:** ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "### Images pushed:" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```bash' >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "# Latest (for release)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/diunabi-api:latest" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/diunabi-ui:latest" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "# Specific build (for rollback)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/diunabi-api:build-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/diunabi-ui:build-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
58
src/Backend/DiunaBI.API/Dockerfile
Normal file
58
src/Backend/DiunaBI.API/Dockerfile
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
# Stage 1: Build
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
WORKDIR /src/Backend
|
||||||
|
|
||||||
|
# Copy solution and all project files for restore
|
||||||
|
COPY DiunaBI.sln ./
|
||||||
|
COPY DiunaBI.API/DiunaBI.API.csproj DiunaBI.API/
|
||||||
|
COPY DiunaBI.Domain/DiunaBI.Domain.csproj DiunaBI.Domain/
|
||||||
|
COPY DiunaBI.Application/DiunaBI.Application.csproj DiunaBI.Application/
|
||||||
|
COPY DiunaBI.Infrastructure/DiunaBI.Infrastructure.csproj DiunaBI.Infrastructure/
|
||||||
|
COPY DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj DiunaBI.Plugins.Morska/
|
||||||
|
|
||||||
|
# Restore dependencies
|
||||||
|
RUN dotnet restore DiunaBI.API/DiunaBI.API.csproj
|
||||||
|
|
||||||
|
# Copy all source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build plugin first
|
||||||
|
WORKDIR /src/Backend/DiunaBI.Plugins.Morska
|
||||||
|
RUN dotnet build -c Release
|
||||||
|
|
||||||
|
# Build and publish API
|
||||||
|
WORKDIR /src/Backend/DiunaBI.API
|
||||||
|
RUN dotnet publish -c Release -o /app/publish --no-restore
|
||||||
|
|
||||||
|
# Copy plugin DLL to publish output
|
||||||
|
RUN mkdir -p /app/publish/Plugins && \
|
||||||
|
cp /src/Backend/DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Plugins.Morska.dll /app/publish/Plugins/
|
||||||
|
|
||||||
|
# Stage 2: Runtime
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install wget for health checks
|
||||||
|
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Set timezone
|
||||||
|
ENV TZ=Europe/Warsaw
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
# Copy published files
|
||||||
|
COPY --from=build /app/publish .
|
||||||
|
|
||||||
|
# Set environment variables (can be overridden)
|
||||||
|
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||||
|
ENV ASPNETCORE_URLS=http://0.0.0.0:7142
|
||||||
|
|
||||||
|
# Expose port (default, can be remapped in docker-compose)
|
||||||
|
EXPOSE 7142
|
||||||
|
|
||||||
|
# Health check
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||||
|
CMD wget --no-verbose --tries=1 --spider http://localhost:7142/health || exit 1
|
||||||
|
|
||||||
|
# Run the application
|
||||||
|
ENTRYPOINT ["dotnet", "DiunaBI.API.dll"]
|
||||||
48
src/Backend/DiunaBI.UI.Web/Dockerfile
Normal file
48
src/Backend/DiunaBI.UI.Web/Dockerfile
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Stage 1: Build
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
WORKDIR /src/Backend
|
||||||
|
|
||||||
|
# Copy solution and all project files for restore
|
||||||
|
COPY DiunaBI.sln ./
|
||||||
|
COPY DiunaBI.UI.Web/DiunaBI.UI.Web.csproj DiunaBI.UI.Web/
|
||||||
|
COPY DiunaBI.UI.Shared/DiunaBI.UI.Shared.csproj DiunaBI.UI.Shared/
|
||||||
|
COPY DiunaBI.Domain/DiunaBI.Domain.csproj DiunaBI.Domain/
|
||||||
|
COPY DiunaBI.Application/DiunaBI.Application.csproj DiunaBI.Application/
|
||||||
|
|
||||||
|
# Restore dependencies
|
||||||
|
RUN dotnet restore DiunaBI.UI.Web/DiunaBI.UI.Web.csproj
|
||||||
|
|
||||||
|
# Copy all source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build and publish
|
||||||
|
WORKDIR /src/Backend/DiunaBI.UI.Web
|
||||||
|
RUN dotnet publish -c Release -o /app/publish --no-restore
|
||||||
|
|
||||||
|
# Stage 2: Runtime
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install wget for health checks
|
||||||
|
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Set timezone
|
||||||
|
ENV TZ=Europe/Warsaw
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
# Copy published files
|
||||||
|
COPY --from=build /app/publish .
|
||||||
|
|
||||||
|
# Set environment variables (can be overridden)
|
||||||
|
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||||
|
ENV ASPNETCORE_URLS=http://0.0.0.0:7143
|
||||||
|
|
||||||
|
# Expose port (default, can be remapped in docker-compose)
|
||||||
|
EXPOSE 7143
|
||||||
|
|
||||||
|
# Health check
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||||
|
CMD wget --no-verbose --tries=1 --spider http://localhost:7143/health || exit 1
|
||||||
|
|
||||||
|
# Run the application
|
||||||
|
ENTRYPOINT ["dotnet", "DiunaBI.UI.Web.dll"]
|
||||||
Reference in New Issue
Block a user