Skip to content

Commit

Permalink
Upgrade image, simplify docker setup, and migrate to compose v2
Browse files Browse the repository at this point in the history
  • Loading branch information
HelgeCPH committed Feb 22, 2024
1 parent 8714bb0 commit 3cd4e69
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
34 changes: 16 additions & 18 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Vagrant.configure("2") do |config|

config.vm.synced_folder "remote_files", "/minitwit", type: "rsync"
config.vm.synced_folder '.', '/vagrant', disabled: true

config.vm.define "minitwit", primary: true do |server|

server.vm.provider :digital_ocean do |provider|
provider.ssh_key_name = "do_ssh_key"
provider.token = ENV["DIGITAL_OCEAN_TOKEN"]
provider.image = 'ubuntu-20-04-x64'
provider.image = 'ubuntu-22-04-x64'
provider.region = 'fra1'
provider.size = 's-1vcpu-1gb'
end
Expand All @@ -23,23 +23,21 @@ Vagrant.configure("2") do |config|

server.vm.provision "shell", inline: 'echo "export DOCKER_USERNAME=' + "'" + ENV["DOCKER_USERNAME"] + "'" + '" >> ~/.bash_profile'
server.vm.provision "shell", inline: 'echo "export DOCKER_PASSWORD=' + "'" + ENV["DOCKER_PASSWORD"] + "'" + '" >> ~/.bash_profile'

server.vm.provision "shell", inline: <<-SHELL
# Install docker and docker-compose
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt-cache policy docker-ce
sudo apt install -y docker-ce
sudo apt-get update
# The following address an issue in DO's Ubuntu images, which still contain a lock file
sudo killall apt apt-get
sudo rm /var/lib/dpkg/lock-frontend
# Install docker and docker compose
sudo apt-get install -y docker.io docker-compose-v2
sudo systemctl status docker
sudo usermod -aG docker ${USER}
sudo apt install -y docker-compose
# sudo usermod -aG docker ${USER}
# Install make
sudo apt-get install -y make
echo -e "\nVerifying that docker works ...\n"
docker run --rm hello-world
docker rmi hello-world
Expand All @@ -58,10 +56,10 @@ Vagrant.configure("2") do |config|
echo "cd /minitwit" >> ~/.bash_profile
chmod +x /minitwit/deploy.sh
echo -e "\nVagrant setup done ..."
echo -e "minitwit will later be accessible at http://$(hostname -I | awk '{print $1}'):5000"
echo -e "The mysql database needs a minute to initialize, if the landing page is stack-trace ..."
echo -e "The mysql database needs a minute to initialize, if the landing page shows an error stack-trace ..."
SHELL
end
end
4 changes: 2 additions & 2 deletions remote_files/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ source ~/.bash_profile

cd /minitwit

docker-compose -f docker-compose.yml pull
docker-compose -f docker-compose.yml up -d
docker compose -f docker-compose.yml pull
docker compose -f docker-compose.yml up -d
docker pull $DOCKER_USERNAME/flagtoolimage:latest

0 comments on commit 3cd4e69

Please sign in to comment.