diff --git a/develop-user-data/.config/nvim/.neoconf.json b/.dotfiles/.config/nvim/.neoconf.json similarity index 100% rename from develop-user-data/.config/nvim/.neoconf.json rename to .dotfiles/.config/nvim/.neoconf.json diff --git a/develop-user-data/.config/nvim/LICENSE b/.dotfiles/.config/nvim/LICENSE similarity index 100% rename from develop-user-data/.config/nvim/LICENSE rename to .dotfiles/.config/nvim/LICENSE diff --git a/develop-user-data/.config/nvim/README.md b/.dotfiles/.config/nvim/README.md similarity index 100% rename from develop-user-data/.config/nvim/README.md rename to .dotfiles/.config/nvim/README.md diff --git a/develop-user-data/.config/nvim/init.lua b/.dotfiles/.config/nvim/init.lua similarity index 100% rename from develop-user-data/.config/nvim/init.lua rename to .dotfiles/.config/nvim/init.lua diff --git a/develop-user-data/.config/nvim/lazy-lock.json b/.dotfiles/.config/nvim/lazy-lock.json similarity index 87% rename from develop-user-data/.config/nvim/lazy-lock.json rename to .dotfiles/.config/nvim/lazy-lock.json index 4f31822..e853360 100644 --- a/develop-user-data/.config/nvim/lazy-lock.json +++ b/.dotfiles/.config/nvim/lazy-lock.json @@ -3,14 +3,14 @@ "LazyVim": { "branch": "main", "commit": "3f034d0a7f58031123300309f2efd3bb0356ee21" }, "SchemaStore.nvim": { "branch": "main", "commit": "d521e71f9d5ac1c29a7653528d4e5c66ffe229c5" }, "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, - "blink.cmp": { "branch": "main", "commit": "cb5e346d9e0efa7a3eee7fd4da0b690c48d2a98e" }, + "blink.cmp": { "branch": "main", "commit": "4f38ce99a472932d5776337f08f7a8180f1f571a" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, - "catppuccin": { "branch": "main", "commit": "5b5e3aef9ad7af84f463d17b5479f06b87d5c429" }, + "catppuccin": { "branch": "main", "commit": "b7bbdf93b42866f166af98d39a2563eedb7cabac" }, "conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" }, "copilot.lua": { "branch": "master", "commit": "a5c390f8d8e85b501b22dcb2f30e0cbbd69d5ff0" }, "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "ee28ba3e70ecea811b8f6d7b51d81976e94b121c" }, + "gitsigns.nvim": { "branch": "main", "commit": "1796c7cedfe7e5dd20096c5d7b8b753d8f8d22eb" }, "grug-far.nvim": { "branch": "main", "commit": "6ff8a205a29db3a9b08e5debe09452b4d6fd6591" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, @@ -24,13 +24,13 @@ "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, "nui.nvim": { "branch": "main", "commit": "8d5b0b568517935d3c84f257f272ef004d9f5a59" }, "nvim-lint": { "branch": "master", "commit": "9dfb77ef6c5092a19502883c02dc5a02ec648729" }, - "nvim-lspconfig": { "branch": "master", "commit": "94d0fec9135719e046903bbbbf8f39e3d3436d4e" }, + "nvim-lspconfig": { "branch": "master", "commit": "46434074f188e6bfccf9d9153dd8be6b1381498b" }, "nvim-treesitter": { "branch": "master", "commit": "94ea4f436d2b59c80f02e293466c374584f03b8c" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ed373482db797bbf71bdff37a15c7555a84dce47" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "persistence.nvim": { "branch": "main", "commit": "166a79a55bfa7a4db3e26fc031b4d92af71d0b51" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "render-markdown.nvim": { "branch": "main", "commit": "bd5657594bf1a96b04f900c87e8d74226a54d832" }, + "render-markdown.nvim": { "branch": "main", "commit": "b2d857c848c2c27440c8e5efc8e49a9b5bcf13c6" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, diff --git a/develop-user-data/.config/nvim/lazyvim.json b/.dotfiles/.config/nvim/lazyvim.json similarity index 100% rename from develop-user-data/.config/nvim/lazyvim.json rename to .dotfiles/.config/nvim/lazyvim.json diff --git a/develop-user-data/.config/nvim/lua/config/autocmds.lua b/.dotfiles/.config/nvim/lua/config/autocmds.lua similarity index 100% rename from develop-user-data/.config/nvim/lua/config/autocmds.lua rename to .dotfiles/.config/nvim/lua/config/autocmds.lua diff --git a/develop-user-data/.config/nvim/lua/config/keymaps.lua b/.dotfiles/.config/nvim/lua/config/keymaps.lua similarity index 100% rename from develop-user-data/.config/nvim/lua/config/keymaps.lua rename to .dotfiles/.config/nvim/lua/config/keymaps.lua diff --git a/develop-user-data/.config/nvim/lua/config/lazy.lua b/.dotfiles/.config/nvim/lua/config/lazy.lua similarity index 100% rename from develop-user-data/.config/nvim/lua/config/lazy.lua rename to .dotfiles/.config/nvim/lua/config/lazy.lua diff --git a/develop-user-data/.config/nvim/lua/config/options.lua b/.dotfiles/.config/nvim/lua/config/options.lua similarity index 100% rename from develop-user-data/.config/nvim/lua/config/options.lua rename to .dotfiles/.config/nvim/lua/config/options.lua diff --git a/develop-user-data/.config/nvim/lua/plugins/example.lua b/.dotfiles/.config/nvim/lua/plugins/example.lua similarity index 100% rename from develop-user-data/.config/nvim/lua/plugins/example.lua rename to .dotfiles/.config/nvim/lua/plugins/example.lua diff --git a/develop-user-data/.config/nvim/stylua.toml b/.dotfiles/.config/nvim/stylua.toml similarity index 100% rename from develop-user-data/.config/nvim/stylua.toml rename to .dotfiles/.config/nvim/stylua.toml diff --git a/develop-user-data/.p10k.zsh b/.dotfiles/.p10k.zsh similarity index 100% rename from develop-user-data/.p10k.zsh rename to .dotfiles/.p10k.zsh diff --git a/develop-user-data/.zshrc b/.dotfiles/.zshrc similarity index 100% rename from develop-user-data/.zshrc rename to .dotfiles/.zshrc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac66881 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.dotfiles/.config/github-copilot/* +.dotfiles/.cache/* +.dotfiles/.local +.dotfiles/.npm +.dotfiles/.zcompdump-* +.dotfiles/.zsh_history + +.DS_Store diff --git a/Dockerfile b/Dockerfile index dc9bb58..9207358 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,43 +1,44 @@ -FROM node:22.15.0-alpine +#* Set the base image to Node.js LTS on Alpine +FROM node:lts-alpine #* Set metadata for image LABEL maintainer="ManghiDev " \ - description="Dockerfile for LazyVim and Zsh with Oh My Zsh" \ - version="0.1.0" + description="Dockerfile for LazyVim and Zsh with oh-my-zsh" \ + version="1.0.0" #* Install necessary dependencies RUN apk add --no-cache git lazygit fzf curl neovim ripgrep alpine-sdk zsh shadow -#* Create a new user 'develop' with home directory and grant sudo privileges -RUN useradd -m -s /bin/zsh develop && \ - echo "develop ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers +#* Create a new user 'developer' with home directory and grant sudo privileges +RUN useradd -m -s /bin/zsh developer && \ + echo "developer ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers -#* Switch to the 'develop' user for the rest of the setup -USER develop -WORKDIR /home/develop +#* Switch to the 'developer' user for the rest of the setup +USER developer +WORKDIR /home/developer -#* Install Oh My Zsh for the 'develop' user +#* Install Oh My Zsh for the 'developer' user RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" || true #* Install the zsh-autosuggestions plugin -RUN git clone https://github.com/zsh-users/zsh-autosuggestions /home/develop/.oh-my-zsh/custom/plugins/zsh-autosuggestions && \ - sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions)/' /home/develop/.zshrc +RUN git clone https://github.com/zsh-users/zsh-autosuggestions /home/developer/.oh-my-zsh/custom/plugins/zsh-autosuggestions && \ + sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions)/' /home/developer/.zshrc #* Install the Powerlevel10k theme -RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /home/develop/.oh-my-zsh/custom/themes/powerlevel10k && \ - sed -i 's/ZSH_THEME=".*"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' /home/develop/.zshrc +RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /home/developer/.oh-my-zsh/custom/themes/powerlevel10k && \ + sed -i 's/ZSH_THEME=".*"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' /home/developer/.zshrc -#* Clone LazyVim for the 'develop' user -RUN git clone https://github.com/LazyVim/starter /home/develop/.config/nvim +#* Clone LazyVim for the 'developer' user +RUN git clone https://github.com/LazyVim/starter /home/developer/.config/nvim #* Remove the .git folder, so you can add it to your own repo later -RUN rm -rf /home/develop/.config/nvim/.git +RUN rm -rf /home/developer/.config/nvim/.git -#* Ensure proper permissions for the 'develop' user -RUN chown -R develop:develop /home/develop +#* Ensure proper permissions for the 'developer' user +RUN chown -R developer:developer /home/developer #* Set the default working directory -WORKDIR /home/develop +WORKDIR /home/developer #* Set the default shell to Zsh CMD ["/bin/zsh"] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..95a878f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 manghidev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index d911c3c..7899b93 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,134 @@ # LazyVim Docker Environment -This repository provides a Dockerized environment for using LazyVim, Zsh with Oh My Zsh, and additional tools for development. It is designed to simplify the setup of a powerful and customizable code editor environment. +This project provides a Dockerized environment to use LazyVim, an advanced Neovim configuration, along with essential developer tools. + +--- ## Features -- **LazyVim**: Pre-configured Neovim setup with LazyVim. -- **Zsh with Oh My Zsh**: Includes plugins like `zsh-autosuggestions` and the `Powerlevel10k` theme. -- **Essential Tools**: Includes `git`, `lazygit`, `fzf`, `curl`, `neovim`, `ripgrep`, and more. -- **Persistent Configuration**: Root configuration is persisted using Docker volumes. -- **Customizable**: Easily extend or modify the setup to suit your needs. +- **LazyVim**: Predefined Neovim configuration to maximize productivity. +- **Dockerized**: Fully isolated and reproducible environment. +- **Zsh with Oh My Zsh**: Interactive shell with plugins and advanced customization. +- **Included tools**: `git`, `lazygit`, `fzf`, `ripgrep`, among others. +- **Volume mounting**: Direct access to your local files from the container. +- **Persistent configuration**: Configuration changes are retained between sessions. + +--- ## Requirements -- Docker -- Docker Compose +- **Docker**: Make sure Docker is installed on your system. +- **Docker Compose**: Required to manage the environment. -## Setup +--- -1. Clone this repository: -```sh -git clone https://github.com/manghidev/lazyvim-docker.git -cd lazyvim-docker +## Available Scripts + +- **`build.sh`**: Builds and configures the entire environment. +- **`init.sh`**: Access the container after exiting. +- **`destroy.sh`**: Stops and removes the containers but keeps the volumes. + +### Execution Permissions + +If the scripts do not have execution permissions, you can grant them using the following command, replacing `` with the script file you want to execute: + +```bash +chmod +x ./ ``` -2. Build and start the container: -```sh -docker compose up -d +For example, to grant execution permissions to `build.sh`: + +```bash +chmod +x ./build.sh ``` -3. Access the container: -```sh -docker exec -it lazyvim /bin/zsh +--- + +## Installation + +1. Clone this repository: + ```bash + git clone https://github.com/manghidev/lazyvim-docker.git + cd lazyvim-docker + ``` + +2. Build the environment using the `build.sh` script: + ```bash + ./build.sh + ``` + +3. If you need to re-enter the container, use the `init.sh` script: + ```bash + ./init.sh + ``` + +4. To destroy the environment (without deleting the volumes), use the `destroy.sh` script: + ```bash + ./destroy.sh + ``` + +--- + +## Usage + +- **Edit files**: Use LazyVim to edit your files directly from the container. +- **Customize configuration**: Modify the files in `/root/.config/nvim` to adjust LazyVim to your needs. +- **Persistence**: Configuration changes are automatically saved thanks to the Docker volume. + +--- + +## Volume Configuration + +You can edit the volumes in the `docker-compose.yml` file to add a documents folder or a USB drive according to your needs. By default, the following configurations are included: + +### Documents Directory on macOS +Mount the user's Documents directory on macOS inside the container: +```yaml +- $HOME/Documents:/home/developer/Documents ``` -## Directory Structure +### Documents Directory on Linux +If you are using Linux, you can mount the user's Documents directory: +```yaml +- /home/user/Documents:/home/developer/Documents +``` + +### USB Drive on macOS +To mount a USB drive on macOS, use the following configuration: +```yaml +- /Volumes/sdb1:/home/developer/usb +``` -- `$HOME/Documents` is mounted to `/home/develop/Documents` inside the container. -- `/Volumes/ExternalSSD/Work` is mounted to `/home/develop/Work`. -- `/Volumes/ExternalSSD/Personal` is mounted to `/home/develop/Personal`. +### USB Drive on Linux +If you need to mount a USB drive on Linux, use this configuration: +```yaml +- /dev/sdb2:/home/developer/usb +``` -## Persistent Configuration +### Customization Example +If you want to add a specific directory where you store your projects, you can edit the `docker-compose.yml` file and add a line like this: +```yaml +- /path/to/your/project:/home/developer/projects +``` +This will mount the `/path/to/your/project` directory from your local system into the container at `/home/developer/projects`. -The root configuration is stored in a Docker volume named `root-config`. This ensures that your Zsh and LazyVim configurations persist across container restarts. +### Note +You can modify these paths directly in the `docker-compose.yml` file to adapt them to your operating system and specific needs. Make sure the local paths exist on your system before starting the container. -## Customization +--- -- **Oh My Zsh Plugins**: Modify the `.zshrc` file to add or remove plugins. -- **LazyVim Configuration**: Edit the files in `/root/.config/nvim` to customize LazyVim. +## Contributions -## Included Tools +Contributions are welcome! If you have ideas or improvements, feel free to open an issue or submit a pull request. -- **LazyVim**: A pre-configured Neovim setup. -- **Oh My Zsh**: A framework for managing Zsh configuration. -- **Powerlevel10k**: A fast and customizable Zsh theme. -- **fzf**: A command-line fuzzy finder. -- **lazygit**: A simple terminal UI for Git commands. -- **ripgrep**: A fast search tool. +--- ## License -This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. + +--- ## Author -Created by ManghiDev. For more information, visit [https://manghi.dev](https://manghi.dev). \ No newline at end of file +Created by ManghiDev. For more information, visit [manghi.dev](https://manghi.dev). \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..507bff9 --- /dev/null +++ b/build.sh @@ -0,0 +1,16 @@ +echo "Cleaning up the environment" +docker compose down --rmi all + +echo "Pulling the latest images" +docker compose pull + +echo "Rebuilding the container" +docker compose build --no-cache + +echo "Starting the container" +docker compose up --force-recreate -d + +echo "Opening a shell in the container" +docker exec -it lazyvim zsh + +echo "Process completed. Container is running" diff --git a/destroy.sh b/destroy.sh new file mode 100755 index 0000000..d416499 --- /dev/null +++ b/destroy.sh @@ -0,0 +1,4 @@ +# Stop and remove the container +docker compose down --rmi all + +echo "Container stopped and removed" \ No newline at end of file diff --git a/develop-user-data/.config/github-copilot/versions.json b/develop-user-data/.config/github-copilot/versions.json deleted file mode 100644 index 743d353..0000000 --- a/develop-user-data/.config/github-copilot/versions.json +++ /dev/null @@ -1 +0,0 @@ -{"copilot.lua":"1.308.0"} diff --git a/develop-user-data/.config/nvim/.gitignore b/develop-user-data/.config/nvim/.gitignore deleted file mode 100644 index cc5457a..0000000 --- a/develop-user-data/.config/nvim/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -tt.* -.tests -doc/tags -debug -.repro -foo.* -*.log -data diff --git a/docker-compose.yml b/docker-compose.yml index add68d2..aa8332c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,19 +5,17 @@ services: dockerfile: Dockerfile container_name: lazyvim volumes: - #* Mount volume for oh-my-zsh - - develop-data:/home/develop + - .dotfiles/.zshrc:/home/developer/.zshrc + - .dotfiles/.p10k.zsh:/home/developer/.p10k.zsh + - .dotfiles/.config/nvim:/home/developer/.config/nvim - #* Mount the user's Documents directory - - $HOME/Documents:/home/develop/Documents - #* Mount the Work directory - - /Volumes/ExternalSSD/Work:/home/develop/Work - #* Mount the Personal directory - - /Volumes/ExternalSSD/Personal:/home/develop/Personal + #* Mount the user's Documents directory in macOS + - $HOME/Documents:/home/developer/Documents + #* Mount the user's Documents directory in Linux + # - /home/user/Documents:/home/developer/Documents + #* Mount the user's USB in macOS + #- /Volumes/sdb1:/home/developer/usb + #* Mount the user's USB in Linux + #- /dev/sdb2:/home/developer/usb stdin_open: true - tty: true - -volumes: - #* Volume for persistent data - develop-data: - driver: local + tty: true \ No newline at end of file diff --git a/init.sh b/init.sh index 1a247d6..ced7721 100755 --- a/init.sh +++ b/init.sh @@ -1,35 +1,2 @@ -# Volume name and backup directory -VOLUME_NAME="lazyvim-docker_develop-data" -BACKUP_DIR="./develop-user-data" - -echo "=== Starting selective backup of volume $VOLUME_NAME ===" - -# Create the backup directory if it doesn't exist -mkdir -p $BACKUP_DIR - -# Copy only the specified files and folders from the volume to the backup directory -docker run --rm \ - -v $VOLUME_NAME:/data \ - -v $(pwd)/$BACKUP_DIR:/backup \ - alpine sh -c " - cd /data && \ - tar -cf - \ - .zshrc \ - .p10k.zsh \ - .config | tar -xf - -C /backup/" - -echo "=== Backup completed. Selected data has been saved to $BACKUP_DIR ===" - -# Clean up the environment -echo "=== Cleaning up the environment ===" -docker compose down --rmi all - -# Rebuild the container -echo "=== Rebuilding the container ===" -docker compose build --no-cache - -# Start the container -echo "=== Starting the container ===" -docker compose up --force-recreate -d - -echo "=== Process completed. Container is running ===" \ No newline at end of file +echo "Enter to the lazyvim container" +docker exec -it lazyvim zsh diff --git a/restore.sh b/restore.sh deleted file mode 100755 index 36095ea..0000000 --- a/restore.sh +++ /dev/null @@ -1,40 +0,0 @@ -# Volume name and backup directory -VOLUME_NAME="lazyvim-docker_develop-data" -BACKUP_DIR="./develop-user-data" - -echo "=== Starting restoration process ===" - -# Step 1: Execute the init.sh script to initialize the environment -echo "=== Executing init.sh to initialize the environment ===" -bash ./init.sh - -# Step 2: Check if the backup directory exists -if [ ! -d $BACKUP_DIR ]; then - echo "Error: The backup directory $BACKUP_DIR does not exist. Cannot restore." - exit 1 -fi - -# Step 3: Check if the backup directory is empty -if [ -z "$(ls -A $BACKUP_DIR)" ]; then - echo "Error: The backup directory $BACKUP_DIR is empty. Cannot restore." - exit 1 -fi - -# Step 4: Restore only the specified files and folders to the volume -echo "=== Restoring data to volume $VOLUME_NAME ===" -docker run --rm \ - -v $VOLUME_NAME:/data \ - -v $(pwd)/$BACKUP_DIR:/backup \ - alpine sh -c " - cd /backup && \ - cp -r .zshrc .p10k.zsh .config /data/" - -# Step 6: Fix permissions specifically for .config/nvim -echo "=== Fixing permissions for .config/nvim ===" -docker run --rm \ - -v $VOLUME_NAME:/data \ - alpine sh -c " - chown -R 1000:1000 /data/.config/nvim && \ - chmod -R u+rwX /data/.config/nvim" - -echo "=== Restoration completed. Data has been copied to volume $VOLUME_NAME ===" \ No newline at end of file