From c6c52bbe1e4c22f9cd769c6ec4869c380991db84 Mon Sep 17 00:00:00 2001 From: Mahmoud Elsabbagh Date: Thu, 24 Apr 2025 12:37:11 +0100 Subject: [PATCH] Vagrant: Remove Vagrant file and all references Remove Vagrant file and all its references for documentation and docker. Signed-off-by: Mahmoud Elsabbagh --- .gitignore | 4 - Vagrantfile | 21 ---- doc/build_system.md | 101 +----------------- docker/Dockerfile | 51 --------- .../rootfs/home/vagrant/.ssh/authorized_keys | 1 - docker/rootfs/usr/local/bin/init | 15 ++- 6 files changed, 9 insertions(+), 184 deletions(-) delete mode 100644 Vagrantfile delete mode 100644 docker/rootfs/home/vagrant/.ssh/authorized_keys diff --git a/.gitignore b/.gitignore index 2350f4dfd..953d8dbd7 100644 --- a/.gitignore +++ b/.gitignore @@ -54,8 +54,4 @@ cscope.* # Docker # General -.vagrant/ .bundle/ - -### Vagrant Patch ### -*.box diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 85d4a7b1e..000000000 --- a/Vagrantfile +++ /dev/null @@ -1,21 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.configure("2") do |config| - config.ssh.forward_env = [ "ARMLMD_LICENSE_FILE" ] - config.ssh.forward_x11 = true - - config.vm.provision "file", source: "~/.gitconfig", destination: "${HOME}/.gitconfig" - - config.vm.provider "docker" do |d| - d.build_dir = "." - - d.build_args = [ "--target", "vagrant", "-f", "docker/Dockerfile" ] - d.cmd = [ "sudo", "/usr/sbin/sshd", "-D" ] - d.env = { "ARMLMD_LICENSE_FILE" => ENV["ARMLMD_LICENSE_FILE"] } - - d.has_ssh = true - - ENV["LC_ALL"] = "C.UTF-8" - end -end diff --git a/doc/build_system.md b/doc/build_system.md index 2803febc7..d2daaa0ce 100644 --- a/doc/build_system.md +++ b/doc/build_system.md @@ -444,100 +444,6 @@ $ cmake "${SCP_SOURCE_DIR}" -B "${SCP_BUILD_DIR}" \ Along with core CMake build system, also provided is a option to generate a build environment, please see details below. -## Vagrant (recommended) -\anchor vagrant - -> **NOTE**: If you're unfamiliar with Vagrant, we recommend you read the brief -> introduction found [here][Vagrant]. - -Vagrant is an open-source software product for building and maintaining portable -virtual software development environments. The `SCP-firmware `project offers a -Vagrant configuration based on the [Docker] provider, and so you will need to -have them both installed: - -- Install [Docker](https://docs.docker.com/get-docker) -- Install [Vagrant](https://www.vagrantup.com/downloads) - -> **NOTE**: Vagrant and Docker are generally both available through system -> package managers: -> -> - Ubuntu and other Debian-based Linux distributions: -> https://docs.docker.com/engine/install/ubuntu/ - - ```sh - $ sudo apt install vagrant - ``` - - -When using Vagrant, there are no additional prerequisites for the host system, -as all build and quality assurance tools are packaged with the container. - -[Docker]: https://www.docker.com/why-docker -[Vagrant]: https://www.vagrantup.com/intro - -### Interactive Development - -You can bring up an interactive development environment by simply running the -following: - -```sh -$ vagrant up -Bringing machine 'default' up with 'docker' provider... -==> default: Machine already provisioned. Run `vagrant provision` or use the -`--provision` -==> default: flag to force provisioning. Provisioners marked to run always will -still run. -``` - -> **NOTE**: The Docker container image will be built the first time you run -> this, which can take a while. Be patient - it won't happen again unless you -> modify the Dockerfile. - -The project working directory will be mounted within the container as -`/scp-firmware`. - -You can then connect to the embedded SSH server as the non-root user `user` -with: - -```sh -$ vagrant ssh -``` - -You will have access to `sudo` from within the container, and Vagrant will -persist any changes to the container even if you halt it. If you need to rebuild -the container for any reason, like if you have made changes to the Dockerfile, -you can rebuild the development environment with: - -```sh -$ vagrant reload -``` - -Do note, however, that reloading the development environment will rebuild it -from scratch. - -### Running Commands - -If you simply wish to invoke a command from within the container, you may also -use Vagrant's [`docker-run`] command, e.g.: - -```sh -$ vagrant docker-run -- pwd -==> default: Image is already built from the Dockerfile. `vagrant reload` to -rebuild. -==> default: Creating the container... - default: Name: git_default_1601546529_1601546529 - default: Image: b7c4cbfc3534 - default: Cmd: pwd - default: Volume: /tmp/tmp.cGFeybHqFb:/vagrant - default: - default: Container is starting. Output will stream in below... - default: - default: /vagrant -``` - -[`docker-run`]: - https://www.vagrantup.com/docs/providers/docker/commands#docker-run - ## Visual Studio Code Development Containers If you use Visual Studio Code, you may also work directly within a @@ -563,12 +469,9 @@ This Dockerfile has four variants: additional steps required to use it from Jenkins. - `dev`: A development variant, which includes additional tools for developers accessing the container directly. -- `vagrant`: A Vagrant variant, which includes an SSH server and a workspace - more familiar to Vagrant users. -We *highly* recommend using [Vagrant](#vagrant) to manage your development -environment, but in case you must do so directly through Docker, you can build -the development container with the following: +In case you want to manage your development environment directly through Docker, +you can build the development container with the following: ```sh $ docker build -t scp-firmware --target=dev -f docker/Dockerfile . diff --git a/docker/Dockerfile b/docker/Dockerfile index 0f239101d..42f41f796 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -156,54 +156,3 @@ RUN echo "\nexport USER=${USERNAME}" >> "/home/${USERNAME}/.bashrc" ENV PATH="/home/${USERNAME}/.local/bin:${PATH}" ENTRYPOINT [ "bash", "/usr/local/bin/init" ] - - -FROM user as vagrant - -VOLUME /vagrant -WORKDIR /vagrant - -# Set a default username argument (vagrant by default) -ARG USERNAME=vagrant - -# Update package lists and install necessary packages - -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get update && \ - apt-get install -y \ - sudo \ - openssh-server - -ENV DEBIAN_FRONTEND= - - -# Create the user and set up SSH access -RUN adduser --disabled-password --gecos "" $USERNAME && \ - usermod -aG sudo $USERNAME && \ - passwd -d vagrant && \ - mkdir -p "/home/$USERNAME/.ssh" && \ - chmod 700 "/home/$USERNAME/.ssh" - -# Copy the authorized keys file -COPY docker/rootfs/home/$USERNAME/.ssh/authorized_keys \ - /home/$USERNAME/.ssh/authorized_keys - -# Set proper permissions for the authorized keys file -RUN chmod 600 "/home/$USERNAME/.ssh/authorized_keys" && \ - chown -R $USERNAME:$USERNAME "/home/$USERNAME/.ssh" - -# Set environment variables -ENV NOTVISIBLE="in users profile" \ - PATH="/home/$USERNAME/.local/bin:${PATH}" - -# Add configuration to make the environment visible -RUN echo "export VISIBLE=now" >> "/etc/profile" && \ - printf "\nAcceptEnv ARMLMD_LICENSE_FILE" >> "/etc/ssh/sshd_config" && \ - printf "\ncd /$USERNAME" >> "/home/$USERNAME/.bashrc" - -# Expose SSH port -EXPOSE 22 - -# Set entrypoint to initialize services -ENTRYPOINT [ "bash", "/usr/local/bin/init" ] diff --git a/docker/rootfs/home/vagrant/.ssh/authorized_keys b/docker/rootfs/home/vagrant/.ssh/authorized_keys deleted file mode 100644 index f76293459..000000000 --- a/docker/rootfs/home/vagrant/.ssh/authorized_keys +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== diff --git a/docker/rootfs/usr/local/bin/init b/docker/rootfs/usr/local/bin/init index 1c0a99c12..e596fb1b2 100755 --- a/docker/rootfs/usr/local/bin/init +++ b/docker/rootfs/usr/local/bin/init @@ -7,24 +7,23 @@ # SPDX-License-Identifier: BSD-3-Clause # -if id vagrant > /dev/null 2>&1; then - user=vagrant -elif id user > /dev/null 2>&1; then +if id user > /dev/null 2>&1; then user=user fi if [ -z "${user}" ]; then - exec $@ + echo "Warning: Non-root user 'user' not found. Running as root." >&2 + exec "$@" else uid=$(stat -c "%u" ".") gid=$(stat -c "%g" ".") - usermod -u ${uid} ${user} - groupmod -g ${gid} ${user} + usermod -u "${uid}" "${user}" + groupmod -g "${gid}" "${user}" if [ $# -eq 0 ]; then - exec su ${user} + exec su "${user}" else - exec gosu ${user} $@ + exec gosu "${user}" "$@" fi fi -- GitLab