Skip to content

Instantly share code, notes, and snippets.

@alinetskyi
Last active March 24, 2023 09:39
Show Gist options
  • Save alinetskyi/cfc95dbce01d9452d93726e9157e89a1 to your computer and use it in GitHub Desktop.
Save alinetskyi/cfc95dbce01d9452d93726e9157e89a1 to your computer and use it in GitHub Desktop.
Setup Debian machine for docker-compose
#!/bin/bash -x
COMPOSE_VERSION="1.23.2"
COMPOSE_URL="https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)"
# Opendax bootstrap script
install_core() {
sudo bash <<EOS
apt-get update
apt-get remove -y --purge unscd
userdel -r debian
apt-get install -y -q git tmux gnupg2 dirmngr dbus htop curl libmariadbclient-dev-compat build-essential
useradd -m -G root -p '*' -s /bin/bash app
EOS
}
log_rotation() {
sudo bash <<EOS
mkdir -p /etc/docker
echo '
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "10"
}
}' > /etc/docker/daemon.json
EOS
}
# Docker installation
install_docker() {
curl -fsSL https://get.docker.com/ | bash
sudo bash <<EOS
usermod -a -G docker app
curl -L "$COMPOSE_URL" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
EOS
}
install_ruby() {
sudo -u app bash <a<EOS
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
source /home/app/.rvm/scripts/rvm
rvm install 2.6.3
EOS
}
install_core
log_rotation
install_docker
install_ruby
sudo -u app /bin/bash --login
cd /home/app
@JohnDilans
Copy link

Hello, Artem, there is the next problem:

find: Failed to restore initial working directory: /root: Permission denied Searching for binary rubies, this might take some time. No binary rubies available for: debian/9/x86_64/ruby-2.6.3. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for debian. Installing requirements for debian. Updating systemapp password required for 'apt-get --quiet --yes update':

How we can fix it?
Thx.

@kbsc332
Copy link

kbsc332 commented Apr 1, 2020

@alinetskyi
You would change install_ruby function.
On the first line, sudo -u app bash <a<EOS should change into sudo -u app bash <<EOS

sudo -u app bash <<EOS
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
source /home/app/.rvm/scripts/rvm
rvm autolibs disable
rvm install 2.6.5
EOS

and who got error when installing bundler,
do under line in command
rvm pkg install openssl
rvm reinstall ruby-2.6.5 --with-openssl-dir=$rvm_path/usr

@Maister81
Copy link

@kbsc332: Thanks for your input

@alinetskyi: Thanks for the script. Is it possible to change the script, according improvements of kbsc332, so we can use it for installation? We are not able to run anything after Docker has been installed. Many thanks for your input and effort. Looking forward to your reaction. Kind regards Mr. Maister

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment