-
Notifications
You must be signed in to change notification settings - Fork 4
Week 04
Considerations:
- We need to set up tests in our github actions
- Modify github actions to create docker images and run in a vm? (needs more digging)
- Delete the previous container
- Set up the public ssh keys
- Deploy a droplet(vm)in digital ocean
- We will user vagrant-digital ocean provider (can we use terraform?: Answer: we will be introduced to Terraform later in the course)
From Session 3 there are some ways for automating the creation of virtual servers:
- Automatic provision of remote virtual machines at DigitalOcean via a web-API
- Automatic provision of remote clusters of virtual machines at DigitalOcean via Vagrant
DockerHub- alternative way to store docker images. -for the free plan, repositories should be public.
- make an account on dockerhub, and set your username and password.
#Exercises Interesting error from the exercises:
the command inside vagrant file is not recognise, therefore the docker plugins do not end up being installed in the VM. Solution: entered via openSSH and manually installed docker-compose-v2 and docker.service
it solved the github action issue
We will be following https://docs.digitalocean.com/reference/api/example-usage/ and https://docs.digitalocean.com/products/droplets/how-to/create/
- For mac users: follow this tutorial: https://stackoverflow.com/questions/51126403/you-dont-have-write-permissions-for-the-library-ruby-gems-2-3-0-directory-ma Remember to add the following to the ~/.bashrc or ~/.zshrc file:
source /usr/local/share/chruby/chruby.sh
For macOS
source $HOMEBREW_PREFIX/opt/chruby/share/chruby/chruby.sh
Or run brew info chruby
to find out installed directory
Ruby script is created. We have a local .env file, We have installed the "dotenv" package for ruby via gem install dotenv
We faced difficulties adding the docker access token through the droplet kit. After having tried different approaches and consulting stack overflow, we dived into the Vagrantfile known from exercises.
Heavily inspired from the provided vagrant file from exercises and the documentation, we created a Vagrantfile to create and configure our droplet on Digital Ocean. Initially we had put the docker password into our environment and provided that for the droplet. We have since changed this to use an access token.
We have followed the exercises session for the deployment workflow. we have set up the following secrets to our github database:
- DOCKER_USERNAME: aswr
- DOCKER_PASSWORD: personal token which reads- and writes
- SSH_USER: in our case is root
- SSH_KEY: has to be adjusted so each of our computers have a key registered to the droplet
- SSH_HOST
we have adjusted the workflow so that on pull request, specifically, when we enable "auto merge" in the pull request, the workflow gets triggered. When the workflow passes, the pull request it merged to main.
we adjusted in the settings: -> settings > general > pull-requests > Allow auto-merge checked -> settings > Branches > require status checks before merging
Deploy.sh used the wrong path for cd: 'cd csharp-minitwit' it should be 'cd /csharp-minitwit'. For some reason the script is run, but from the root, and for some other reason, the cd command in the shell script requires a '/' in front, although this is not necessary when SSH'ing into the server manually.
- Used exercises session for reference;
- Setup the environment variables devops keys required: (Ask Ellie for the data)
DOCKER_USERNAME
DOCKER_PASSWORD
-
PROVISION_TOKEN
- personal access token through DO -
do_ssh_key
- the private and public key in your computer
- cd into the csharp folder and
vagrant up
. IMPORTANT: Ensure that no .vagrant folder exists in the repository before running - Observe any discrepancies (especially if Docker is installed, otherwise you will have to ssh into the docker manually and install it yourself)
- Now you should have the droplet ready. Remember to reattach the reserved IP address to the droplet.