Configure GitLab to run Docker build in a CI Pipeline

Assuming you already have an installed an running Gitlab server, you need to install and configure a GitLab runner:

Install gitlab-runner: https://docs.gitlab.com/runner/install/linux-repository.html

Run the gitlab-runner shell setup, described here: https://docs.gitlab.com/ce/ci/docker/using_docker_build.html

Get the registration token from the Settings / CI/CD Settings page.

You can now use docker commands in the script section of your .gitlab-ci.yml file defining your pipeline.

git error: “refusing to merge unrelated histories”

When working with local git repos, whenever I add a remote repo on github and then try to pull down the master from remote to local, I get errors about local repo not being on the same branch as the remote, or more recently this error:

fatal: refusing to merge unrelated histories

I think in the past I’ve done a ‘reset –hard’ like described here, but this didn’t work for me this time, I got the same error about ‘unrelated histories’

Turns out this might be related to a change in git behavior, as described here.

Doing:

git pull github master --allow-unrelated-histories

and then followed with:

git push github master

fixed my issue.

Deploying a git subtree to Heroku (or other PaaS)

Most of the common PaaS platforms like OpenShift and Heroku deploy code based on a source in a git repo – you push your local repo containing source to the remote repo on the platform, the build is performed remotely and then deploys the built artifacts.

What if you want to deploy an app that is prebuilt, or you have a git repo that contains various subfolders, and only part of the folder structure in the repo is what you need deployed?

I’ve been experimenting with a simple React app that also has a node.js backend. In hindsight restructuring the source tree to make the app easier to deploy may have been simpler, but it turns out you can push part of your source subtree to a remote repo, like an application deployed to Heroku, using ‘git subtree’:

git subtree push –prefix subfoldername heroku master

This is discussed in this post here.