Today I would like to share my experience and struggles with AL-Go for GitHub. This is a different and longer post from what I´ve been sharing as you will realize. However, I believe someone could be interested and might find value in it.
First of all, to let you know my background for this story I am in the initiation level of DevOps, CI/CD, pipelines, .yaml’s, etc. I´ve been trying to learn Azure DevOps for CI/CD on my own and understanding the basic concepts but never really built a pipeline before. Also, I´ve been fighting with Docker not for long and always with BcContainerHelper for creating containers and images of Business Central. Outside of that I am lost.
From that perspective I enter the step 1 of AL-Go for GitHub.
AL-Go for GitHub is a set of GitHub templates and actions, which can be used to setup and maintain professional DevOps processes for your Business Central AL projects.
It´s a new feature realeased with Business Central 2022 wave 1 (BC20). So I thought it was about time for me to enter this world once and for all with this new tool.
Get more information here:
Phase 1: Eager
Alright, here we go, let´s build some pipelines.
I am ready to follow Step 1. When I try to execute ‘localDevEnv.ps1’ this error occurs, “Oh, an error, ok, let´s see.” (I think for myself, unaware for what was about to come).
Yep, no clue about the error. “Initialization of container failed”, “Service tier doesn´t exist/ is not installed”.
I can only see that the container is created and running but ‘http://bcserver/BC/’ is not working.
Alright, let´s run it again, why not? It has happened to me with docker, first time fails, second time works fine.
Nope, “ALTER DATABASE [CRONUS] SET OFFLINE WITH ROLLBACK INMEDIATE”.
“Umm, this is not going to be as easy as I expected”.
Alright, it could be because the container is created already and there should be no containers with same name. I run it again:
Same error, “Really?” The process might have suffered imcompatibilites or something is not working properly on my machine. Let´s delete the container and image, reboot and have a fresh start, right?
Note that it takes around 10 minutes for the image to be pulled each time.
Phase 2: Not eager
After the reboot and trying to initilize docker I get this error:
“This is going to be tough”, not so eager at this moment I reset to factory defaults. I have no other options as quitting and trying to initialize showed me the same error.
After Docker is running fine again I tried running one more time, and surprise! Another error, “Seems like we are making progress…” (note the sarcasm).
“Driver “windowsfilter” failed to remove root filesystem: failed to detach virtual disk”.
As a result, I get a dead container and more red, I can only understand “context deadline exceeded”. At this point I realize I am clueless and try to find something on the web. Not finding anything useful I try to delete the container and try something else.
“What?” Yes, I start complaining and not enjoying the process at this moment. Instead of reset to factory defaults because it´s taking a long time I decide to unistall docker and install it again. And why not, rebooting the machine in case I have any process I don´t know messing up.
Let´s try running VS Code as administrator? At this point I´m frustrated and just trying random things I find out there on the web.
Some more red. I didn´t have any hope anyways. What drives me nuts at this point is that docker is broken again. I have to unistall it, reboot, install it, etc, which is taking almost another 10 minutes every time.
Phase 3: Hope and back to frutration
Right know I´m really lost and think that this is not working for me.
At some point I find this GitHub section named ‘Issues’, a newbie like me didn´t realized until this point.
And ‘voilà’, somebody else have summited the error not long ago, and he isn´t the only one.
Someone posted that the script worked when running from PowerShell, not the terminal from VS Code. “Yeah! I got it! This should be it! Right?”
I can´t take it. It´s no even pulling the image! I reboot the machine and try again.
Alright now the image is pulled! Let´s see the container, it´s taking a while…
And red, I can´t believe it, “Failed to detach VHD”.
This error sounds familiar but I am giving up. It´s time to get some help. I asked Freddy but didn´t know what to really ask. I thought it had something to do with “Removing BcContainerHelper” because the error was always displayed after that.
Very rapidly he answers:
Can´t even count the times I have restarted already Freddy, but thanks anyways. I reply with the following with the hope that he has a magic wand and the solution to the problem:
Phase 4: Relieve
As I´m not receiving answers I lost all hope and I´m about to give up. But suddenly I find this thread from last year:
A long thread but some people share the errors I am experiencing, let´s see what they have to say. Demiliani and many people are suggesting some solutions:
First time I read about Windows Defender issue. Although my docker version is different (4.7.0) what can I lose? Another broken docker? Let´s do it! Last opportunity for today and trying not to throw it to the trash.
I disable Windows defender and… GREEN, GREEN! I was so excited I didn´t even took the screenshot . The container is created and running, the script has finished! I do have the final output of the process:
My feelings right now are not even happy, but relieved. I finally did it. Ater all, Freddy was right, it was a local issue. I saved the day.
And there I have my “Hello World”:
And my build pipeline is running with my first commit.
I finished step 1! Are all the steps this hard? Let´s have a well deserved rest.
Phase 5: Docker attacks again
The next day happily to get started with Step 2 I start docker and….
“Again?” This can´t be an script issue, this must be docker for sure. I don´t know how but I ended up here:
Finally, I updated to Docker 4.7.1 thanks to ebriney (Emmanuel Briney) (github.com) .
I started again from scratch, new app on github, no Windows defender, everything worked fine now.
So after this long struggling and ranting, the conclusion.
Be patient with Docker.
Seriously, there was two different problems:
- Windows Defender not allowing the creation of the container.
- Docker 4.7.0 crushing every time a failed container was generated.
This was a tough path and an emotional rollercoaster but learned a lot in the process. Not so much about CI/CD but about problem solving, investigation and patience. And pushed my machine to the limit which I hope is fine after all the messing up.
Hope you enjoyed it and if you find yourself with the same issues you can save some valuable time.