diff --git a/.dockerignore b/.dockerignore index fe1152b..7da1db6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,30 +1,58 @@ -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/azds.yaml -**/bin -**/charts -**/docker-compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml -LICENSE +# Git +.git +.gitignore +.gitattributes +.gitmodules + +# CI/CD +.gitea/ +.github/ +*.yml +*.yaml + +# Documentation README.md -!**/.gitignore -!.git/HEAD -!.git/config -!.git/packed-refs -!.git/refs/heads/** \ No newline at end of file +*.md +docs/ + +# Build artifacts +**/bin/ +**/obj/ +**/out/ +**/publish/ + +# VS Code +.vscode/ +*.code-workspace + +# Visual Studio +.vs/ +*.user +*.suo +*.userosscache +*.sln.docstates + +# Testing +**/TestResults/ +**/*.trx +**/*.coverage + +# Node modules (se houver) +node_modules/ +npm-debug.log* + +# Logs +*.log + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Temporary files +*.tmp +*.temp \ No newline at end of file diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 1b8fa2e..7075907 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -16,27 +16,56 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Debug - List files + run: | + echo "=== Arquivos na raiz ===" + ls -la + echo "=== Procurando Dockerfile ===" + find . -name "Dockerfile" -o -name "dockerfile" -type f + echo "=== Estrutura do projeto ===" + tree -L 3 || find . -type d -name "OnlyOneAccessTemplate" - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . + file: ./Dockerfile platforms: linux/arm64 push: true tags: | registry.redecarneir.us/onlyoneaccesstemplate:latest registry.redecarneir.us/onlyoneaccesstemplate:${{ github.sha }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: | + type=local,src=/tmp/.buildx-cache + type=registry,ref=registry.redecarneir.us/onlyoneaccesstemplate:cache + cache-to: | + type=local,dest=/tmp/.buildx-cache-new,mode=max + type=registry,ref=registry.redecarneir.us/onlyoneaccesstemplate:cache,mode=max + build-args: | + BUILDKIT_INLINE_CACHE=1 + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: Deploy to OCI Server uses: appleboy/ssh-action@v1.0.3 with: host: 129.146.116.218 - # username: ${{ secrets.SSH_USERNAME }} - # key: ${{ secrets.SSH_PRIVATE_KEY }} - username: ubuntu + username: ${{ secrets.SSH_USERNAME }} + key: ${{ secrets.SSH_PRIVATE_KEY }} port: 22 + timeout: 60s script: | # Para qualquer container que esteja usando a porta 80 echo "=== Verificando containers na porta 80 ===" diff --git a/Dockerfile b/Dockerfile index 35c49c4..2a9a76e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,15 +9,31 @@ EXPOSE 8081 FROM --platform=linux/arm64 mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src + +# Copiar apenas arquivos de projeto primeiro (melhor cache) COPY ["OnlyOneAccessTemplate/OnlyOneAccessTemplate.csproj", "OnlyOneAccessTemplate/"] -RUN dotnet restore "./OnlyOneAccessTemplate/OnlyOneAccessTemplate.csproj" +RUN dotnet restore "./OnlyOneAccessTemplate/OnlyOneAccessTemplate.csproj" \ + --runtime linux-arm64 \ + --no-cache + +# Copiar código fonte depois do restore COPY . . WORKDIR "/src/OnlyOneAccessTemplate" -RUN dotnet build "./OnlyOneAccessTemplate.csproj" -c $BUILD_CONFIGURATION -o /app/build +RUN dotnet build "./OnlyOneAccessTemplate.csproj" \ + -c $BUILD_CONFIGURATION \ + -o /app/build \ + --runtime linux-arm64 \ + --no-restore FROM build AS publish ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "./OnlyOneAccessTemplate.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +RUN dotnet publish "./OnlyOneAccessTemplate.csproj" \ + -c $BUILD_CONFIGURATION \ + -o /app/publish \ + --runtime linux-arm64 \ + --no-restore \ + --self-contained false \ + /p:UseAppHost=false FROM base AS final WORKDIR /app diff --git a/OnlyOneAccessTemplate.sln b/OnlyOneAccessTemplate.sln index 902506b..a37ff0a 100644 --- a/OnlyOneAccessTemplate.sln +++ b/OnlyOneAccessTemplate.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pipeline", "pipeline", "{21 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{2D004DDC-10EA-47D2-911A-216449BE686C}" ProjectSection(SolutionItems) = preProject + .dockerignore = .dockerignore Dockerfile = Dockerfile EndProjectSection EndProject