Compare commits

...

12 Commits

Author SHA1 Message Date
aeedb3f5a0 fix(deps): update react to 19.2.4 to fix CVE-2025-55182, add docker workflow
Some checks failed
Build and Push Docker Images / build-and-push (push) Has been cancelled
2026-02-14 00:21:50 -03:00
4c426fb68c fix: add Dockerfile and docker-compose configuration for backend and frontend services
Some checks failed
Build and Deploy to Production / deploy (push) Has been cancelled
2025-11-22 08:01:00 -03:00
d8feffe9f4 fix: add BackendPort configuration to support dynamic backend port setting
Some checks failed
Build and Deploy to Production / deploy (push) Has been cancelled
2025-10-30 00:11:07 -03:00
f37142903a fix: configure backend port and simplify application arguments in ecosystem config 2025-10-29 23:38:50 -03:00
28be7d1e1c fix: add caching for Next.js build to improve deployment efficiency 2025-10-29 22:45:49 -03:00
4b047e0157 fix: update rsync commands in deployment workflow to improve file synchronization 2025-10-29 22:22:44 -03:00
fe03b3d4da fix: enhance file sync process in deployment workflow with detailed output and progress tracking 2025-10-29 22:14:41 -03:00
fdbb54a6b3 fix: ensure backend appsettings are included in published output and sync ecosystem files for PM2 2025-10-29 21:44:29 -03:00
0d29ba4da0 fix: update file sync paths in deployment workflow to ensure correct directory structure 2025-10-29 21:33:20 -03:00
d40cb543e9 fix: update backend project references in deployment workflow 2025-10-29 21:26:58 -03:00
41b86eccf0 fix: update backend solution references in deployment script and project descriptions 2025-10-29 21:23:08 -03:00
81e915d155 fix: update deploy workflow to improve caching and streamline environment file creation 2025-10-29 21:04:08 -03:00
10 changed files with 573 additions and 334 deletions

View File

