Deploying any application is super easy with Git. Every Cloud Container Image has git installed out of the box.
First things first, we need to create an ssh key for your Cloud Container, this is because authentication via username/password has been deprecated in favor of more secure authentication methods.
We can create our own ssh key with this command (Press
enter every time the command asks you for input):
ssh-keygen -t rsa -b 4096
Now you can get your newly created ssh key by typing the following command:
Copy the output of the command and go to your GitHub/GitLab/Bitbucket account settings, the process should be identical for all the options.
On the settings menu, search the
SSH Keys option, then click on
New SSH Key, you should be prompted with a screen like this:
Set a title for the new record and paste the previously copied ssh-key into the
key box and click
Add SSH key
Now you can clone your project into your Container. From here, we need to ssh into the Container.
You can check that git is installed on your Container by running this command:
user@ch-test:~$ git --version git version 2.25.1
Usually, your application should be located on the
/container/application/ directory and in here where you should be cloning your project/
Now we can clone our project to the Container. Keep in mind that the dot at the end of the command is telling git to clone the project in the current folder
git clone email@example.com:your-username/project-name.git .
If everything goes well, you should see the following result:
Cloning into '.'... remote: Enumerating objects: 6, done. remote: Counting objects: 100% (6/6), done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (6/6), done.
If the application requires building (fetch dependencies, compile assets, generate artifacts, etc.), execute the build command manually on the server (npm, composer, yarn install, gulp grunt webpack, etc.) just as if you were working on your local machine.
Now every time you wish to update your project, you can use the
git pull command, and the project will be updated.
If you are making changes on the Container and want to
commit your changes to the repository, you will be getting the
Please tell me who you are message, to set your identity on the server, run the following commands:
git config user.name "Your Username" git config user.email "Your email"