My Shitty Code

Embracing the Messiness in Search of Epic Solutions

Category: Development Tools

  • Docker: Executing Startup Script When Running Container Interactively

    PROBLEM When running the Docker container interactively (ex: docker run –rm -it myimage), you want to run a startup script every time. SOLUTION For Ubuntu, Debian and Centos images, write the startup script to /root/.bashrc: For Alpine image, it’s a little different because it uses Ash shell. Besides writing the startup script to /root/.profile, you […]

  • Git: Querying Tags Without Cloning the Repository

    PROBLEM A typical way to get a list of tags from a repository is to clone it before running git tag:- versionsort.suffix=- ensures 1.0.0-XXXXXX comes after 1.0.0. To retrieve the latest tag:- While it works, it requires us to clone the repository first, and if we want to retrieve tags from multiple repositories, we are […]

  • Git: Configuring Different Git User Info Depending on Projects

    PROBLEM Given, the following global config stored under ~/.gitconfig… When committing any code, the above user info will always be used. However, there are times you want to use a different user info depending on projects (ex: work projects, GitHub projects, etc) SOLUTION This is one of many ways to solve this problem. Let’s assume […]

  • Azure: Deploying WAR File to Tomcat

    PROBLEM Typically, when using ZipDeploy to push a WAR file (ex: my-app.war) to an Azure instance, we need to:- This zip file will automatically be unzipped under site/wwwroot:- Tomcat detects ROOT.war and will try to unpack the WAR file under ROOT/:- The problem is sometimes Tomcat is unable to fully unpack ROOT.war because some files […]

  • Spring Boot: Restarting App using Dev Tools with IntelliJ IDEA

    Spring Boot provides spring-boot-devtools module that allows the app to “smartly” restart whenever the files on the classpath have changed. Because the rarely changed classes (ex: 3rd party JARs) are separated out into a different classloader from the app’s actively developed classes’ classloader, it allows Spring Boot to quickly restart the app compared to “cold […]

  • Docker: Handling Circular Dependency between Containers

    PROBLEM Let’s assume we are going to run 3 containers:- Nginx is used to serve cleaner URLs through reverse proxies so that users will access http://server/jenkins and http://server/nexus instead of remembering specific ports. So, the simplified docker-compose.yml looks like this:- While http://server/jenkins and http://server/nexus work flawlessly, the Jenkins container is unable to communicate with Nexus […]