@@ -1,93 +1,56 @@
name: Build and Deploy to Production name: Build and Push Docker Images
run-name: Deploying commit ${{ gitea.sha_short }} by @${{ gitea.actor }}
on: on:
push: push:
branches: branches: [ "main" ]
- main tags: [ "v*" ]
jobs: jobs:
deploy: build-and-push:
runs-on: website-deploy-runner runs-on: website-deploy-runner
env:
DOTNET_INSTALL_DIR: "$HOME/.dotnet"
steps: steps:
- name: Checkout Code - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup .NET 8 SDK - name: Log in to Gitea Registry
uses: actions/setup-dotnet@v4 uses: docker/login-action@v3
with: with:
dotnet-version: '8.0.x' registry: gitea.joaoloureiro.dev.br
cache: true username: ${{ secrets.GITEA_USER }}
dotnet-solution: 'backend/JoaoLoureiro.Portfolio.slnx' password: ${{ secrets.GITEA_TOKEN }}
- name: Create Backend appsettings.Production.json - name: Extract metadata (tags, labels) for Backend
run: | id: meta-backend
echo "Creating backend appsettings.Production.json file..." uses: docker/metadata-action@v5
# This creates the JSON file by mapping your Gitea secrets/vars with:
# to the structure you provided. images: gitea.joaoloureiro.dev.br/joaonloureiro/portfolio-backend
cat <<EOF > backend/appsettings.Production.json tags: |
{ type=semver,pattern={{version}}
"SmtpSettings": { type=ref,event=branch
"Host": "${{ vars.SMTP_HOST }}", type=raw,value=latest,enable={{is_default_branch}}
"Port": ${{ vars.SMTP_PORT }},
"User": "${{ secrets.SMTP_USER }}",
"Pass": "${{ secrets.SMTP_PASS }}",
"FromEmail": "${{ vars.SMTP_FROM_EMAIL }}",
"ReceivingEmail": "${{ vars.YOUR_RECEIVING_EMAIL }}"
},
"CorsOrigins": "${{ vars.FRONTEND_URL }}"
}
EOF
- name: Create Frontend .env.local file - name: Extract metadata (tags, labels) for Frontend
run: | id: meta-frontend
echo "Creating frontend .env.local file..." uses: docker/metadata-action@v5
cd frontend with:
echo "NEXT_PUBLIC_GITHUB_URL=${{ vars.NEXT_PUBLIC_GITHUB_URL }}" >> .env.local images: gitea.joaoloureiro.dev.br/joaonloureiro/portfolio-frontend
echo "NEXT_PUBLIC_LINKEDIN_URL=${{ vars.NEXT_PUBLIC_LINKEDIN_URL }}" >> .env.local tags: |
type=semver,pattern={{version}}
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Cache Dependencies - name: Build and push Backend
uses: actions/cache@v4 uses: docker/build-push-action@v5
with: with:
path: | context: ./backend
~/.nuget/packages push: true
frontend/node_modules tags: ${{ steps.meta-backend.outputs.tags }}
frontend/.next/cache labels: ${{ steps.meta-backend.outputs.labels }}
key: ${{ runner.os }}-${{ hashFiles('**/*.csproj') }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-
- name: Install Dependencies and Build - name: Build and push Frontend
run: | uses: docker/build-push-action@v5
echo "Restoring backend NuGet packages..." with:
dotnet restore backend context: ./frontend
push: true
echo "Building and publishing backend..." tags: ${{ steps.meta-frontend.outputs.tags }}
# This compiles the app and places the output in the 'publish' folder labels: ${{ steps.meta-frontend.outputs.labels }}
dotnet publish backend --configuration Release --output ./publish
echo "Installing frontend dependencies..."
cd frontend && npm install
echo "Building frontend application..."
npm run build
- name: Sync Files to Production Directory
run: |
# Sync the published backend from the './publish' directory
rsync -a --delete ./publish/ /var/www/website.joaoloureiro.dev.br/
# Sync the built frontend from the 'frontend' directory
rsync -a --delete ./frontend/.next /var/www/website.joaoloureiro.dev.br/
rsync -a --delete ./frontend/public /var/www/website.joaoloureiro.dev.br/
rsync -a ./frontend/package.json /var/www/website.joaoloureiro.dev.br/
rsync -a ./frontend/ecosystem.config.js /var/www/website.joaoloureiro.dev.br/
- name: Restart Applications with PM2
run: |
# This command on your server should handle restarting both processes
# Ensure your PM2 ecosystem file now has entries for both the .NET app
# and the Next.js app.
restart-portfolio

View File

@@ -1,3 +1,4 @@
# Ignore common files that shouldn't be in the container
**/.classpath **/.classpath
**/.dockerignore **/.dockerignore
**/.env **/.env
@@ -13,16 +14,23 @@
**/*.jfm **/*.jfm
**/azds.yaml **/azds.yaml
**/bin **/bin
**/obj
**/charts **/charts
**/docker-compose* **/docker-compose*
**/Dockerfile* **/Dockerfile*
**/node_modules **/node_modules
**/npm-debug.log **/npm-debug.log
**/obj **/.idea
**/secrets.dev.yaml **/.vs
**/values.dev.yaml **/.vscode
LICENSE **/*.user
README.md **/*.suo
**/*.userosscache
**/*.sln.docstates
# Include all .csproj files - they are needed for the build
!**/*.csproj
!**/*.sln
!**/.gitignore !**/.gitignore
!.git/HEAD !.git/HEAD
!.git/config !.git/config

47
backend/Dockerfile Normal file
View File

@@ -0,0 +1,47 @@
# Build stage - using .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Copy project files first for better layer caching
COPY ["*.sln", "./"]
COPY ["JoaoLoureiro.Portfolio.Api/*.csproj", "JoaoLoureiro.Portfolio.Api/"]
COPY ["JoaoLoureiro.Portfolio.Application/*.csproj", "JoaoLoureiro.Portfolio.Application/"]
COPY ["JoaoLoureiro.Portfolio.Domain/*.csproj", "JoaoLoureiro.Portfolio.Domain/"]
COPY ["JoaoLoureiro.Portfolio.Infrastructure/*.csproj", "JoaoLoureiro.Portfolio.Infrastructure/"]
# Restore dependencies
WORKDIR "/src/JoaoLoureiro.Portfolio.Api"
RUN dotnet restore
# Copy remaining source code
WORKDIR "/src"
COPY . .
# Build and publish
WORKDIR "/src/JoaoLoureiro.Portfolio.Api"
RUN dotnet publish -c Release -o /app/publish
# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
# curl used by docker-compose healthcheck
RUN apt-get update \
&& apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/*
# Configure logging to show in container logs
ENV ASPNETCORE_ENVIRONMENT=Development
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
ENV ASPNETCORE_URLS=http://+:3001
ENV ASPNETCORE_HTTP_PORT=3001
ENV ASPNETCORE_LOGGING__CONSOLE__DISABLECOLORS=true
# Expose the port
EXPOSE 3001
# Copy published app
COPY --from=build /app/publish .
# Entry point with enhanced logging
ENTRYPOINT ["dotnet", "JoaoLoureiro.Portfolio.Api.dll"]

View File

@@ -15,6 +15,11 @@ using System.Net;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
if (builder.Configuration["BackendPort"] is { Length: > 0 } port && ushort.TryParse(port, out _))
{
builder.WebHost.UseUrls($"http://0.0.0.0:{port}");
}
builder.Host.UseSerilog((context, config) => config.ReadFrom.Configuration(context.Configuration)); builder.Host.UseSerilog((context, config) => config.ReadFrom.Configuration(context.Configuration));
builder.Services.AddProblemDetails(); builder.Services.AddProblemDetails();

View File

@@ -2,7 +2,8 @@
"apps": [{ "apps": [{
"name": "portfolio-backend", "name": "portfolio-backend",
"script": "dotnet", "script": "dotnet",
"args": "JoaoLoureiro.Portfolio.Api/bin/Release/net8.0/JoaoLoureiro.Portfolio.Api.dll", "args": "JoaoLoureiro.Portfolio.Api.dll",
"cwd": "/var/www/website.joaoloureiro.dev.br/backend",
"instances": 1, "instances": 1,
"autorestart": true, "autorestart": true,
"watch": false, "watch": false,

47
docker-compose.yml Normal file
View File

@@ -0,0 +1,47 @@
version: '3.8'
services:
# Backend Service
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: portfolio-backend
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=http://+:80
networks:
- traefik_network
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.portfolio-backend.rule=Host(`api.yourdomain.com`)"
- "traefik.http.routers.portfolio-backend.entrypoints=websecure"
- "traefik.http.services.portfolio-backend.loadbalancer.server.port=80"
- "traefik.docker.network=traefik_network"
- "traefik.http.routers.portfolio-backend.tls.certresolver=le"
- "traefik.http.routers.portfolio-backend.middlewares=auth@docker"
# Frontend Service
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: portfolio-frontend
environment:
- NEXT_PUBLIC_API_URL=https://api.yourdomain.com
networks:
- traefik_network
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.portfolio-frontend.rule=Host(`yourdomain.com`, `www.yourdomain.com`)"
- "traefik.http.routers.portfolio-frontend.entrypoints=websecure"
- "traefik.http.services.portfolio-frontend.loadbalancer.server.port=3000"
- "traefik.docker.network=traefik_network"
- "traefik.http.routers.portfolio-frontend.tls.certresolver=le"
- "traefik.http.routers.portfolio-frontend.middlewares=auth@docker"
networks:
traefik_network:
external: true # Using your existing Traefik network

File diff suppressed because it is too large Load Diff

View File

@@ -11,11 +11,12 @@
"dependencies": { "dependencies": {
"@heroicons/react": "^2.2.0", "@heroicons/react": "^2.2.0",
"framer-motion": "^12.16.0", "framer-motion": "^12.16.0",
"next": "15.3.3", "next": "^15.5.6",
"next-auth": "^4.24.13",
"next-intl": "^4.1.0", "next-intl": "^4.1.0",
"react": "^19.0.0", "react": "^19.2.4",
"react-country-flag": "^3.1.0", "react-country-flag": "^3.1.0",
"react-dom": "^19.0.0", "react-dom": "^19.2.4",
"react-hot-toast": "^2.5.2", "react-hot-toast": "^2.5.2",
"react-icons": "^5.5.0", "react-icons": "^5.5.0",
"react-type-animation": "^3.2.0" "react-type-animation": "^3.2.0"
@@ -31,4 +32,4 @@
"tailwindcss": "^4", "tailwindcss": "^4",
"typescript": "^5" "typescript": "^5"
} }
} }

View File

@@ -23,7 +23,7 @@
"about": { "about": {
"title": "About Me", "title": "About Me",
"paragraph1": "I am a Full Stack Developer driven by a passion for building, automating, and scaling robust applications. My journey into technology began with a desire to understand how complex systems work, and it has evolved into a career dedicated to crafting elegant, high-performance solutions.", "paragraph1": "I am a Full Stack Developer driven by a passion for building, automating, and scaling robust applications. My journey into technology began with a desire to understand how complex systems work, and it has evolved into a career dedicated to crafting elegant, high-performance solutions.",
"paragraph2": "With a strong foundation in the .NET and JavaScript ecosystems, I specialize in creating modern web applications using technologies like .NET, Angular, Next.js, React, and Node.js. However, my curiosity extends beyond code. As you can see from my Homelab project, I am deeply engaged with the full development lifecycle, including CI/CD, containerization with Docker, and infrastructure management.", "paragraph2": "With a strong foundation in the .NET and JavaScript ecosystems, I specialize in creating modern web applications using technologies like .NET, Angular, Next.js, and React. However, my curiosity extends beyond code. As you can see from my Homelab project, I am deeply engaged with the full development lifecycle, including CI/CD, containerization with Docker, and infrastructure management.",
"paragraph3": "I thrive on challenges and am constantly exploring new technologies, from database administration with MariaDB and Redis to workflow automation with N8N and message queuing with RabbitMQ. This hands-on approach to DevOps and self-hosting allows me to build not just features, but resilient and scalable systems." "paragraph3": "I thrive on challenges and am constantly exploring new technologies, from database administration with MariaDB and Redis to workflow automation with N8N and message queuing with RabbitMQ. This hands-on approach to DevOps and self-hosting allows me to build not just features, but resilient and scalable systems."
}, },
"skills": { "skills": {
@@ -36,14 +36,14 @@
"projects": { "projects": {
"title": "Projects I've Built", "title": "Projects I've Built",
"project_1_title": "Personal Portfolio", "project_1_title": "Personal Portfolio",
"project_1_description": "The very site you are on now! A full-stack application built with Next.js, Tailwind CSS, and a Node.js backend to showcase my work and skills.", "project_1_description": "The very site you are on now! A full-stack application built with Next.js, Tailwind CSS, and a .NET 8 backend to showcase my work and skills.",
"project_1_details": "This portfolio is a full-stack application designed to showcase my skills and projects. It features a modern, decoupled architecture with a Next.js frontend and a Node.js backend. The project is automatically deployed via Gitea Actions, with PM2 managing the processes on the server for zero-downtime restarts.", "project_1_details": "This portfolio is a full-stack application designed to showcase my skills and projects. It features a modern, decoupled architecture with a Next.js frontend and a .NET 8 backend. The project is automatically deployed via Gitea Actions, with PM2 managing the processes on the server for zero-downtime restarts.",
"project_1_features_title": "Key Features:", "project_1_features_title": "Key Features:",
"project_1_features": [ "project_1_features": [
"**Internationalization (i18n):** Fully translated in English and Portuguese with `next-intl`.", "**Internationalization (i18n):** Fully translated in English and Portuguese with `next-intl`.",
"**Responsive Design:** Optimized for all devices using Tailwind CSS.", "**Responsive Design:** Optimized for all devices using Tailwind CSS.",
"**Interactive UI:** Includes a theme switcher (dark/light mode) and toast notifications.", "**Interactive UI:** Includes a theme switcher (dark/light mode) and toast notifications.",
"**Robust Backend:** An Express.js server handles contact form submissions securely using Nodemailer." "**Robust Backend:** A .NET 8 API handles contact form submissions securely."
], ],
"project_2_title": "Homelab & DevOps Playground", "project_2_title": "Homelab & DevOps Playground",
"project_2_description": "A self-hosted infrastructure running on Proxmox, showcasing a wide range of DevOps and backend services.", "project_2_description": "A self-hosted infrastructure running on Proxmox, showcasing a wide range of DevOps and backend services.",

View File

@@ -23,7 +23,7 @@
"about": { "about": {
"title": "Sobre Mim", "title": "Sobre Mim",
"paragraph1": "Sou um Desenvolvedor Full Stack movido pela paixão de construir, automatizar e escalar aplicações robustas. Minha jornada na tecnologia começou com o desejo de entender como sistemas complexos funcionam e evoluiu para uma carreira dedicada a criar soluções elegantes e de alta performance.", "paragraph1": "Sou um Desenvolvedor Full Stack movido pela paixão de construir, automatizar e escalar aplicações robustas. Minha jornada na tecnologia começou com o desejo de entender como sistemas complexos funcionam e evoluiu para uma carreira dedicada a criar soluções elegantes e de alta performance.",
"paragraph2": "Com uma base sólida nos ecossistemas .NET e JavaScript, minha especialidade é a criação de aplicações web modernas utilizando tecnologias como .NET, Angular, Next.js, React e Node.js. No entanto, minha curiosidade vai além do código. Como você pode ver no meu projeto de Homelab, estou profundamente envolvido com todo o ciclo de vida de desenvolvimento, incluindo CI/CD, conteinerização com Docker e gerenciamento de infraestrutura.", "paragraph2": "Com uma base sólida nos ecossistemas .NET e JavaScript, minha especialidade é a criação de aplicações web modernas utilizando tecnologias como .NET, Angular, Next.js e React. No entanto, minha curiosidade vai além do código. Como você pode ver no meu projeto de Homelab, estou profundamente envolvido com todo o ciclo de vida de desenvolvimento, incluindo CI/CD, conteinerização com Docker e gerenciamento de infraestrutura.",
"paragraph3": "Eu prospero em desafios e estou constantemente explorando novas tecnologias, desde a administração de bancos de dados com MariaDB e Redis até a automação de fluxos de trabalho com N8N e filas de mensagens com RabbitMQ. Essa abordagem prática em DevOps e auto-hospedagem me permite construir não apenas funcionalidades, mas sistemas resilientes e escaláveis." "paragraph3": "Eu prospero em desafios e estou constantemente explorando novas tecnologias, desde a administração de bancos de dados com MariaDB e Redis até a automação de fluxos de trabalho com N8N e filas de mensagens com RabbitMQ. Essa abordagem prática em DevOps e auto-hospedagem me permite construir não apenas funcionalidades, mas sistemas resilientes e escaláveis."
}, },
"skills": { "skills": {
@@ -36,14 +36,14 @@
"projects": { "projects": {
"title": "Projetos que Construí", "title": "Projetos que Construí",
"project_1_title": "Portfólio Pessoal", "project_1_title": "Portfólio Pessoal",
"project_1_description": "O próprio site em que você está agora! Uma aplicação full-stack construída com Next.js, Tailwind CSS e um backend Node.js para exibir meu trabalho e habilidades.", "project_1_description": "O próprio site em que você está agora! Uma aplicação full-stack construída com Next.js, Tailwind CSS e um backend .NET 8 para exibir meu trabalho e habilidades.",
"project_1_details": "Este portfólio é uma aplicação full-stack projetada para mostrar minhas habilidades e projetos. Possui uma arquitetura moderna e desacoplada, com um frontend em Next.js e um backend em Node.js. O projeto é implantado automaticamente via Gitea Actions, com o PM2 gerenciando os processos no servidor para reinicializações sem tempo de inatividade.", "project_1_details": "Este portfólio é uma aplicação full-stack projetada para mostrar minhas habilidades e projetos. Possui uma arquitetura moderna e desacoplada, com um frontend em Next.js e um backend em .NET 8. O projeto é implantado automaticamente via Gitea Actions, com o PM2 gerenciando os processos no servidor para reinicializações sem tempo de inatividade.",
"project_1_features_title": "Principais Características:", "project_1_features_title": "Principais Características:",
"project_1_features": [ "project_1_features": [
"**Internacionalização (i18n):** Totalmente traduzido para inglês e português com `next-intl`.", "**Internacionalização (i18n):** Totalmente traduzido para inglês e português com `next-intl`.",
"**Design Responsivo:** Otimizado para todos os dispositivos usando Tailwind CSS.", "**Design Responsivo:** Otimizado para todos os dispositivos usando Tailwind CSS.",
"**UI Interativa:** Inclui um seletor de tema (modo claro/escuro) e notificações para feedback de formulários.", "**UI Interativa:** Inclui um seletor de tema (modo claro/escuro) e notificações para feedback de formulários.",
"**Backend Robusto:** Um servidor Express.js lida com os envios do formulário de contato de forma segura usando o Nodemailer." "**Backend Robusto:** Uma API .NET 8 lida com os envios do formulário de contato de forma segura usando o MailKit."
], ],
"project_2_title": "Homelab & Playground DevOps", "project_2_title": "Homelab & Playground DevOps",
"project_2_description": "Uma infraestrutura auto-hospedada rodando em Proxmox, demonstrando uma vasta gama de serviços de DevOps e backend.", "project_2_description": "Uma infraestrutura auto-hospedada rodando em Proxmox, demonstrando uma vasta gama de serviços de DevOps e backend.",