Git server for local tests
100K+
This is a git server based on git-server-docker: "A lightweight Git Server Docker image built with Alpine Linux. Available on GitHub and Docker Hub"

The basic usage is unchanged from the original, docs available on GitHub.
The additions consists in the keys and repos directories.
The keys directory contains a key pair used to authenticate to the server. The private keys is included for convenience in test and debug.
/!\ DO NO USE THE KEYS ANYWHERE ELSE /!
The repos contains the ready to use git repositories.
Both keys and repositories are copied in the appropriate directories, see Dockerfile and start.sh, and are available in the container.
Assuming that you are running the development environment of the backend, the container is running as git-server inside the yd-subnet with IP 172.42.0.14, the easiest way to access the repositories locally is to add the following entry in you ~/.ssh/config file:
Host git-server
Hostname 172.42.0.14
IdentityFile <PATH_TO_THE_KEY_IN>backend-tests-git-server/keys/id_ed25519
IdentitiesOnly yes
Explanation: git-server is the name of the container and of the service, it is set in the backend docker-compose.yml, and it is enough for the backend to reach the container since they running in the same network from docker-compose.
But we cannot resolve git-server when we use git on our machine to access to the git-server so we need to specify the IP of the container in the config file as HostName, again from the docker-compose.yml.
In this way we can use the same URL to clone/pull/push locally to/from any of the repos in the local git server as we do in the backend, the URLs are in testutils/urls.go.
Tweak the entry with your path to the key, and since git does not keep the file permissions (a part from the executable ones) you need to chmod 700 PATH_TO_KEY or ssh will complain.
You should be able to access the repo normally for example: git clone git@git-server:/git-server/repos/<REPO_NAME>.git.
This git server is used for integration tests, the repositories are supposed to, roughly, stay same and any modification should be volatile and not persisted.
The docker-copose.yml file has been updated to reflect this, the repositories ad keys are copied in two tmpfs and not in bind-mounted volumes.
There are few things to do to update this service here are the main points.
Keys are stored in the key directory and then copied at container startup in the proper location.
To add a key pairs simply add them in the key directory.
The repositories are stored in /repos inside the container and are copied at container startup to /git-server/repos/ from where they are served, see start.sh.
The easy way to add a repository is to have it online and publicly available (can be cloned without credentials) and update the Dockerfile to clone the new repo as --bare inside the container in /repos, for example: git clone --bare https://github.com/gh_user/new_repo.git /repos/new_repo.git.
The not so easy way or if you cannot have the repository public is to create a --bare repository in the repos directory.
These are the steps to crate an empty repository:
cd repos
mkdir tmp # create a temporary git repository
cd tmp
git init
git branch -M master # change the default branch name to master
touch README.md
git add README.md
git commit -m"initial commit"
cd ..
git clone --bare tmp <REPO_NAME>.git # clone the temporary repo as a bare repository with the correct name
rm -rf tmp/
cd ..
To be able to commit the the bare rpository we need to add a .gitkeep file to the empty directories:
touch repos/backend-infra-import-repo.git/refs/heads/.gitkeep
touch repos/backend-infra-import-repo.git/refs/tagss/.gitkeep
touch repos/backend-infra-import-repo.git/branches/.gitkeep
Now you can commit the directory containing the new repo.
The new repositories will be available at: git@git-server:/git-server/repos/<REPO_NAME>.git to the backend, and to you locally if you added the .ssh/config mentioned earlier.
After changing Dockerfile or other files in this repo you need to tag and push a new commit, the tag will be picked up by the DockerHub builder that will build and tag a new image.
The tag must be something like 1.2.3 and will produce a docker image with the following name cycloid/backend-tests-git-server:v1.2.3.
Once the new image is ready to be pulled you need to update the docker-compose.yml of youdeploy-http-api to pull the new docker image with the correct tag, and update cycloid-stacks to cache the new image.
Content type
Image
Digest
sha256:e286fd5d3…
Size
12.2 MB
Last updated
about 1 month ago
docker pull cycloid/backend-tests-git-server:v1.0.55