Skip to content

HOWTO devops dev_containers

steveoro edited this page Jan 9, 2025 · 4 revisions

HOW-TO: dev-containers intro & setup

References:

0. make sure SSH is set up:

Follow, for example, https://linuxconfig.org/quick-guide-to-enabling-ssh-on-ubuntu-24-04:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install ssh
$ sudo systemctl enable ssh
$ sudo systemctl status ssh
$ sudo systemctl start ssh
$ sudo ufw allow ssh
$ sudo ufw enable

# Check that the ssh-agent is running:
$ ssh-agent -s

# Reuse any ssh identity carried or copied over from your previous laptop:
# (Copy both private & .pub files before)
$ ssh-add ~/.ssh/id_rsa

At this point, You should be able to clone any private repo from GitHub. Just make sure to use the "git@github.com:" prefix protocol for cloning, not "https:".

1. install Docker

Use docker-ce, which is more up-to-date than the default Ubuntu docker.io package.

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

$ sudo apt update
$ sudo apt install docker-ce -y
$ sudo systemctl status docker
$ sudo usermod -aG docker $USER

# Update groups and display renewed groups for current user:
$ newgrp
$ groups $USER

At this point, you should be able to run docker ps without sudo.

2. install VS Code

$ sudo apt update
$ sudo apt install code

Or use https://code.visualstudio.com/.

Install the Dev Containers extension by downloading it from the VSCode marketplace if not already installed. VS Code's container configuration is stored in a devcontainer.json file inside your project.

See https://code.visualstudio.com/docs/devcontainers/containers#_create-a-devcontainerjson-file for more details.

3. install 'rails-new'

References:

Go to the latest release and download the executable for your platform (not the source code).

For example, on M1 macOS this would be rails-new-aarch64-apple-darwin.tar.gz.

Once the download is complete, unzip the .tar.gz file, which will create the rails-new executable.

Move the executable into your path so that it is ready to run from the command line.

$ sudo mv rails-new /usr/local/bin

To generate a new Rails application, you can run the following command:

rails-new myapp

Or with options:

rails-new myapp --main

Clone this wiki locally