HodorNV / ALOps

ALOps
55 stars 24 forks source link

ALOpsDockerWait@1 - Copy Working folder to Docker Container - Exclude .git folder #724

Closed Arthurvdv closed 1 month ago

Arthurvdv commented 4 months ago

Is your feature request related to a problem? Please describe. For some projects the duration of the ALOpsDockerWait@1 step takes 8 minutes and 30 seconds, where the Copy Working folder to Docker Container action takes up almost all the time (8 minutes).

The reason for this is that it compress and copies over 2,2 GB from the Build.SourcesDirectory/System.DefaultWorkingDirectory to the container. Over time on a number of projects the .git folder has increased to a significant size. In this example the .git folder is a whopping 2,1 GB for a project of 80 MB.

Describe the solution you'd like In our pipelines we don't use any git commands inside the container itself. With this in mind, it would be helpful if we could exclude the .git folder from this step.

Describe alternatives you've considered

Additional context

2024-02-21T17:16:39.0026695Z ##[section]Starting: Wait for Docker Container
2024-02-21T17:16:39.0204970Z ==============================================================================
2024-02-21T17:16:39.0205101Z Task         : ALOps Docker Wait
2024-02-21T17:16:39.0205176Z Description  : Wait until the Business Central container is started
2024-02-21T17:16:39.0205257Z Version      : 1.462.5150
2024-02-21T17:16:39.0205321Z Author       : Hodor
2024-02-21T17:16:39.0205449Z Help         : Wait until the Business Central container is started.
2024-02-21T17:16:39.0205543Z ==============================================================================
2024-02-21T17:16:39.6190481Z *** Validate configuration
2024-02-21T17:16:39.6521416Z *** Task Inputs:
2024-02-21T17:16:39.6562559Z 
2024-02-21T17:16:39.6643870Z name                 value                 
2024-02-21T17:16:39.6647416Z ----                 -----                 
2024-02-21T17:16:39.6650540Z fixed_tag                                  
2024-02-21T17:16:39.6653536Z search_string        Ready for connections!
2024-02-21T17:16:39.6656524Z warning_string                             
2024-02-21T17:16:39.6659562Z error_string                               
2024-02-21T17:16:39.6662624Z setup_working_folder True                  
2024-02-21T17:16:39.6665685Z usecompression       True                  
2024-02-21T17:16:39.6668782Z printlogs            True                  
2024-02-21T17:16:39.6669676Z 
2024-02-21T17:16:39.6688918Z 
2024-02-21T17:16:39.6695957Z 
2024-02-21T17:16:39.6845070Z *** For documentation, please visit   : https://www.alops.be/documentation
2024-02-21T17:16:39.6850962Z 
2024-02-21T17:16:39.8834188Z *** ALOps License:
2024-02-21T17:16:39.8861439Z   * Licensed To: Van Roey (Collection License)
2024-02-21T17:16:39.8865860Z 
2024-02-21T17:16:39.8973232Z *** Importing required PS-Functions
2024-02-21T17:16:40.0294442Z *** Waiting for Docker Container Log Entry: Ready for connections!
2024-02-21T17:16:41.1215145Z Initializing...
2024-02-21T17:16:41.1236570Z Starting Container
2024-02-21T17:16:41.1252009Z Hostname is e4ef55c1c920
2024-02-21T17:16:41.1268149Z PublicDnsName is e4ef55c1c920
2024-02-21T17:16:41.1281338Z Using NavUserPassword Authentication
2024-02-21T17:16:41.1294357Z Starting Local SQL Server
2024-02-21T17:16:41.1305758Z Starting Internet Information Server
2024-02-21T17:16:41.1317233Z Creating Self Signed Certificate
2024-02-21T17:16:41.1330185Z Self Signed Certificate Thumbprint 3DFFCB6890045F7B3B5E671F40215187F12FD3FA
2024-02-21T17:16:41.1343395Z DNS identity e4ef55c1c920
2024-02-21T17:16:41.1357500Z Modifying Service Tier Config File with Instance Specific Settings
2024-02-21T17:16:42.2720152Z Modifying Service Tier Config File with settings from environment variable
2024-02-21T17:16:42.2730479Z Setting EnableTaskScheduler to false
2024-02-21T17:16:42.2740105Z Starting Service Tier
2024-02-21T17:17:05.6505187Z CertificateThumprint 3DFFCB6890045F7B3B5E671F40215187F12FD3FA
2024-02-21T17:17:05.6524077Z Registering event sources
2024-02-21T17:17:05.6537094Z Creating DotNetCore Web Server Instance
2024-02-21T17:17:05.6552276Z Using application pool name: BC
2024-02-21T17:17:05.6567576Z Using default container name: NavWebApplicationContainer
2024-02-21T17:17:05.6582588Z Copy files to WWW root C:\inetpub\wwwroot\BC
2024-02-21T17:17:07.9246342Z Create the application pool BC
2024-02-21T17:17:09.0425971Z Create website: NavWebApplicationContainer with SSL
2024-02-21T17:17:10.1757662Z Update configuration: navsettings.json
2024-02-21T17:17:10.1771614Z Done Configuring Web Client
2024-02-21T17:17:10.1784064Z Enabling Financials User Experience
2024-02-21T17:17:10.1797431Z Creating http download site
2024-02-21T17:17:10.1810783Z Setting SA Password and enabling SA
2024-02-21T17:17:10.1822689Z Creating admin as SQL User and add to sysadmin
2024-02-21T17:17:13.4951119Z Creating SUPER user
2024-02-21T17:17:14.6030296Z Container IP Address: 172.30.65.92
2024-02-21T17:17:14.6042081Z Container Hostname  : e4ef55c1c920
2024-02-21T17:17:14.6054665Z Container Dns Name  : e4ef55c1c920
2024-02-21T17:17:14.6065706Z Web Client          : https://e4ef55c1c920/BC/
2024-02-21T17:17:14.6076397Z Admin Username      : admin
2024-02-21T17:17:14.6087390Z Admin Password      : Cuwu6149
2024-02-21T17:17:14.6099677Z Dev. Server         : https://e4ef55c1c920
2024-02-21T17:17:14.6109906Z Dev. ServerInstance : BC
2024-02-21T17:17:14.6113544Z 
2024-02-21T17:17:14.6123486Z Files:
2024-02-21T17:17:14.6132751Z http://e4ef55c1c920:8080/ALLanguage.vsix
2024-02-21T17:17:14.6142103Z http://e4ef55c1c920:8080/certificate.cer
2024-02-21T17:17:14.6145417Z 
2024-02-21T17:17:14.6155279Z Container Total Physical Memory is 24.0Gb
2024-02-21T17:17:14.6163863Z Container Free Physical Memory is 18.1Gb
2024-02-21T17:17:14.6167195Z 
2024-02-21T17:17:14.6175889Z Initialization took 36 seconds
2024-02-21T17:17:14.6185600Z Ready for connections!
2024-02-21T17:17:14.6194140Z Starting EventLog Monitor
2024-02-21T17:17:14.6203919Z Monitoring EventSources from EventLog[Application]:
2024-02-21T17:17:14.6212570Z - MicrosoftDynamicsNAVClientClientService
2024-02-21T17:17:14.6221039Z - MicrosoftDynamicsNAVClientWebClient
2024-02-21T17:17:14.6230724Z - MicrosoftDynamicsNavServer$BC
2024-02-21T17:17:14.6239248Z - MSSQL$SQLEXPRESS
2024-02-21T17:17:14.6242580Z 
2024-02-21T17:17:14.6704707Z 
2024-02-21T17:17:14.8397860Z *** BC Container Parameters:
2024-02-21T17:17:14.8412111Z 
2024-02-21T17:17:14.8424976Z *** Mapping container info to global variables:
2024-02-21T17:17:14.8457701Z *** Set Pipeline variable $(ALOPS_DOCKER_CONTAINER_ID) = 'e4ef55c1c920b38733406ae82e5efd4e09a73ff27738916fa5babf0874afbbc1'
2024-02-21T17:17:14.8554000Z *** Set Pipeline variable $(ALOPS_DOCKER_IPADDRESS) = '172.30.65.92'
2024-02-21T17:17:14.8583188Z *** Set Pipeline variable $(ALOPS_DOCKER_HOSTNAME) = 'e4ef55c1c920'
2024-02-21T17:17:14.8612234Z *** Set Pipeline variable $(ALOPS_DOCKER_DNSNAME) = 'e4ef55c1c920'
2024-02-21T17:17:14.8640601Z *** Set Pipeline variable $(ALOPS_DOCKER_WEBCLIENT) = 'https://e4ef55c1c920/BC/'
2024-02-21T17:17:14.8669864Z *** Set Pipeline variable $(ALOPS_DOCKER_VSIX) = 'http://e4ef55c1c920:8080/ALLanguage.vsix'
2024-02-21T17:17:14.8698138Z *** Set Pipeline variable $(ALOPS_DOCKER_CERTIFICATE) = 'http://e4ef55c1c920:8080/certificate.cer'
2024-02-21T17:17:14.8743999Z *** Set Pipeline variable $(ALOPS_DOCKER_ADMINUSER) = 'admin'
2024-02-21T17:17:14.8775564Z *** Set Pipeline variable $(ALOPS_DOCKER_ADMINPASSWORD) = 'Cuwu6149'
2024-02-21T17:17:14.8807642Z *** Set Pipeline variable $(ALOPS_DOCKER_NAVSERVERINSTANCE) = 'BC'
2024-02-21T17:17:14.8886365Z *** Initiate Docker Session
2024-02-21T17:17:15.1349638Z *** Set Docker Container ErrorActionPreference = Stop
2024-02-21T17:17:15.1706555Z *** Working folder: C:\vsts-agent-alops-warp10\_work\2281\s
2024-02-21T17:17:15.1726577Z ***
2024-02-21T17:17:15.1741227Z *** Copy Working folder to Docker Container: e4ef55c1c920b38733406ae82e5efd4e09a73ff27738916fa5babf0874afbbc1
2024-02-21T17:17:15.1752683Z *** Docker Working Folder: c:\Run\DevOps\
2024-02-21T17:17:15.1765507Z *** Copy from [C:\vsts-agent-alops-warp10\_work\2281\s] to [c:\Run\DevOps\]
2024-02-21T17:17:15.2375187Z *** Compression Enabled Transfer (Dotnet)
2024-02-21T17:17:15.2472035Z *** Compress Source Files
2024-02-21T17:18:13.1837365Z *** Transfer compressed Archive to session (2236958576 bytes)
2024-02-21T17:24:59.5724818Z *** Expand source files in target session
2024-02-21T17:25:02.1504405Z *** Source File setup completed
2024-02-21T17:25:02.1657987Z *** Cleanup VSTS Environment: True
2024-02-21T17:25:04.4404908Z ##[section]Finishing: Wait for Docker Container
acjdekorte commented 4 months ago

@Arthurvdv We run into a simular problem, which I have solved by adding the workspace: clean: resources to the job. The disadvantage is that the fetch from git takes slighthly longer, but it saves us about 15-20 minutes for our most used repository.
image

Arthurvdv commented 4 months ago

If I'm not mistaken we already have this in place (but with the setting to all instead of resources).

- stage: TestStage
  displayName: 'Test'
  dependsOn: BuildStage
  condition: succeeded()
  jobs:
    - job: TestJob
      displayName: 'Test'
      pool: '${{ parameters.build_pool }}'
      workspace:
        clean: all
      steps:
Arthurvdv commented 4 months ago

After sleeping a night I think I have have a better approach on this. Can we use the mount functionality of docker, instead of the Compress, Transfer and Expand steps?

image https://docs.docker.com/storage/bind-mounts/

I believe this could simply the steps of the ALOpsDockerWait@1 and improve performance at the same time? In this way we expose the folder directly to the container, without the need of transferring files.

waldo1001 commented 4 months ago

We'll try to foresee an option (extra parameter) to exclude the .git folder from the copy.

It can take a while though, since we have to redo our zip-procedure completely. And we obviously don't want to break anything.. .

waldo1001 commented 2 months ago

We found a way to do this. Setting will be exclude_git_folder.

Arthurvdv commented 1 month ago

Works perfectly, thank you for supporting this!

waldo1001 commented 1 month ago

Thanks for the suggestion - it was a very good idea ;-)