From afd56691a762b06d357138b0d710dffe958d0a51 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Mon, 5 May 2025 12:13:12 -0600 Subject: [PATCH 01/14] feat: add lazgit config file for improved environment setup --- .dotfiles/.config/lazygit/config.yml | 106 ++++++++++++++++++++++++++ .dotfiles/.config/nvim/lazy-lock.json | 10 +-- docker-compose.yml | 1 + 3 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 .dotfiles/.config/lazygit/config.yml diff --git a/.dotfiles/.config/lazygit/config.yml b/.dotfiles/.config/lazygit/config.yml new file mode 100644 index 0000000..74b686a --- /dev/null +++ b/.dotfiles/.config/lazygit/config.yml @@ -0,0 +1,106 @@ +# Specify the current working directory path +# the default is the current working directory path +cwd: null + +# Export additional ENV variables +env: + recording: true + +# Explicitly set the number of columns +# or use `auto` to take the current +# number of columns of your shell +cols: 120 # 100 + +# Explicitly set the number of rows +# or use `auto` to take the current +# number of rows of your shell +rows: 35 # 30 + +# Amount of times to repeat GIF +# If value is -1, play once +# If value is 0, loop indefinitely +# If value is a positive number, loop n times +repeat: 0 + +# Quality +# 1 - 100 +# Higher quality seems to make no difference, but running it through +# gifsicle ends up with a much better compressed version. +quality: 100 + +# Delay between frames in ms +# If the value is `auto` use the actual recording delays +frameDelay: auto + +# Maximum delay between frames in ms +# Ignored if the `frameDelay` isn't set to `auto` +# Set to `auto` to prevent limiting the max idle time +maxIdleTime: 2000 + +# The surrounding frame box +# The `type` can be null, window, floating, or solid` +# To hide the title use the value null +# Don't forget to add a backgroundColor style with a null as type +frameBox: + type: floating + title: Lazygit + style: + border: 0px black solid + backgroundColor: "#1d1d1d" + margin: -5px + +# Add a watermark image to the rendered gif +# You need to specify an absolute path for +# the image on your machine or a URL, and you can also +# add your own CSS styles +watermark: + imagePath: null + style: + position: absolute + right: 15px + bottom: 15px + width: 100px + opacity: 0.9 + +# Cursor style can be one of +# `block`, `underline`, or `bar` +cursorStyle: block + +# Font family +# You can use any font that is installed on your machine +# in CSS-like syntax +# Download from: +# https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/DejaVuSansMono.zip +# Not using the mono font because it makes icons too small. +fontFamily: "DejaVuSansM Nerd Font" + +# The size of the font +fontSize: 8 + +# The height of lines +lineHeight: 1 + +# The spacing between letters +letterSpacing: 0 + +# Theme +theme: + background: "transparent" + foreground: "#dddad6" + cursor: "#c7c7c7" + black: "#7a7a7a" + red: "#fc4384" + green: "#b3e33b" + yellow: "#ffa727" + blue: "#102895" + magenta: "#c930c7" + cyan: "#00c5c7" + white: "#c7c7c7" + brightBlack: "#676767" + brightRed: "#ff7fac" + brightGreen: "#c8ed71" + brightYellow: "#ebdf86" + brightBlue: "#6871ff" + brightMagenta: "#ff76ff" + brightCyan: "#5ffdff" + brightWhite: "#fffefe" diff --git a/.dotfiles/.config/nvim/lazy-lock.json b/.dotfiles/.config/nvim/lazy-lock.json index a120e0d..3c9bdea 100644 --- a/.dotfiles/.config/nvim/lazy-lock.json +++ b/.dotfiles/.config/nvim/lazy-lock.json @@ -5,12 +5,12 @@ "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, "blink.cmp": { "branch": "main", "commit": "4f38ce99a472932d5776337f08f7a8180f1f571a" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, - "catppuccin": { "branch": "main", "commit": "b7bbdf93b42866f166af98d39a2563eedb7cabac" }, + "catppuccin": { "branch": "main", "commit": "1bf070129c0b6f77cc23f6a2212dcdc868308c52" }, "conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" }, - "copilot.lua": { "branch": "master", "commit": "a5c390f8d8e85b501b22dcb2f30e0cbbd69d5ff0" }, + "copilot.lua": { "branch": "master", "commit": "ce230868c1b453882d1147ceeede5dee1cafc89d" }, "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "1796c7cedfe7e5dd20096c5d7b8b753d8f8d22eb" }, + "gitsigns.nvim": { "branch": "main", "commit": "056d5ea359efe35c4e25e2ebcc255117ac86500d" }, "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": "f535005e6ad1016383f24e39559833759453564e" }, "nvim-lint": { "branch": "master", "commit": "9dfb77ef6c5092a19502883c02dc5a02ec648729" }, - "nvim-lspconfig": { "branch": "master", "commit": "1b801f68d09e70e59e6dd967b663b6d84ee3e87d" }, + "nvim-lspconfig": { "branch": "master", "commit": "4bc481b6f0c0cf3671fc894debd0e00347089a4e" }, "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": "b2d857c848c2c27440c8e5efc8e49a9b5bcf13c6" }, + "render-markdown.nvim": { "branch": "main", "commit": "fa92c30f59afa980708e110824ff0933bc0954e5" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, diff --git a/docker-compose.yml b/docker-compose.yml index 436249b..aef804f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: volumes: - .dotfiles/.zshrc:/home/developer/.zshrc - .dotfiles/.p10k.zsh:/home/developer/.p10k.zsh + - .dotfiles/.config/lazygit:/home/developer/.config/lazygit - .dotfiles/.config/nvim:/home/developer/.config/nvim #* Mount the user's Documents directory in macOS From 7d24373a49a9879f3be126de0b9c8977356be6c4 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Mon, 5 May 2025 12:13:53 -0600 Subject: [PATCH 02/14] fix: correct formatting of commented USB mount paths in docker-compose.yml --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index aef804f..d29f74e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,8 +17,8 @@ services: #* 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 + # - /Volumes/sdb1:/home/developer/usb #* Mount the user's USB in Linux - #- /dev/sdb2:/home/developer/usb + # - /dev/sdb2:/home/developer/usb stdin_open: true tty: true \ No newline at end of file From 3b9f91f06ec304ccef3fccdce716c141eb6992dc Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 11:10:35 -0600 Subject: [PATCH 03/14] feat: update lazy-lock.json with new plugin commits and add snacks.lua configuration for dashboard --- .dotfiles/.config/nvim/lazy-lock.json | 20 +++++++------ .dotfiles/.config/nvim/lazyvim.json | 2 ++ .dotfiles/.config/nvim/lua/config/snacks.lua | 30 ++++++++++++++++++++ 3 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 .dotfiles/.config/nvim/lua/config/snacks.lua diff --git a/.dotfiles/.config/nvim/lazy-lock.json b/.dotfiles/.config/nvim/lazy-lock.json index 3c9bdea..6f37e12 100644 --- a/.dotfiles/.config/nvim/lazy-lock.json +++ b/.dotfiles/.config/nvim/lazy-lock.json @@ -1,36 +1,38 @@ { "CopilotChat.nvim": { "branch": "main", "commit": "75653259442a8eb895abfc70d7064e07aeb7134c" }, "LazyVim": { "branch": "main", "commit": "3f034d0a7f58031123300309f2efd3bb0356ee21" }, - "SchemaStore.nvim": { "branch": "main", "commit": "d521e71f9d5ac1c29a7653528d4e5c66ffe229c5" }, + "SchemaStore.nvim": { "branch": "main", "commit": "ea5687d7e8af3ce6678dd03d3a1bd109b5c618b7" }, "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, "blink.cmp": { "branch": "main", "commit": "4f38ce99a472932d5776337f08f7a8180f1f571a" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "catppuccin": { "branch": "main", "commit": "1bf070129c0b6f77cc23f6a2212dcdc868308c52" }, "conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" }, - "copilot.lua": { "branch": "master", "commit": "ce230868c1b453882d1147ceeede5dee1cafc89d" }, + "copilot.lua": { "branch": "master", "commit": "7ba73866b9b3c696f80579c470c6eec374d3acec" }, "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "056d5ea359efe35c4e25e2ebcc255117ac86500d" }, - "grug-far.nvim": { "branch": "main", "commit": "6ff8a205a29db3a9b08e5debe09452b4d6fd6591" }, + "fzf-lua": { "branch": "main", "commit": "02def6b972d7687866738d6f6a5f4839ce5b5a7a" }, + "gitsigns.nvim": { "branch": "main", "commit": "43b0c856ae5f32a195d83f4a27fe21d63e6c966c" }, + "grug-far.nvim": { "branch": "main", "commit": "b91e6d4bad441dcaeda3d0c6df45ed270443b60a" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, "lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, - "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "d39a75bbce4b8aad5d627191ea915179c77c100f" }, + "mason.nvim": { "branch": "main", "commit": "7c7318e8bae7e3536ef6b9e86b9e38e74f2e125e" }, "mini.ai": { "branch": "main", "commit": "e139eb1101beb0250fea322f8c07a42f0f175688" }, "mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" }, "mini.pairs": { "branch": "main", "commit": "69864a2efb36c030877421634487fd90db1e4298" }, + "neo-tree.nvim": { "branch": "main", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, "nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" }, "nvim-lint": { "branch": "master", "commit": "9dfb77ef6c5092a19502883c02dc5a02ec648729" }, "nvim-lspconfig": { "branch": "master", "commit": "4bc481b6f0c0cf3671fc894debd0e00347089a4e" }, - "nvim-treesitter": { "branch": "master", "commit": "94ea4f436d2b59c80f02e293466c374584f03b8c" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "ed373482db797bbf71bdff37a15c7555a84dce47" }, + "nvim-treesitter": { "branch": "master", "commit": "28d480e0624b259095e56f353ec911f9f2a0f404" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "0e3be38005e9673d044e994b1e4b123adb040179" }, "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": "fa92c30f59afa980708e110824ff0933bc0954e5" }, + "render-markdown.nvim": { "branch": "main", "commit": "ff577b44bd3ab642acec0f134a7bf26b7278d137" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, diff --git a/.dotfiles/.config/nvim/lazyvim.json b/.dotfiles/.config/nvim/lazyvim.json index 9f9da5c..cf792f0 100644 --- a/.dotfiles/.config/nvim/lazyvim.json +++ b/.dotfiles/.config/nvim/lazyvim.json @@ -2,6 +2,8 @@ "extras": [ "lazyvim.plugins.extras.ai.copilot", "lazyvim.plugins.extras.ai.copilot-chat", + "lazyvim.plugins.extras.editor.fzf", + "lazyvim.plugins.extras.editor.neo-tree", "lazyvim.plugins.extras.lang.angular", "lazyvim.plugins.extras.lang.astro", "lazyvim.plugins.extras.lang.docker", diff --git a/.dotfiles/.config/nvim/lua/config/snacks.lua b/.dotfiles/.config/nvim/lua/config/snacks.lua new file mode 100644 index 0000000..205f64a --- /dev/null +++ b/.dotfiles/.config/nvim/lua/config/snacks.lua @@ -0,0 +1,30 @@ +opts = { + dashboard = { + preset = { + pick = function(cmd, opts) + return LazyVim.pick(cmd, opts)() + end, + header = [[ + ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ + ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z + ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z + ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ +]], + -- stylua: ignore + ---@type snacks.dashboard.Item[] + keys = { + { icon = " ", key = "f", desc = "Find File", action = ":lua Snacks.dashboard.pick('files')" }, + { icon = " ", key = "n", desc = "New File", action = ":ene | startinsert" }, + { icon = " ", key = "g", desc = "Find Text", action = ":lua Snacks.dashboard.pick('live_grep')" }, + { icon = " ", key = "r", desc = "Recent Files", action = ":lua Snacks.dashboard.pick('oldfiles')" }, + { icon = " ", key = "c", desc = "Config", action = ":lua Snacks.dashboard.pick('files', {cwd = vim.fn.stdpath('config')})" }, + { icon = " ", key = "s", desc = "Restore Session", section = "session" }, + { icon = " ", key = "x", desc = "Lazy Extras", action = ":LazyExtras" }, + { icon = "󰒲 ", key = "l", desc = "Lazy", action = ":Lazy" }, + { icon = " ", key = "q", desc = "Quit", action = ":qa" }, + }, + }, + }, + }: From 6f8255bc3fd3dd83bc3da3eb9b0734da40ea1896 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 11:33:57 -0600 Subject: [PATCH 04/14] Bump version to 2.0.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1cc5f65..227cea2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 \ No newline at end of file +2.0.0 From e8bde37bc5cfafd203fba18d1f98af0b4ed66e20 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 12:58:22 -0600 Subject: [PATCH 05/14] feat: Update version to 1.1.0 and remove obsolete scripts - Updated VERSION file to 1.1.0 - Removed build.sh, destroy.sh, init.sh, and added Makefile for better command management - Enhanced docker-compose.yml with named volumes and improved environment variables - Added docker-compose.dev.yml for development mode with mounted workspace - Created comprehensive documentation in CHANGELOG.md and COMMANDS.md - Introduced new scripts for health checks, version bumping, and setup - Improved logging and error handling in scripts - Added backup and restore functionality for dotfiles --- .gitignore | 38 ++++++ Dockerfile | 55 +++++++- Makefile | 108 ++++++++++++++++ README.md | 276 +++++++++++++++++++++++++++------------- VERSION | 2 +- build.sh | 18 --- destroy.sh | 5 - docker-compose.dev.yml | 7 + docker-compose.yml | 55 +++++++- docs/CHANGELOG.md | 65 ++++++++++ docs/COMMANDS.md | 187 +++++++++++++++++++++++++++ init.sh | 5 - scripts/build.sh | 103 +++++++++++++++ scripts/bump-version.sh | 68 ++++++++++ scripts/destroy.sh | 79 ++++++++++++ scripts/health-check.sh | 165 ++++++++++++++++++++++++ scripts/init.sh | 84 ++++++++++++ scripts/setup.sh | 239 ++++++++++++++++++++++++++++++++++ 18 files changed, 1431 insertions(+), 128 deletions(-) create mode 100644 Makefile delete mode 100755 build.sh delete mode 100755 destroy.sh create mode 100644 docker-compose.dev.yml create mode 100644 docs/CHANGELOG.md create mode 100644 docs/COMMANDS.md delete mode 100755 init.sh create mode 100755 scripts/build.sh create mode 100755 scripts/bump-version.sh create mode 100755 scripts/destroy.sh create mode 100755 scripts/health-check.sh create mode 100755 scripts/init.sh create mode 100755 scripts/setup.sh diff --git a/.gitignore b/.gitignore index ac66881..66c267c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# LazyVim Docker - Git Ignore + +# Dotfiles - sensitive or user-specific data .dotfiles/.config/github-copilot/* .dotfiles/.cache/* .dotfiles/.local @@ -5,4 +8,39 @@ .dotfiles/.zcompdump-* .dotfiles/.zsh_history +# Backup files +backups/ +*.backup +*.bak + +# Temporary files +*.tmp +*.temp +.temp/ + +# OS specific files .DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Docker specific +.docker/ + +# Logs +*.log +logs/ + +# Environment files +.env.local +.env.*.local diff --git a/Dockerfile b/Dockerfile index 882c987..e4c50e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,11 +8,30 @@ LABEL maintainer="ManghiDev " \ description="Dockerfile for LazyVim and Zsh with oh-my-zsh" \ version=$VERSION -#* Install necessary dependencies -RUN apk add --no-cache git lazygit fzf curl neovim ripgrep alpine-sdk zsh shadow +#* Install necessary dependencies and development tools +RUN apk add --no-cache \ + # Core tools + git lazygit fzf curl neovim ripgrep alpine-sdk zsh sudo \ + # Additional development tools + tmux tree htop unzip zip \ + # Language tools + python3 py3-pip \ + # Network tools + openssh-client wget \ + # Build tools + make cmake g++ \ + # Text processing + jq yq sed gawk grep \ + # Terminal enhancements + bat exa fd github-cli \ + # Python packages via apk (more stable on Alpine) + && apk add --no-cache py3-requests py3-beautifulsoup4 \ + # Install some Python tools that need pip + && pip3 install --break-system-packages --no-cache-dir \ + black flake8 mypy pytest pandas #* Create a new user 'developer' with home directory and grant sudo privileges -RUN useradd -m -s /bin/zsh developer && \ +RUN adduser -D -s /bin/zsh developer && \ echo "developer ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers #* Switch to the 'developer' user for the rest of the setup @@ -22,9 +41,11 @@ WORKDIR /home/developer #* 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 +#* Install useful zsh plugins 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 + git clone https://github.com/zsh-users/zsh-syntax-highlighting /home/developer/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && \ + git clone https://github.com/zsh-users/zsh-completions /home/developer/.oh-my-zsh/custom/plugins/zsh-completions && \ + sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions)/' /home/developer/.zshrc #* Install the Powerlevel10k theme RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /home/developer/.oh-my-zsh/custom/themes/powerlevel10k && \ @@ -36,8 +57,28 @@ 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/developer/.config/nvim/.git -#* Ensure proper permissions for the 'developer' user -RUN chown -R developer:developer /home/developer +#* Create useful aliases in .zshrc +RUN echo 'alias ll="exa -la"' >> /home/developer/.zshrc && \ + echo 'alias cat="bat"' >> /home/developer/.zshrc && \ + echo 'alias find="fd"' >> /home/developer/.zshrc && \ + echo 'alias vim="nvim"' >> /home/developer/.zshrc && \ + echo 'alias vi="nvim"' >> /home/developer/.zshrc && \ + echo 'alias lg="lazygit"' >> /home/developer/.zshrc + +#* Add helpful environment variables +RUN echo 'export EDITOR=nvim' >> /home/developer/.zshrc && \ + echo 'export VISUAL=nvim' >> /home/developer/.zshrc && \ + echo 'export PAGER=bat' >> /home/developer/.zshrc + +#* Switch back to root to fix permissions and create directories +USER root + +#* Create cache directories and ensure proper permissions +RUN mkdir -p /home/developer/.cache /home/developer/.local/share && \ + chown -R developer:developer /home/developer + +#* Switch back to developer user +USER developer #* Set the default working directory WORKDIR /home/developer diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e5797ac --- /dev/null +++ b/Makefile @@ -0,0 +1,108 @@ +# LazyVim Docker - Makefile +# Provides easy-to-use commands for managing the LazyVim Docker environment + +.PHONY: help build start enter stop destroy clean status update logs backup restore dev quick version bump-version + +# Default target +.DEFAULT_GOAL := help + +# Colors for output +RED := \033[0;31m +GREEN := \033[0;32m +YELLOW := \033[1;33m +BLUE := \033[0;34m +NC := \033[0m # No Color + +# Read version from VERSION file +VERSION := $(shell cat VERSION 2>/dev/null || echo "1.0.0") +CONTAINER_NAME := lazyvim +COMPOSE_FILE := docker-compose.yml + +help: ## Show this help message + @echo "$(BLUE)LazyVim Docker Environment - Available Commands$(NC)" + @echo "" + @awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*##/ { printf "$(GREEN)%-15s$(NC) %s\n", $$1, $$2 }' $(MAKEFILE_LIST) + @echo "" + @echo "$(YELLOW)Current version: $(VERSION)$(NC)" + +build: ## Build the Docker environment (clean build) + @echo "$(BLUE)Building LazyVim Docker environment v$(VERSION)...$(NC)" + @./scripts/build.sh + +start: ## Start the container (if already built) + @echo "$(BLUE)Starting LazyVim container...$(NC)" + @./scripts/init.sh + +enter: ## Enter the running container + @echo "$(BLUE)Entering LazyVim container...$(NC)" + @docker exec -it $(CONTAINER_NAME) zsh 2>/dev/null || { \ + echo "$(RED)Container not running. Starting it first...$(NC)"; \ + make start; \ + } + +stop: ## Stop the container (keeps volumes) + @echo "$(YELLOW)Stopping LazyVim container...$(NC)" + @docker compose stop + @echo "$(GREEN)Container stopped$(NC)" + +destroy: ## Destroy everything (container, images, and volumes) + @echo "$(RED)Destroying LazyVim environment...$(NC)" + @./scripts/destroy.sh + +clean: ## Clean up unused Docker resources + @echo "$(YELLOW)Cleaning up Docker resources...$(NC)" + @docker system prune -f + @docker volume prune -f + @echo "$(GREEN)Cleanup completed$(NC)" + +status: ## Show container status + @echo "$(BLUE)Container Status:$(NC)" + @docker compose ps + @echo "" + @echo "$(BLUE)Container Info:$(NC)" + @docker inspect $(CONTAINER_NAME) --format='{{.State.Status}}' 2>/dev/null | \ + sed 's/running/$(GREEN)Running$(NC)/' | \ + sed 's/exited/$(RED)Stopped$(NC)/' || echo "$(RED)Not found$(NC)" + +logs: ## Show container logs + @echo "$(BLUE)Container Logs:$(NC)" + @docker compose logs -f --tail=50 + +update: ## Update to latest version and rebuild + @echo "$(BLUE)Updating LazyVim environment...$(NC)" + @git pull origin main || echo "$(YELLOW)Could not pull latest changes$(NC)" + @make build + +backup: ## Backup dotfiles and configuration + @echo "$(BLUE)Creating backup of configuration...$(NC)" + @mkdir -p backups + @tar -czf backups/dotfiles-backup-$(shell date +%Y%m%d-%H%M%S).tar.gz .dotfiles/ + @echo "$(GREEN)Backup created in backups/ directory$(NC)" + +restore: ## Restore from backup (requires BACKUP_FILE variable) + @if [ -z "$(BACKUP_FILE)" ]; then \ + echo "$(RED)Please specify BACKUP_FILE. Example: make restore BACKUP_FILE=backups/dotfiles-backup-20231201-120000.tar.gz$(NC)"; \ + exit 1; \ + fi + @echo "$(YELLOW)Restoring from $(BACKUP_FILE)...$(NC)" + @tar -xzf $(BACKUP_FILE) + @echo "$(GREEN)Restore completed$(NC)" + +dev: ## Development mode - start with current directory mounted + @echo "$(BLUE)Starting in development mode...$(NC)" + @docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d + @docker exec -it $(CONTAINER_NAME) zsh + +quick: ## Quick start - build and enter in one command + @echo "$(BLUE)Quick start: building and entering container...$(NC)" + @make build && make enter + +version: ## Show current version + @echo "$(GREEN)Current version: $(VERSION)$(NC)" + +bump-version: ## Bump version (patch, minor, major) + @if [ -z "$(TYPE)" ]; then \ + echo "$(RED)Please specify TYPE. Example: make bump-version TYPE=patch$(NC)"; \ + exit 1; \ + fi + @./scripts/bump-version.sh $(TYPE) diff --git a/README.md b/README.md index f394e76..8bcd0dd 100644 --- a/README.md +++ b/README.md @@ -1,165 +1,265 @@ # LazyVim Docker Environment -This project provides a Dockerized environment to use LazyVim, an advanced Neovim configuration, along with essential developer tools. +A professional Dockerized environment for LazyVim (advanced Neovim configuration) with essential developer tools. Perfect for development without installing anything on your host machine! --- -## Features +## 🚀 Quick Start -- **LazyVim**: Predefined Neovim configuration to maximize productivity. -- **Dockerized**: Fully isolated and reproducible environment. -- **bash with Oh My bash**: 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. +### One-Line Installation (Recommended) +```bash +git clone https://github.com/manghidev/lazyvim-docker.git && cd lazyvim-docker && make quick +``` + +### Manual Installation +```bash +git clone https://github.com/manghidev/lazyvim-docker.git +cd lazyvim-docker +make build # Build the environment +make enter # Enter the container +``` --- -## Versioning +## ✨ Features + +- **LazyVim**: Predefined Neovim configuration for maximum productivity +- **Dockerized**: Fully isolated and reproducible environment +- **Rich Terminal**: Zsh with Oh My Zsh, Powerlevel10k theme, and useful plugins +- **40+ Developer Tools**: git, lazygit, tmux, python, node.js, and many more +- **Easy Management**: Simple make commands for all operations +- **Persistent Configuration**: All changes are saved between sessions +- **Cross-Platform**: Works on macOS and Linux -This project uses a global version stored in the `VERSION` file located in the root of the repository. The version is used during the Docker image build process and is embedded as metadata in the image. +--- -### How to Update the Version +## � Main Commands -1. Open the `VERSION` file in the root of the project. -2. Update the version number (e.g., change `1.1.0` to `1.2.0`). -3. Rebuild the Docker image using the `build.sh` script: ```bash -./build.sh - ``` +make help # Show all available commands +make quick # Quick start - build and enter in one command +make build # Build the Docker environment +make enter # Enter the running container +make stop # Stop the container +make destroy # Destroy everything +make status # Check environment status +make backup # Backup your configuration +``` + +For a complete list of commands, see: **[📖 Commands Reference](docs/COMMANDS.md)** + +--- -### Checking the Version in the Docker Image +## 🔧 Configuration -After building the image, you can verify the version embedded in the image by running: +### Volume Mounting +By default, your `Documents` folder is mounted. Edit `docker-compose.yml` to add more directories: +```yaml +volumes: + # Already included + - $HOME/Documents:/home/developer/Documents + + # Add your project directories + - $HOME/Projects:/home/developer/Projects + - $HOME/Developer:/home/developer/Developer +``` + +### Initial Setup +Run the interactive setup for personalized configuration: ```bash -docker inspect lazyvim | grep '"version"' +make build # First build the environment ``` --- -## Requirements +## 📁 Project Structure -- **Docker**: Make sure Docker is installed on your system. -- **Docker Compose**: Required to manage the environment. +``` +lazyvim-docker/ +├── Makefile # Main command interface +├── docker-compose.yml # Docker configuration +├── Dockerfile # Container definition +├── VERSION # Current version +├── docs/ # Documentation +│ ├── COMMANDS.md # Complete command reference +│ └── CHANGELOG.md # Version history +├── scripts/ # Internal scripts (use make commands instead) +│ ├── build.sh # Build script +│ ├── init.sh # Init script +│ ├── destroy.sh # Destroy script +│ ├── setup.sh # Interactive setup +│ ├── health-check.sh # Environment diagnostics +│ └── bump-version.sh # Version management +└── .dotfiles/ # Persistent configuration + ├── .zshrc # Shell configuration + ├── .p10k.zsh # Theme configuration + └── .config/ # App configurations + ├── nvim/ # Neovim/LazyVim + └── lazygit/ # Git TUI +``` --- -## Available Scripts +## �️ Included Tools + +**Core Development:** +- Neovim with LazyVim configuration +- Git + Lazygit (Git TUI) +- Node.js LTS + npm +- Python 3 + pip with dev packages -- **`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. +**Terminal Enhancement:** +- Zsh with Oh My Zsh + Powerlevel10k +- fzf (fuzzy finder), ripgrep (fast search) +- bat (better cat), exa (better ls), fd (better find) +- tmux (terminal multiplexer) -### Execution Permissions +**System Tools:** +- htop, tree, curl, wget +- make, cmake, g++ +- jq, yq (JSON/YAML processors) -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: +--- + +## 🩺 Health & Maintenance ```bash -chmod +x ./ +make status # Check container status +make backup # Backup configurations +make clean # Clean up Docker resources ``` -For example, to grant execution permissions to `build.sh`: - +For detailed diagnostics: ```bash -chmod +x ./build.sh +# Internal health check (comprehensive diagnostics) +./scripts/health-check.sh ``` --- -## Installation - -### Automatic Installation -If you want to automate the installation process, run the following command. This will clone the repository, navigate to the project folder, grant execution permissions to the scripts, and build the environment: +## 🔄 Version Management ```bash -git clone https://github.com/manghidev/lazyvim-docker.git && cd lazyvim-docker && chmod +x ./build.sh ./init.sh ./destroy.sh && ./build.sh +make version # Show current version +make bump-version TYPE=patch # Bump version (patch/minor/major) ``` -### Manual Installation -1. Clone this repository: -```bash -git clone https://github.com/manghidev/lazyvim-docker.git -cd lazyvim-docker -``` +--- + +## 🐛 Troubleshooting -2. Build the environment using the `build.sh` script (Only the first time, or when you want to update the image, as it will erase everything and rebuild everything): +**Container won't start:** ```bash -./build.sh +make status # Check what's wrong +make destroy # Nuclear option: rebuild everything +make build ``` -3. If you need to re-enter or run the container again, use the `init.sh` script: +**Need fresh start:** ```bash -./init.sh +make destroy && make build ``` -4. To destroy the environment (along with the volumes), use the `destroy.sh` script: +**Performance issues:** ```bash -./destroy.sh +make clean # Free up disk space ``` --- -## Usage +## 📚 Documentation -- **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. +- **[📖 Complete Commands Reference](docs/COMMANDS.md)** - All available commands and workflows +- **[📝 Changelog](docs/CHANGELOG.md)** - Version history and updates --- -## Volume Configuration +## ⭐ Support -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: +If this project helps you, please: +- ⭐ Star the repository +- 🐛 Report issues +- 💡 Suggest improvements +- 📖 Improve documentation -### Documents Directory on macOS -Mount the user's Documents directory on macOS inside the container: -```yaml -- $HOME/Documents:/home/developer/Documents -``` +--- -### Documents Directory on Linux -If you are using Linux, you can mount the user's Documents directory: -```yaml -- /home/user/Documents:/home/developer/Documents -``` +**Ready to code? Run `make quick` and start developing! 🚀** -### USB Drive on macOS -To mount a USB drive on macOS, use the following configuration: -```yaml -- /Volumes/sdb1:/home/developer/usb -``` +## 💡 Usage Tips -### USB Drive on Linux -If you need to mount a USB drive on Linux, use this configuration: -```yaml -- /dev/sdb2:/home/developer/usb -``` +### First Time Setup +1. Run the container: `make build` +2. Configure Powerlevel10k theme: `p10k configure` +3. Customize Neovim as needed +4. Set up git: `git config --global user.name "Your Name"` -### 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`. +### Daily Workflow +1. Start container: `make start` or `make enter` +2. Work on your projects in mounted directories +3. All changes in .dotfiles are persisted +4. Stop when done: `make stop` -### 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. +### Accessing Your Files +- Documents: `/home/developer/Documents` +- Projects: `/home/developer/Projects` (if configured) +- Custom mounts: As configured in docker-compose.yml + +### Terminal Features +- **Auto-suggestions**: Start typing, get suggestions from history +- **Syntax highlighting**: Commands are highlighted as you type +- **Fast search**: Use `Ctrl+R` for history search with fzf +- **Git integration**: Lazygit with `lg` command or `lazygit` --- -## Contributions +## 🤝 Contributions + +Contributions are welcome! Here's how you can help: -Contributions are welcome! If you have ideas or improvements, feel free to open an issue or submit a pull request. +1. **Fork** the repository +2. **Create** a feature branch: `git checkout -b feature/amazing-feature` +3. **Commit** your changes: `git commit -m 'Add amazing feature'` +4. **Push** to the branch: `git push origin feature/amazing-feature` +5. **Open** a Pull Request + +### Development Guidelines +- Follow existing code style +- Add appropriate documentation +- Test your changes +- Update version number if needed --- -## License +## 📝 License This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. --- -## Author +## 👨‍💻 Author + +Created by **ManghiDev** +🌐 Website: [Personal web](https://manghi.dev) +📧 Contact: [GitHub Issues](https://github.com/manghidev/lazyvim-docker/issues) + +--- + +## ⭐ Support + +If you find this project helpful, please consider: +- ⭐ Starring the repository +- 🐛 Reporting bugs +- 💡 Suggesting new features +- 📖 Improving documentation + +--- + +## 📚 Additional Resources -Created by ManghiDev. For more information, visit [https://manghi.dev](https://manghi.dev). \ No newline at end of file +- [LazyVim Documentation](https://lazyvim.github.io/) +- [Neovim Documentation](https://neovim.io/doc/) +- [Docker Documentation](https://docs.docker.com/) +- [Oh My Zsh Documentation](https://ohmyz.sh/) +- [Powerlevel10k Documentation](https://github.com/romkatv/powerlevel10k) \ No newline at end of file diff --git a/VERSION b/VERSION index 227cea2..9084fa2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 +1.1.0 diff --git a/build.sh b/build.sh deleted file mode 100755 index ebbf88b..0000000 --- a/build.sh +++ /dev/null @@ -1,18 +0,0 @@ -VERSION=$(cat VERSION) - -echo "Cleaning up the environment" -docker compose down --rmi all - -echo "Pulling the latest images" -docker compose pull - -echo "Building the container with this version $VERSION" -docker compose build --build-arg VERSION=$VERSION --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 deleted file mode 100755 index c2fbd6e..0000000 --- a/destroy.sh +++ /dev/null @@ -1,5 +0,0 @@ -# Stop and remove the container -# Stop and remove the container along with volumes -docker compose down --rmi all --volumes - -echo "Container and volumes stopped and removed" \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..a7e7096 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,7 @@ +services: + code-editor: + volumes: + # Mount current directory for development + - .:/home/developer/workspace + # Add any additional development-specific volumes here + - /tmp:/tmp diff --git a/docker-compose.yml b/docker-compose.yml index d29f74e..074b42d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,19 +6,66 @@ services: args: VERSION: ${VERSION:-1.0.0} container_name: lazyvim + hostname: lazyvim-dev + restart: unless-stopped volumes: + #* Persistent dotfiles - .dotfiles/.zshrc:/home/developer/.zshrc - .dotfiles/.p10k.zsh:/home/developer/.p10k.zsh - .dotfiles/.config/lazygit:/home/developer/.config/lazygit - .dotfiles/.config/nvim:/home/developer/.config/nvim + + #* Cache directories for better performance + - nvim-cache:/home/developer/.cache/nvim + - zsh-cache:/home/developer/.cache/zsh + - npm-cache:/home/developer/.npm + - pip-cache:/home/developer/.cache/pip + + #* Mount directories based on your OS + #* Uncomment and modify the appropriate lines below #* 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 + # - $HOME/Documents:/home/developer/Documents + + #* Mount the user's Desktop directory + # - $HOME/Desktop:/home/developer/Desktop + + #* Mount a development projects directory + # - $HOME/Projects:/home/developer/Projects + # - $HOME/Developer:/home/developer/Developer + #* Mount the user's USB in macOS - # - /Volumes/sdb1:/home/developer/usb + # - /Volumes/USB_NAME:/home/developer/usb + #* Mount the user's USB in Linux - # - /dev/sdb2:/home/developer/usb + # - /media/$USER/USB_NAME:/home/developer/usb + + #* Mount additional drives or directories + # - /path/to/your/custom/directory:/home/developer/custom + + environment: + - TERM=xterm-256color + - COLORTERM=truecolor + - LANG=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 stdin_open: true - tty: true \ No newline at end of file + tty: true + # Uncomment for network access to specific ports + # ports: + # - "3000:3000" # For web development + # - "8080:8080" # For alternative web dev + # - "5173:5173" # For Vite dev server + +# Named volumes for better performance and persistence +volumes: + nvim-cache: + driver: local + zsh-cache: + driver: local + npm-cache: + driver: local + pip-cache: + driver: local \ No newline at end of file diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md new file mode 100644 index 0000000..6e74266 --- /dev/null +++ b/docs/CHANGELOG.md @@ -0,0 +1,65 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.2.0] - 2025-06-27 + +### Added +- **Makefile** with intuitive commands for easy container management +- **Enhanced scripts** with error handling, logging, and validation +- **Health check script** (`scripts/health-check.sh`) for environment monitoring +- **Setup script** (`scripts/setup.sh`) for initial configuration +- **Version management script** (`scripts/bump-version.sh`) for semantic versioning +- **Development mode** with `docker-compose.dev.yml` for mounting workspace +- **Named volumes** for better performance (nvim-cache, zsh-cache, npm-cache, pip-cache) +- **Extended Dockerfile** with additional development tools: + - Python 3 with pip and development packages (black, flake8, mypy, pytest) + - Enhanced terminal tools (bat, exa, fd, tmux, htop, tree) + - Additional zsh plugins (syntax-highlighting, completions) + - Useful aliases and environment variables + - Network and build tools +- **Backup and restore functionality** for dotfiles +- **Environment configuration** with `.env.example` template +- **Improved .gitignore** with comprehensive exclusions +- **Enhanced documentation** with detailed setup and usage instructions + +### Changed +- **Improved `build.sh`** with better error handling and logging +- **Enhanced `init.sh`** with container status validation and auto-build option +- **Better `destroy.sh`** with confirmation prompts and cleanup +- **Updated `docker-compose.yml`** with: + - Named volumes for performance + - Better environment variables + - Container hostname and restart policy + - Improved volume mount structure +- **Comprehensive README** with: + - Quick start instructions + - Detailed command reference + - Troubleshooting guide + - Development tips + - Better organization and formatting + +### Fixed +- Container accessibility and health checking +- Permission issues with dotfiles +- Docker resource cleanup +- Script execution permissions + +## [1.1.0] - Previous Release + +### Added +- Basic LazyVim Docker environment +- Oh My Zsh with Powerlevel10k theme +- Essential development tools +- Volume mounting for Documents directory +- Basic build, init, and destroy scripts + +### Features +- LazyVim Neovim configuration +- Zsh with auto-suggestions +- Git and Lazygit integration +- FZF and Ripgrep for fast searching +- Persistent dotfiles configuration diff --git a/docs/COMMANDS.md b/docs/COMMANDS.md new file mode 100644 index 0000000..281320a --- /dev/null +++ b/docs/COMMANDS.md @@ -0,0 +1,187 @@ +# LazyVim Docker - Command Reference + +This document provides a comprehensive guide to all available commands in the LazyVim Docker environment. + +> **💡 Recommendation**: Always use `make` commands instead of running scripts directly. They provide better error handling, validation, and user feedback. + +## Make Commands (Recommended) + +### Basic Operations + +| Command | Description | Example | +|---------|-------------|---------| +| `make help` | Show all available commands with descriptions | `make help` | +| `make version` | Show current project version | `make version` | +| `make status` | Show container and environment status | `make status` | + +### Container Management + +| Command | Description | Example | +|---------|-------------|---------| +| `make build` | Build the Docker environment (clean build) | `make build` | +| `make start` | Start the container (if already built) | `make start` | +| `make enter` | Enter the running container | `make enter` | +| `make stop` | Stop the container (keeps volumes) | `make stop` | +| `make destroy` | Destroy everything (container, images, volumes) | `make destroy` | +| `make quick` | Quick start - build and enter in one command | `make quick` | + +### Development + +| Command | Description | Example | +|---------|-------------|---------| +| `make dev` | Start in development mode with workspace mounted | `make dev` | +| `make logs` | Show container logs (follow mode) | `make logs` | +| `make update` | Update to latest version and rebuild | `make update` | + +### Maintenance + +| Command | Description | Example | +|---------|-------------|---------| +| `make clean` | Clean up unused Docker resources | `make clean` | +| `make backup` | Backup dotfiles and configuration | `make backup` | +| `make restore` | Restore from backup | `make restore BACKUP_FILE=backup.tar.gz` | + +### Version Management + +| Command | Description | Example | +|---------|-------------|---------| +| `make bump-version TYPE=patch` | Bump patch version (1.0.0 → 1.0.1) | `make bump-version TYPE=patch` | +| `make bump-version TYPE=minor` | Bump minor version (1.0.0 → 1.1.0) | `make bump-version TYPE=minor` | +| `make bump-version TYPE=major` | Bump major version (1.0.0 → 2.0.0) | `make bump-version TYPE=major` | + +## Shell Scripts (Not Recommended - Use Make Instead) + +> **⚠️ Warning**: These scripts are for internal use. Use `make` commands instead for better experience. + +### Primary Scripts + +| Script | Make Alternative | Description | +|--------|------------------|-------------| +| `./scripts/build.sh` | `make build` | Build and start environment | +| `./scripts/init.sh` | `make start` | Start and enter container | +| `./scripts/destroy.sh` | `make destroy` | Remove environment | + +### Utility Scripts + +| Script | Make Alternative | Description | +|--------|------------------|-------------| +| `./scripts/setup.sh` | *No alternative* | Interactive initial configuration | +| `./scripts/health-check.sh` | `make status` | Environment diagnostics | +| `./scripts/bump-version.sh` | `make bump-version TYPE=patch` | Version management | + +## Docker Compose Commands + +For advanced users who prefer direct Docker Compose commands: + +```bash +# Basic operations +docker compose up -d # Start container in background +docker compose down # Stop and remove container +docker compose ps # Show container status +docker compose logs -f # Follow logs + +# Development mode +docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d + +# Build operations +docker compose build --no-cache # Clean build +docker compose up --force-recreate -d # Force recreate container +``` + +## Direct Docker Commands + +```bash +# Enter running container +docker exec -it lazyvim zsh + +# Check container status +docker inspect lazyvim + +# View container logs +docker logs lazyvim + +# Copy files to/from container +docker cp file.txt lazyvim:/home/developer/ +docker cp lazyvim:/home/developer/file.txt ./ +``` + +## Environment Variables + +Set these in your `.env` file (copy from `.env.example`): + +```bash +# Container configuration +CONTAINER_NAME=lazyvim +COMPOSE_PROJECT_NAME=lazyvim + +# Volume paths +DOCUMENTS_PATH=$HOME/Documents +PROJECTS_PATH=$HOME/Projects + +# Development mode +DEV_MODE=false +ENABLE_PORTS=false + +# Git configuration +GIT_USER_NAME="Your Name" +GIT_USER_EMAIL="your.email@example.com" +``` + +## Common Workflows + +### First Time Setup +```bash +git clone https://github.com/manghidev/lazyvim-docker.git +cd lazyvim-docker +./scripts/setup.sh # Interactive configuration +make build # Build environment +``` + +### Daily Development +```bash +make enter # Start and enter container +# Work on your projects +make stop # Stop when done +``` + +### Maintenance +```bash +make status # Check health +make backup # Backup configuration +make clean # Clean up Docker resources +make update # Update to latest +``` + +### Troubleshooting +```bash +./scripts/health-check.sh # Diagnose issues +make logs # Check container logs +make destroy && make build # Nuclear option - rebuild everything +``` + +## Tips and Best Practices + +1. **Use make commands**: They provide better error handling and user feedback +2. **Regular backups**: Run `make backup` before major changes +3. **Health checks**: Use `make status` or `./scripts/health-check.sh` for diagnostics +4. **Version control**: Use `make bump-version` for proper semantic versioning +5. **Clean up**: Run `make clean` periodically to free up disk space +6. **Development mode**: Use `make dev` when working on the Docker configuration itself + +## Keyboard Shortcuts in Container + +Once inside the container, these keyboard shortcuts are available: + +- `Ctrl+R` - Fuzzy search command history with fzf +- `Ctrl+T` - Fuzzy file finder with fzf +- `Alt+C` - Fuzzy directory changer with fzf +- `Ctrl+L` - Clear screen +- `Ctrl+D` - Exit container + +## Aliases Available in Container + +- `ll` - Enhanced ls with exa +- `cat` - Better cat with bat +- `find` - Better find with fd +- `vim`/`vi` - Opens neovim +- `lg` - Opens lazygit diff --git a/init.sh b/init.sh deleted file mode 100755 index cb79d22..0000000 --- a/init.sh +++ /dev/null @@ -1,5 +0,0 @@ -echo "Starting the container" -docker compose up -d - -echo "Enter to the lazyvim container" -docker exec -it lazyvim zsh diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..1845dda --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +# LazyVim Docker Build Script +# This script builds and starts the LazyVim Docker environment +# +# RECOMMENDATION: Use 'make build' instead of running this script directly +# The make command provides better error handling and user feedback + +set -e # Exit on any error + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +# Configuration +VERSION_FILE="VERSION" +CONTAINER_NAME="lazyvim" +DOTFILES_DIR=".dotfiles" + +# Functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Check if VERSION file exists +if [[ ! -f "$VERSION_FILE" ]]; then + log_error "VERSION file not found!" + exit 1 +fi + +VERSION=$(cat "$VERSION_FILE") +log_info "Building LazyVim Docker environment v$VERSION" + +# Create .dotfiles directory if it doesn't exist +if [[ ! -d "$DOTFILES_DIR" ]]; then + log_warning "Creating $DOTFILES_DIR directory..." + mkdir -p "$DOTFILES_DIR/.config/"{nvim,lazygit} +fi + +# Check if Docker is running +if ! docker info >/dev/null 2>&1; then + log_error "Docker is not running. Please start Docker first." + exit 1 +fi + +# Clean up existing environment +log_info "Cleaning up existing environment..." +docker compose down --rmi all --volumes 2>/dev/null || true + +# Pull latest base images +log_info "Pulling latest base images..." +docker compose pull || log_warning "Could not pull some images, continuing..." + +# Build the container +log_info "Building container with version $VERSION..." +if docker compose build --build-arg VERSION="$VERSION" --no-cache; then + log_success "Container built successfully" +else + log_error "Failed to build container" + exit 1 +fi + +# Start the container +log_info "Starting the container..." +if docker compose up --force-recreate -d; then + log_success "Container started successfully" +else + log_error "Failed to start container" + exit 1 +fi + +# Wait for container to be ready +log_info "Waiting for container to be ready..." +sleep 3 + +# Check if container is running +if docker compose ps | grep -q "Up"; then + log_success "Container is running!" + log_info "Opening shell in the container..." + docker exec -it "$CONTAINER_NAME" zsh +else + log_error "Container failed to start properly" + docker compose logs + exit 1 +fi + +log_success "Build process completed successfully!" +log_info "Use 'make enter' or './init.sh' to access the container again" diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh new file mode 100755 index 0000000..5c9dda4 --- /dev/null +++ b/scripts/bump-version.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +# Version bump script for LazyVim Docker +# Usage: ./bump-version.sh [patch|minor|major] + +set -e + +VERSION_FILE="VERSION" +BUMP_TYPE=${1:-patch} + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +# Validate bump type +if [[ ! "$BUMP_TYPE" =~ ^(patch|minor|major)$ ]]; then + echo -e "${RED}Error: Invalid bump type. Use: patch, minor, or major${NC}" + exit 1 +fi + +# Read current version +if [[ ! -f "$VERSION_FILE" ]]; then + echo -e "${RED}Error: VERSION file not found${NC}" + exit 1 +fi + +CURRENT_VERSION=$(cat "$VERSION_FILE") +echo -e "${BLUE}Current version: $CURRENT_VERSION${NC}" + +# Parse version components +IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" +MAJOR=${VERSION_PARTS[0]} +MINOR=${VERSION_PARTS[1]} +PATCH=${VERSION_PARTS[2]} + +# Bump version based on type +case $BUMP_TYPE in + "patch") + PATCH=$((PATCH + 1)) + ;; + "minor") + MINOR=$((MINOR + 1)) + PATCH=0 + ;; + "major") + MAJOR=$((MAJOR + 1)) + MINOR=0 + PATCH=0 + ;; +esac + +NEW_VERSION="$MAJOR.$MINOR.$PATCH" + +# Write new version +echo "$NEW_VERSION" > "$VERSION_FILE" +echo -e "${GREEN}Version bumped to: $NEW_VERSION${NC}" + +# Git commit if in a git repository +if git rev-parse --git-dir > /dev/null 2>&1; then + echo -e "${YELLOW}Committing version bump...${NC}" + git add "$VERSION_FILE" + git commit -m "Bump version to $NEW_VERSION" + git tag "v$NEW_VERSION" + echo -e "${GREEN}Version committed and tagged${NC}" +fi diff --git a/scripts/destroy.sh b/scripts/destroy.sh new file mode 100755 index 0000000..370e2a2 --- /dev/null +++ b/scripts/destroy.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# LazyVim Docker Destroy Script +# This script completely removes the LazyVim Docker environment +# +# RECOMMENDATION: Use 'make destroy' instead of running this script directly +# The make command provides better error handling and user feedback + +set -e # Exit on any error + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +# Configuration +CONTAINER_NAME="lazyvim" + +# Functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Confirmation prompt +log_warning "This will completely destroy the LazyVim Docker environment!" +log_warning "This includes:" +echo " - Stopping and removing containers" +echo " - Removing Docker images" +echo " - Removing Docker volumes (configuration will be lost!)" +echo "" +read -p "Are you sure you want to continue? (y/N): " -n 1 -r +echo + +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + log_info "Operation cancelled" + exit 0 +fi + +# Check if Docker is running +if ! docker info >/dev/null 2>&1; then + log_error "Docker is not running. Cannot destroy environment." + exit 1 +fi + +# Stop and remove containers, images, and volumes +log_info "Stopping and removing containers, images, and volumes..." +if docker compose down --rmi all --volumes; then + log_success "Environment destroyed successfully" +else + log_warning "Some resources might not have been removed" +fi + +# Clean up any remaining resources +log_info "Cleaning up any remaining Docker resources..." +docker system prune -f >/dev/null 2>&1 || true + +# Check if everything was removed +if docker compose ps | grep -q "$CONTAINER_NAME"; then + log_warning "Some containers might still be running" +else + log_success "All containers removed" +fi + +log_success "LazyVim Docker environment has been completely destroyed" +log_info "To rebuild the environment, run './build.sh' or 'make build'" \ No newline at end of file diff --git a/scripts/health-check.sh b/scripts/health-check.sh new file mode 100755 index 0000000..79ea135 --- /dev/null +++ b/scripts/health-check.sh @@ -0,0 +1,165 @@ +#!/bin/bash + +# LazyVim Docker Health Check Script +# This script checks the health of the LazyVim Docker environment + +set -e + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +# Configuration +CONTAINER_NAME="lazyvim" + +# Functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +print_header() { + echo -e "${BLUE}=== LazyVim Docker Health Check ===${NC}" + echo "" +} + +print_separator() { + echo "" + echo "-----------------------------------" + echo "" +} + +# Main health check function +health_check() { + print_header + + # Check Docker + log_info "Checking Docker..." + if docker info >/dev/null 2>&1; then + log_success "Docker is running" + DOCKER_VERSION=$(docker --version) + echo " Version: $DOCKER_VERSION" + else + log_error "Docker is not running or not installed" + return 1 + fi + + print_separator + + # Check Docker Compose + log_info "Checking Docker Compose..." + if docker compose version >/dev/null 2>&1; then + log_success "Docker Compose is available" + COMPOSE_VERSION=$(docker compose version --short) + echo " Version: $COMPOSE_VERSION" + else + log_error "Docker Compose is not available" + return 1 + fi + + print_separator + + # Check container status + log_info "Checking container status..." + if docker compose ps | grep -q "$CONTAINER_NAME"; then + if docker compose ps | grep -q "Up"; then + log_success "Container is running" + + # Check container health + log_info "Checking container health..." + CONTAINER_STATUS=$(docker inspect "$CONTAINER_NAME" --format='{{.State.Status}}') + CONTAINER_HEALTH=$(docker inspect "$CONTAINER_NAME" --format='{{.State.Health.Status}}' 2>/dev/null || echo "No health check") + + echo " Status: $CONTAINER_STATUS" + echo " Health: $CONTAINER_HEALTH" + + # Check if we can execute commands in the container + if docker exec "$CONTAINER_NAME" echo "Container accessible" >/dev/null 2>&1; then + log_success "Container is accessible" + else + log_warning "Container is not accessible" + fi + + else + log_warning "Container exists but is not running" + echo " Use 'make start' or './init.sh' to start it" + fi + else + log_warning "Container does not exist" + echo " Use 'make build' or './build.sh' to create it" + fi + + print_separator + + # Check volumes + log_info "Checking volumes..." + VOLUMES=$(docker volume ls | grep lazyvim || true) + if [[ -n "$VOLUMES" ]]; then + log_success "LazyVim volumes found:" + echo "$VOLUMES" | sed 's/^/ /' + else + log_warning "No LazyVim volumes found" + fi + + print_separator + + # Check dotfiles + log_info "Checking dotfiles directory..." + if [[ -d ".dotfiles" ]]; then + log_success "Dotfiles directory exists" + + # Check individual dotfiles + DOTFILES=(".dotfiles/.zshrc" ".dotfiles/.p10k.zsh" ".dotfiles/.config/nvim" ".dotfiles/.config/lazygit") + for file in "${DOTFILES[@]}"; do + if [[ -e "$file" ]]; then + echo " ✓ $file" + else + log_warning "Missing: $file" + fi + done + else + log_warning "Dotfiles directory does not exist" + echo " It will be created automatically when you build the environment" + fi + + print_separator + + # Check VERSION file + log_info "Checking version..." + if [[ -f "VERSION" ]]; then + VERSION=$(cat VERSION) + log_success "Version file found: $VERSION" + else + log_error "VERSION file not found" + fi + + print_separator + + # Final status + log_info "Health check completed" + + if docker compose ps | grep -q "Up"; then + log_success "Environment is ready to use!" + echo " Use 'make enter' or 'docker exec -it $CONTAINER_NAME zsh' to access" + else + log_info "Environment is not running" + echo " Use 'make start' to start or 'make build' to rebuild" + fi +} + +# Run health check +health_check diff --git a/scripts/init.sh b/scripts/init.sh new file mode 100755 index 0000000..7296131 --- /dev/null +++ b/scripts/init.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# LazyVim Docker Init Script +# This script starts and enters the LazyVim Docker container +# +# RECOMMENDATION: Use 'make start' or 'make enter' instead of running this script directly +# The make commands provide better error handling and user feedback + +set -e # Exit on any error + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +# Configuration +CONTAINER_NAME="lazyvim" + +# Functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Check if Docker is running +if ! docker info >/dev/null 2>&1; then + log_error "Docker is not running. Please start Docker first." + exit 1 +fi + +# Check if container exists +if ! docker compose ps | grep -q "$CONTAINER_NAME"; then + log_warning "Container not found. You may need to build it first." + read -p "Do you want to build the environment? (y/N): " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + log_info "Building environment..." + ./build.sh + exit 0 + else + log_error "Cannot proceed without building the environment first." + log_info "Run './build.sh' or 'make build' to build the environment." + exit 1 + fi +fi + +# Start the container if it's not running +if ! docker compose ps | grep -q "Up"; then + log_info "Starting the container..." + if docker compose up -d; then + log_success "Container started successfully" + # Wait a moment for the container to be fully ready + sleep 2 + else + log_error "Failed to start container" + exit 1 + fi +else + log_info "Container is already running" +fi + +# Enter the container +log_info "Entering the LazyVim container..." +if docker exec -it "$CONTAINER_NAME" zsh; then + log_success "Session ended" +else + log_error "Failed to enter container" + log_info "Container status:" + docker compose ps + exit 1 +fi diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 0000000..9844a71 --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,239 @@ +#!/bin/bash + +# LazyVim Docker Setup Script +# This script helps with initial setup and configuration + +set -e + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +# Functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +print_header() { + echo -e "${BLUE}=== LazyVim Docker Setup ===${NC}" + echo "This script will help you set up your LazyVim Docker environment" + echo "" +} + +# Create dotfiles structure +create_dotfiles_structure() { + log_info "Creating dotfiles structure..." + + mkdir -p .dotfiles/.config/{nvim,lazygit} + mkdir -p .dotfiles/.cache/{nvim,zsh} + mkdir -p .dotfiles/.local/share + + # Create basic .zshrc if it doesn't exist + if [[ ! -f ".dotfiles/.zshrc" ]]; then + cat > .dotfiles/.zshrc << 'EOF' +# LazyVim Docker Zsh Configuration +export ZSH="$HOME/.oh-my-zsh" + +ZSH_THEME="powerlevel10k/powerlevel10k" +plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions) + +source $ZSH/oh-my-zsh.sh + +# Custom aliases +alias ll="exa -la" +alias cat="bat" +alias find="fd" +alias vim="nvim" +alias vi="nvim" +alias lg="lazygit" + +# Environment variables +export EDITOR=nvim +export VISUAL=nvim +export PAGER=bat + +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh +EOF + log_success "Created basic .zshrc" + fi + + # Create basic .p10k.zsh if it doesn't exist + if [[ ! -f ".dotfiles/.p10k.zsh" ]]; then + touch .dotfiles/.p10k.zsh + log_info "Created empty .p10k.zsh (will be configured on first run)" + fi + + log_success "Dotfiles structure created" +} + +# Configure git settings +configure_git() { + log_info "Git configuration setup" + echo "Let's configure git for your container environment" + echo "" + + read -p "Enter your git username: " GIT_USER + read -p "Enter your git email: " GIT_EMAIL + + if [[ -n "$GIT_USER" && -n "$GIT_EMAIL" ]]; then + mkdir -p .dotfiles/.config/git + cat > .dotfiles/.config/git/config << EOF +[user] + name = $GIT_USER + email = $GIT_EMAIL + +[init] + defaultBranch = main + +[core] + editor = nvim + pager = bat + +[alias] + st = status + co = checkout + br = branch + ci = commit + lg = log --oneline --graph --decorate + last = log -1 HEAD + unstage = reset HEAD -- +EOF + log_success "Git configuration created" + else + log_warning "Skipping git configuration" + fi +} + +# Configure volumes in docker-compose.yml +configure_volumes() { + log_info "Volume configuration" + echo "Let's configure the directories you want to mount in your container" + echo "" + + # Detect OS + if [[ "$OSTYPE" == "darwin"* ]]; then + OS="macOS" + DEFAULT_DOCS="$HOME/Documents" + DEFAULT_PROJECTS="$HOME/Developer" + else + OS="Linux" + DEFAULT_DOCS="$HOME/Documents" + DEFAULT_PROJECTS="$HOME/Projects" + fi + + echo "Detected OS: $OS" + echo "" + + echo "Current default mounts:" + echo " - Documents: $DEFAULT_DOCS" + echo "" + + read -p "Do you want to add a Projects directory? (y/N): " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + read -p "Enter the path to your projects directory [$DEFAULT_PROJECTS]: " PROJECTS_DIR + PROJECTS_DIR=${PROJECTS_DIR:-$DEFAULT_PROJECTS} + + if [[ -d "$PROJECTS_DIR" ]]; then + # Add projects directory to docker-compose.yml + sed -i.bak "/Documents:/a\\ + - $PROJECTS_DIR:/home/developer/Projects" docker-compose.yml + log_success "Added Projects directory: $PROJECTS_DIR" + else + log_warning "Directory $PROJECTS_DIR does not exist, skipping" + fi + fi + + read -p "Do you want to add any other custom directories? (y/N): " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + while true; do + read -p "Enter local directory path (or 'done' to finish): " CUSTOM_DIR + if [[ "$CUSTOM_DIR" == "done" ]]; then + break + fi + + if [[ -d "$CUSTOM_DIR" ]]; then + MOUNT_NAME=$(basename "$CUSTOM_DIR") + read -p "Mount as [/home/developer/$MOUNT_NAME]: " CONTAINER_PATH + CONTAINER_PATH=${CONTAINER_PATH:-"/home/developer/$MOUNT_NAME"} + + # Add custom directory to docker-compose.yml + sed -i.bak "/Documents:/a\\ + - $CUSTOM_DIR:$CONTAINER_PATH" docker-compose.yml + log_success "Added custom directory: $CUSTOM_DIR -> $CONTAINER_PATH" + else + log_warning "Directory $CUSTOM_DIR does not exist, skipping" + fi + done + fi +} + +# Main setup function +main() { + print_header + + # Check if we're in the right directory + if [[ ! -f "docker-compose.yml" ]]; then + log_error "This script must be run from the lazyvim-docker directory" + exit 1 + fi + + # Create dotfiles structure + create_dotfiles_structure + echo "" + + # Configure git + read -p "Do you want to configure git settings? (y/N): " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + configure_git + echo "" + fi + + # Configure volumes + read -p "Do you want to configure volume mounts? (y/N): " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + configure_volumes + echo "" + fi + + # Make scripts executable + log_info "Making scripts executable..." + chmod +x *.sh scripts/*.sh + log_success "Scripts are now executable" + echo "" + + # Final message + log_success "Setup completed!" + echo "" + echo "Next steps:" + echo " 1. Run 'make build' or './build.sh' to build the environment" + echo " 2. Run 'make enter' or './init.sh' to start and enter the container" + echo " 3. Configure Neovim and other tools as needed" + echo "" + echo "Useful commands:" + echo " - 'make help' - Show all available commands" + echo " - 'make status' - Check environment status" + echo " - './scripts/health-check.sh' - Run health check" +} + +# Run main function +main "$@" From a36442621af886ac54efabd64dba1014bc50d7c5 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 13:12:49 -0600 Subject: [PATCH 06/14] feat: enhance Dockerfile to create specific cache directories for nvim, zsh, and pip --- .dotfiles/.config/nvim/lazy-lock.json | 48 +++++++++++++-------------- Dockerfile | 3 +- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.dotfiles/.config/nvim/lazy-lock.json b/.dotfiles/.config/nvim/lazy-lock.json index 6f37e12..e4fe599 100644 --- a/.dotfiles/.config/nvim/lazy-lock.json +++ b/.dotfiles/.config/nvim/lazy-lock.json @@ -1,45 +1,45 @@ { - "CopilotChat.nvim": { "branch": "main", "commit": "75653259442a8eb895abfc70d7064e07aeb7134c" }, + "CopilotChat.nvim": { "branch": "main", "commit": "55f2162c36901224e22ff8424fd60ecef670b8fc" }, "LazyVim": { "branch": "main", "commit": "3f034d0a7f58031123300309f2efd3bb0356ee21" }, - "SchemaStore.nvim": { "branch": "main", "commit": "ea5687d7e8af3ce6678dd03d3a1bd109b5c618b7" }, + "SchemaStore.nvim": { "branch": "main", "commit": "6af106298a8fd50af775d5281ee39a102556e352" }, "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, - "blink.cmp": { "branch": "main", "commit": "4f38ce99a472932d5776337f08f7a8180f1f571a" }, + "blink.cmp": { "branch": "main", "commit": "9bcb14b43852a6f2bfd5ac9ef29cb5cf09b1b39b" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, - "catppuccin": { "branch": "main", "commit": "1bf070129c0b6f77cc23f6a2212dcdc868308c52" }, - "conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" }, - "copilot.lua": { "branch": "master", "commit": "7ba73866b9b3c696f80579c470c6eec374d3acec" }, + "catppuccin": { "branch": "main", "commit": "fa42eb5e26819ef58884257d5ae95dd0552b9a66" }, + "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, + "copilot.lua": { "branch": "master", "commit": "46f4b7d026cba9497159dcd3e6aa61a185cb1c48" }, "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "fzf-lua": { "branch": "main", "commit": "02def6b972d7687866738d6f6a5f4839ce5b5a7a" }, - "gitsigns.nvim": { "branch": "main", "commit": "43b0c856ae5f32a195d83f4a27fe21d63e6c966c" }, - "grug-far.nvim": { "branch": "main", "commit": "b91e6d4bad441dcaeda3d0c6df45ed270443b60a" }, + "fzf-lua": { "branch": "main", "commit": "20d64076669c8d94f94319dd1f451608156ee3da" }, + "gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" }, + "grug-far.nvim": { "branch": "main", "commit": "b3f9412b1ed76f14cfc68e1ee899873544330c80" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" }, + "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "d39a75bbce4b8aad5d627191ea915179c77c100f" }, - "mason.nvim": { "branch": "main", "commit": "7c7318e8bae7e3536ef6b9e86b9e38e74f2e125e" }, - "mini.ai": { "branch": "main", "commit": "e139eb1101beb0250fea322f8c07a42f0f175688" }, - "mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" }, - "mini.pairs": { "branch": "main", "commit": "69864a2efb36c030877421634487fd90db1e4298" }, - "neo-tree.nvim": { "branch": "main", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" }, + "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, + "mini.ai": { "branch": "main", "commit": "d172ada7b0281044a06cb9a625a862553c457b6f" }, + "mini.icons": { "branch": "main", "commit": "94848dad1589a199f876539bd79befb0c5e3abf0" }, + "mini.pairs": { "branch": "main", "commit": "42407ccb80ec59c84e7c91d815f42ed90a8cc093" }, + "neo-tree.nvim": { "branch": "main", "commit": "7bc06b5efc5554d10f73a8aa508e02c03a83c2a0" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, - "nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" }, - "nvim-lint": { "branch": "master", "commit": "9dfb77ef6c5092a19502883c02dc5a02ec648729" }, - "nvim-lspconfig": { "branch": "master", "commit": "4bc481b6f0c0cf3671fc894debd0e00347089a4e" }, - "nvim-treesitter": { "branch": "master", "commit": "28d480e0624b259095e56f353ec911f9f2a0f404" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "0e3be38005e9673d044e994b1e4b123adb040179" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, + "nvim-lspconfig": { "branch": "master", "commit": "6bba673aa8993eceec233be17b42ddfb9540794b" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "89ebe73cd2836db80a22d9748999ace0241917a5" }, "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": "ff577b44bd3ab642acec0f134a7bf26b7278d137" }, + "render-markdown.nvim": { "branch": "main", "commit": "c809fc129f842a7055c672593d24be6346bcc673" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, "ts-comments.nvim": { "branch": "main", "commit": "1bd9d0ba1d8b336c3db50692ffd0955fe1bb9f0c" }, - "vim-dadbod": { "branch": "master", "commit": "fa31d0ffeebaa59cf97a81e7f92194cced54a13f" }, + "vim-dadbod": { "branch": "master", "commit": "e95afed23712f969f83b4857a24cf9d59114c2e6" }, "vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" }, - "vim-dadbod-ui": { "branch": "master", "commit": "460432301a5cb280ea265ddfa15c9f3dcd1d26b7" }, + "vim-dadbod-ui": { "branch": "master", "commit": "2900a1617b3df1a48683d872eadbe1101146a49a" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/Dockerfile b/Dockerfile index e4c50e2..0785d96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,7 +74,8 @@ RUN echo 'export EDITOR=nvim' >> /home/developer/.zshrc && \ USER root #* Create cache directories and ensure proper permissions -RUN mkdir -p /home/developer/.cache /home/developer/.local/share && \ +RUN mkdir -p /home/developer/.cache/nvim /home/developer/.cache/zsh /home/developer/.cache/pip \ + /home/developer/.local/share/nvim /home/developer/.local/state/nvim && \ chown -R developer:developer /home/developer #* Switch back to developer user From 2c59bdb8b3c8f6475755e3f31948ad1ff7bec64d Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 13:27:37 -0600 Subject: [PATCH 07/14] refactor: remove development mode target and associated docker-compose.dev.yml --- Makefile | 5 ----- docker-compose.dev.yml | 7 ------- 2 files changed, 12 deletions(-) delete mode 100644 docker-compose.dev.yml diff --git a/Makefile b/Makefile index e5797ac..b85275c 100644 --- a/Makefile +++ b/Makefile @@ -88,11 +88,6 @@ restore: ## Restore from backup (requires BACKUP_FILE variable) @tar -xzf $(BACKUP_FILE) @echo "$(GREEN)Restore completed$(NC)" -dev: ## Development mode - start with current directory mounted - @echo "$(BLUE)Starting in development mode...$(NC)" - @docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d - @docker exec -it $(CONTAINER_NAME) zsh - quick: ## Quick start - build and enter in one command @echo "$(BLUE)Quick start: building and entering container...$(NC)" @make build && make enter diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml deleted file mode 100644 index a7e7096..0000000 --- a/docker-compose.dev.yml +++ /dev/null @@ -1,7 +0,0 @@ -services: - code-editor: - volumes: - # Mount current directory for development - - .:/home/developer/workspace - # Add any additional development-specific volumes here - - /tmp:/tmp From 34a881ac4fb5e3562bd2825e5907541b0e56849f Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 13:30:58 -0600 Subject: [PATCH 08/14] Bump version to 1.2.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9084fa2..26aaba0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.2.0 From 2335ed90c1b92dee654c48b76028eebb6f7dfbc3 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:12:45 -0600 Subject: [PATCH 09/14] fix: update access instructions for the container in build script --- scripts/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 1845dda..91bd0f6 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -100,4 +100,4 @@ else fi log_success "Build process completed successfully!" -log_info "Use 'make enter' or './init.sh' to access the container again" +log_info "Use 'make enter' to access the container again" From 66bfc6b4789699c4b2cd44e44fa1fc2e2e16c6bd Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:24:57 -0600 Subject: [PATCH 10/14] refactor: simplify rebuild instructions in scripts --- scripts/destroy.sh | 2 +- scripts/health-check.sh | 4 ++-- scripts/init.sh | 2 +- scripts/setup.sh | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/destroy.sh b/scripts/destroy.sh index 370e2a2..298a1d4 100755 --- a/scripts/destroy.sh +++ b/scripts/destroy.sh @@ -76,4 +76,4 @@ else fi log_success "LazyVim Docker environment has been completely destroyed" -log_info "To rebuild the environment, run './build.sh' or 'make build'" \ No newline at end of file +log_info "To rebuild the environment, run 'make build'" \ No newline at end of file diff --git a/scripts/health-check.sh b/scripts/health-check.sh index 79ea135..0819211 100755 --- a/scripts/health-check.sh +++ b/scripts/health-check.sh @@ -96,11 +96,11 @@ health_check() { else log_warning "Container exists but is not running" - echo " Use 'make start' or './init.sh' to start it" + echo " Use 'make start' to start it" fi else log_warning "Container does not exist" - echo " Use 'make build' or './build.sh' to create it" + echo " Use 'make build' to create it" fi print_separator diff --git a/scripts/init.sh b/scripts/init.sh index 7296131..417883c 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -52,7 +52,7 @@ if ! docker compose ps | grep -q "$CONTAINER_NAME"; then exit 0 else log_error "Cannot proceed without building the environment first." - log_info "Run './build.sh' or 'make build' to build the environment." + log_info "Run 'make build' to build the environment." exit 1 fi fi diff --git a/scripts/setup.sh b/scripts/setup.sh index 9844a71..fc52e26 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -225,8 +225,8 @@ main() { log_success "Setup completed!" echo "" echo "Next steps:" - echo " 1. Run 'make build' or './build.sh' to build the environment" - echo " 2. Run 'make enter' or './init.sh' to start and enter the container" + echo " 1. Run 'make build' to build the environment" + echo " 2. Run 'make enter' to start and enter the container" echo " 3. Configure Neovim and other tools as needed" echo "" echo "Useful commands:" From bcebb6c0f71a2fbe736f8403d21183968763c4a4 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:25:23 -0600 Subject: [PATCH 11/14] fix: update default version in docker-compose to 0.0.0 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 074b42d..3a95916 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: context: . dockerfile: Dockerfile args: - VERSION: ${VERSION:-1.0.0} + VERSION: ${VERSION:-0.0.0} container_name: lazyvim hostname: lazyvim-dev restart: unless-stopped From 680eeeb83cda8779b854842c7e11a1e10a1cb8a7 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 16:18:51 -0600 Subject: [PATCH 12/14] feat: add timezone configuration support for Docker container --- .dotfiles/.config/nvim/lazy-lock.json | 2 +- Dockerfile | 8 ++++++ Makefile | 4 +++ README.md | 33 +++++++++++++++++++++++++ docker-compose.yml | 4 ++- scripts/build.sh | 4 +++ scripts/check-timezone.sh | 35 +++++++++++++++++++++++++++ scripts/init.sh | 2 +- 8 files changed, 89 insertions(+), 3 deletions(-) create mode 100755 scripts/check-timezone.sh diff --git a/.dotfiles/.config/nvim/lazy-lock.json b/.dotfiles/.config/nvim/lazy-lock.json index e4fe599..5d1dca4 100644 --- a/.dotfiles/.config/nvim/lazy-lock.json +++ b/.dotfiles/.config/nvim/lazy-lock.json @@ -1,7 +1,7 @@ { "CopilotChat.nvim": { "branch": "main", "commit": "55f2162c36901224e22ff8424fd60ecef670b8fc" }, "LazyVim": { "branch": "main", "commit": "3f034d0a7f58031123300309f2efd3bb0356ee21" }, - "SchemaStore.nvim": { "branch": "main", "commit": "6af106298a8fd50af775d5281ee39a102556e352" }, + "SchemaStore.nvim": { "branch": "main", "commit": "e4f80f37cd11ed58a6e914cc30850749f021b6a7" }, "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, "blink.cmp": { "branch": "main", "commit": "9bcb14b43852a6f2bfd5ac9ef29cb5cf09b1b39b" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, diff --git a/Dockerfile b/Dockerfile index 0785d96..56bc9b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,12 +24,20 @@ RUN apk add --no-cache \ jq yq sed gawk grep \ # Terminal enhancements bat exa fd github-cli \ + # Timezone support + tzdata \ # Python packages via apk (more stable on Alpine) && apk add --no-cache py3-requests py3-beautifulsoup4 \ # Install some Python tools that need pip && pip3 install --break-system-packages --no-cache-dir \ black flake8 mypy pytest pandas +#* Configure timezone (default to America/Mexico_City, can be overridden with build arg) +ARG TIMEZONE=America/Mexico_City +ENV TZ=$TIMEZONE +RUN cp /usr/share/zoneinfo/$TIMEZONE /etc/localtime && \ + echo $TIMEZONE > /etc/timezone + #* Create a new user 'developer' with home directory and grant sudo privileges RUN adduser -D -s /bin/zsh developer && \ echo "developer ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers diff --git a/Makefile b/Makefile index b85275c..4f4ed0f 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,10 @@ quick: ## Quick start - build and enter in one command version: ## Show current version @echo "$(GREEN)Current version: $(VERSION)$(NC)" +timezone: ## Check timezone configuration in container + @echo "$(BLUE)Checking timezone configuration...$(NC)" + @./scripts/check-timezone.sh + bump-version: ## Bump version (patch, minor, major) @if [ -z "$(TYPE)" ]; then \ echo "$(RED)Please specify TYPE. Example: make bump-version TYPE=patch$(NC)"; \ diff --git a/README.md b/README.md index 8bcd0dd..1e28cc6 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,39 @@ For a complete list of commands, see: **[📖 Commands Reference](docs/COMMANDS. ## 🔧 Configuration +### Timezone Configuration +Configure your local timezone to match the container time. Edit the `docker-compose.yml` file: + +```yaml +# In docker-compose.yml, modify these lines: +services: + code-editor: + build: + args: + VERSION: 1.2.0 + TIMEZONE: America/Mexico_City # Change to your timezone + environment: + - TZ=America/Mexico_City # Change to your timezone +``` + +Common timezones: +- `America/Mexico_City` (UTC-6) +- `America/New_York` (UTC-5/-4) +- `America/Los_Angeles` (UTC-8/-7) +- `Europe/Madrid` (UTC+1/+2) +- `Europe/London` (UTC+0/+1) +- `Asia/Tokyo` (UTC+9) + +After changing the timezone, rebuild the container: +```bash +make build +``` + +Check the current timezone configuration: +```bash +make timezone +``` + ### Volume Mounting By default, your `Documents` folder is mounted. Edit `docker-compose.yml` to add more directories: diff --git a/docker-compose.yml b/docker-compose.yml index 3a95916..c6e53aa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,8 @@ services: context: . dockerfile: Dockerfile args: - VERSION: ${VERSION:-0.0.0} + VERSION: ${VERSION:-1.0.0} + TIMEZONE: America/Mexico_City container_name: lazyvim hostname: lazyvim-dev restart: unless-stopped @@ -51,6 +52,7 @@ services: - COLORTERM=truecolor - LANG=en_US.UTF-8 - LC_ALL=en_US.UTF-8 + - TZ=America/Mexico_City stdin_open: true tty: true # Uncomment for network access to specific ports diff --git a/scripts/build.sh b/scripts/build.sh index 91bd0f6..83923f3 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -44,7 +44,11 @@ if [[ ! -f "$VERSION_FILE" ]]; then fi VERSION=$(cat "$VERSION_FILE") +# Get timezone from docker-compose.yml +TIMEZONE=$(grep -A 10 "args:" docker-compose.yml | grep "TIMEZONE:" | awk '{print $2}' || echo "America/Mexico_City") + log_info "Building LazyVim Docker environment v$VERSION" +log_info "Timezone: $TIMEZONE" # Create .dotfiles directory if it doesn't exist if [[ ! -d "$DOTFILES_DIR" ]]; then diff --git a/scripts/check-timezone.sh b/scripts/check-timezone.sh new file mode 100755 index 0000000..1d5d217 --- /dev/null +++ b/scripts/check-timezone.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Check timezone in the container +# This script helps verify the timezone configuration + +set -e + +# Colors +GREEN='\033[0;32m' +BLUE='\033[0;34m' +NC='\033[0m' + +CONTAINER_NAME="lazyvim" + +echo -e "${BLUE}Checking timezone configuration...${NC}" +echo "" + +if docker ps | grep -q "$CONTAINER_NAME"; then + echo -e "${GREEN}Container timezone information:${NC}" + echo "Current time in container:" + docker exec "$CONTAINER_NAME" date + echo "" + echo "Timezone file:" + docker exec "$CONTAINER_NAME" cat /etc/timezone 2>/dev/null || echo "Timezone file not found" + echo "" + echo "TZ environment variable:" + docker exec "$CONTAINER_NAME" env | grep TZ || echo "TZ variable not set" + echo "" + echo -e "${GREEN}Local system time for comparison:${NC}" + date +else + echo "Container '$CONTAINER_NAME' is not running." + echo "Please start the container first with: make start" + exit 1 +fi diff --git a/scripts/init.sh b/scripts/init.sh index 417883c..7856c8e 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -48,7 +48,7 @@ if ! docker compose ps | grep -q "$CONTAINER_NAME"; then echo if [[ $REPLY =~ ^[Yy]$ ]]; then log_info "Building environment..." - ./build.sh + ./scripts/build.sh exit 0 else log_error "Cannot proceed without building the environment first." From 55427f83d1a49119b86d6b714e2c4b08cddc1188 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 17:00:30 -0600 Subject: [PATCH 13/14] feat: enhance container management commands and update documentation --- Makefile | 75 +++++++++++++---- README.md | 19 +++-- docker-compose.yml | 8 +- docs/CONTAINER_LIFECYCLE.md | 160 ++++++++++++++++++++++++++++++++++++ scripts/init.sh | 22 +++-- 5 files changed, 244 insertions(+), 40 deletions(-) create mode 100644 docs/CONTAINER_LIFECYCLE.md diff --git a/Makefile b/Makefile index 4f4ed0f..cfba4d8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # LazyVim Docker - Makefile # Provides easy-to-use commands for managing the LazyVim Docker environment -.PHONY: help build start enter stop destroy clean status update logs backup restore dev quick version bump-version +.PHONY: help build start enter stop destroy clean status update logs backup restore dev quick version bump-version restart # Default target .DEFAULT_GOAL := help @@ -31,20 +31,51 @@ build: ## Build the Docker environment (clean build) start: ## Start the container (if already built) @echo "$(BLUE)Starting LazyVim container...$(NC)" - @./scripts/init.sh + @CONTAINER_STATE=$$(docker inspect $(CONTAINER_NAME) 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || echo "missing"); \ + if [ "$$CONTAINER_STATE" = "missing" ]; then \ + echo "$(RED)Container not found. Please build first with 'make build'$(NC)"; \ + exit 1; \ + elif [ "$$CONTAINER_STATE" = "running" ]; then \ + echo "$(GREEN)Container is already running$(NC)"; \ + else \ + echo "$(YELLOW)Starting existing container...$(NC)"; \ + if docker compose start; then \ + echo "$(GREEN)Container started successfully$(NC)"; \ + else \ + echo "$(RED)Failed to start container$(NC)"; \ + exit 1; \ + fi \ + fi enter: ## Enter the running container @echo "$(BLUE)Entering LazyVim container...$(NC)" - @docker exec -it $(CONTAINER_NAME) zsh 2>/dev/null || { \ - echo "$(RED)Container not running. Starting it first...$(NC)"; \ - make start; \ - } + @CONTAINER_STATE=$$(docker inspect $(CONTAINER_NAME) 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || echo "missing"); \ + if [ "$$CONTAINER_STATE" = "missing" ]; then \ + echo "$(RED)Container not found. Please build first with 'make build'$(NC)"; \ + exit 1; \ + elif [ "$$CONTAINER_STATE" = "running" ]; then \ + docker exec -it $(CONTAINER_NAME) zsh; \ + else \ + echo "$(YELLOW)Container not running. Starting it first...$(NC)"; \ + if docker compose start; then \ + sleep 2; \ + docker exec -it $(CONTAINER_NAME) zsh; \ + else \ + echo "$(RED)Failed to start container$(NC)"; \ + exit 1; \ + fi \ + fi stop: ## Stop the container (keeps volumes) @echo "$(YELLOW)Stopping LazyVim container...$(NC)" @docker compose stop @echo "$(GREEN)Container stopped$(NC)" +restart: ## Restart the container (stop and start) + @echo "$(BLUE)Restarting LazyVim container...$(NC)" + @docker compose restart + @echo "$(GREEN)Container restarted$(NC)" + destroy: ## Destroy everything (container, images, and volumes) @echo "$(RED)Destroying LazyVim environment...$(NC)" @./scripts/destroy.sh @@ -57,12 +88,18 @@ clean: ## Clean up unused Docker resources status: ## Show container status @echo "$(BLUE)Container Status:$(NC)" - @docker compose ps - @echo "" - @echo "$(BLUE)Container Info:$(NC)" - @docker inspect $(CONTAINER_NAME) --format='{{.State.Status}}' 2>/dev/null | \ - sed 's/running/$(GREEN)Running$(NC)/' | \ - sed 's/exited/$(RED)Stopped$(NC)/' || echo "$(RED)Not found$(NC)" + @CONTAINER_STATE=$$(docker inspect $(CONTAINER_NAME) 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || echo "missing"); \ + if [ "$$CONTAINER_STATE" = "missing" ]; then \ + echo "$(RED)✗ Container does not exist$(NC)"; \ + echo "$(BLUE)Use 'make build' to create the container$(NC)"; \ + elif [ "$$CONTAINER_STATE" = "running" ]; then \ + echo "$(GREEN)✓ Container exists and is running$(NC)"; \ + docker compose ps; \ + else \ + echo "$(YELLOW)⚠ Container exists but is stopped ($$CONTAINER_STATE)$(NC)"; \ + echo "$(BLUE)Use 'make start' to start the container$(NC)"; \ + docker compose ps; \ + fi logs: ## Show container logs @echo "$(BLUE)Container Logs:$(NC)" @@ -88,9 +125,17 @@ restore: ## Restore from backup (requires BACKUP_FILE variable) @tar -xzf $(BACKUP_FILE) @echo "$(GREEN)Restore completed$(NC)" -quick: ## Quick start - build and enter in one command - @echo "$(BLUE)Quick start: building and entering container...$(NC)" - @make build && make enter +quick: ## Quick start - start container and enter (build only if needed) + @echo "$(BLUE)Quick start...$(NC)" + @CONTAINER_STATE=$$(docker inspect $(CONTAINER_NAME) 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || echo "missing"); \ + if [ "$$CONTAINER_STATE" = "missing" ]; then \ + echo "$(YELLOW)Container not found. Building first...$(NC)"; \ + make build && make enter; \ + elif [ "$$CONTAINER_STATE" = "running" ]; then \ + make enter; \ + else \ + make start && make enter; \ + fi version: ## Show current version @echo "$(GREEN)Current version: $(VERSION)$(NC)" diff --git a/README.md b/README.md index 1e28cc6..06a0db6 100644 --- a/README.md +++ b/README.md @@ -33,20 +33,21 @@ make enter # Enter the container --- -## � Main Commands +## 🎯 Main Commands ```bash make help # Show all available commands -make quick # Quick start - build and enter in one command -make build # Build the Docker environment -make enter # Enter the running container -make stop # Stop the container -make destroy # Destroy everything -make status # Check environment status -make backup # Backup your configuration +make enter # 🔥 DAILY USE: Enter container (starts automatically if stopped) +make start # Start existing container (preserves all data) +make stop # Stop container (saves all data and plugins) +make status # Check container status +make build # ⚠️ ONLY for first time or major updates +make destroy # ⚠️ DANGEROUS: Removes everything ``` -For a complete list of commands, see: **[📖 Commands Reference](docs/COMMANDS.md)** +> 💡 **For daily development**: Just use `make enter` - it handles everything! + +For detailed workflow and troubleshooting: **[📖 Container Lifecycle Guide](docs/CONTAINER_LIFECYCLE.md)** --- diff --git a/docker-compose.yml b/docker-compose.yml index c6e53aa..6b6d545 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,10 +25,10 @@ services: #* Mount directories based on your OS #* Uncomment and modify the appropriate lines below - #* Mount the user's Documents directory in macOS + #* Mount the user's Documents directory on macOS - $HOME/Documents:/home/developer/Documents - #* Mount the user's Documents directory in Linux + #* Mount the user's Documents directory on Linux # - $HOME/Documents:/home/developer/Documents #* Mount the user's Desktop directory @@ -38,10 +38,10 @@ services: # - $HOME/Projects:/home/developer/Projects # - $HOME/Developer:/home/developer/Developer - #* Mount the user's USB in macOS + #* Mount the user's USB on macOS # - /Volumes/USB_NAME:/home/developer/usb - #* Mount the user's USB in Linux + #* Mount the user's USB on Linux # - /media/$USER/USB_NAME:/home/developer/usb #* Mount additional drives or directories diff --git a/docs/CONTAINER_LIFECYCLE.md b/docs/CONTAINER_LIFECYCLE.md new file mode 100644 index 0000000..6f86b1c --- /dev/null +++ b/docs/CONTAINER_LIFECYCLE.md @@ -0,0 +1,160 @@ +# LazyVim Container Lifecycle Management + +This guide explains the correct workflow for managing the LazyVim Docker container without losing plugin configurations, sessions, or having to rebuild unnecessarily. + +## 🔧 Main Commands + +### Initial Build +```bash +make build # Builds the container for the first time +``` +⚠️ **Only use when**: +- First time setting up the environment +- Need to update the base image +- Container is corrupted or damaged + +### Daily Operations + +#### Start Container +```bash +make start # Starts an existing container (NO rebuild) +``` +✅ **Perfect for**: +- Starting your work day +- Resuming after using `make stop` +- Reviving a container that stopped unexpectedly + +#### Enter Container +```bash +make enter # Enters the container (starts automatically if stopped) +``` +✅ **Perfect for**: +- Quick access to development environment +- Automatically handles starting the container if stopped +- Most common use for daily development + +#### Stop Container +```bash +make stop # Stops the container PRESERVING all data +``` +✅ **Ideal for**: +- Freeing system resources +- Ending your work day +- Temporarily suspending the environment + +#### Quick Restart +```bash +make restart # Restarts the existing container +``` +✅ **Useful for**: +- Applying configuration changes +- Resolving minor issues +- Refreshing the environment without data loss + +## 🔄 Recommended Daily Workflow + +### Starting Your Day +```bash +make enter # Handles everything automatically +``` + +### During Development +- Container keeps running +- You can exit and enter with `make enter` as many times as needed +- All plugins, configurations, and sessions are preserved + +### Ending Your Day +```bash +make stop # Frees resources but preserves everything +``` + +### Next Day +```bash +make enter # Continue exactly where you left off +``` + +## 📊 Container States + +| State | Description | Command to Continue | +|--------|-------------|----------------------| +| `missing` | Doesn't exist | `make build` | +| `exited` | Stopped but exists | `make start` or `make enter` | +| `running` | Running and ready | `make enter` | + +## ✅ Check Status + +```bash +make status # Shows current status in detail +``` + +Example outputs: +- ✅ `Container exists and is running` - Ready to use +- ⚠️ `Container exists but is stopped` - Use `make start` or `make enter` +- ❌ `Container does not exist` - Use `make build` + +## 🚀 Quick Start Commands + +```bash +make quick # Starts and enters automatically (builds only if needed) +``` + +## ⚠️ Destructive Commands (Use with Caution) + +```bash +make destroy # REMOVES EVERYTHING: container, volumes, images +make build # Rebuilds from scratch (you lose plugins/sessions) +``` + +## 🐛 Troubleshooting + +### Problem: "Container not found" +**Symptom**: Error when using `make start` or `make enter` +```bash +make status # Check status +make build # Only if it really doesn't exist +``` + +### Problem: Container Doesn't Respond +**Symptom**: Container exists but doesn't work properly +```bash +make restart # Try restarting first +make status # Verify the status +``` + +### Problem: Configuration Changes Not Applied +**Symptom**: You modified docker-compose.yml but changes aren't applied +```bash +make restart # For most changes +make destroy && make build # Only for major changes +``` + +## 🎯 Best Practices + +1. **Use `make enter` as your main command** - It's the smartest +2. **`make stop` at the end of the day** - Conserves resources +3. **Avoid `make build`** - Only when really necessary +4. **Check with `make status`** - Before reporting issues +5. **Use `make restart`** - Before `make destroy` + +## 🔒 Data Preservation + +The system is configured to preserve: +- ✅ Neovim plugin configurations +- ✅ GitHub Copilot sessions +- ✅ Command history +- ✅ Personal configurations +- ✅ Files in `.dotfiles/` +- ✅ Git configurations + +**Data is preserved between `make stop` and `make start`** + +## 📈 Performance + +- `make start`: ~1-2 seconds +- `make enter`: ~1-2 seconds + startup time if it was stopped +- `make stop`: ~10 seconds (normal, Docker does clean shutdown) +- `make build`: ~2-5 minutes (only when necessary) + +--- + +💡 **Tip**: For daily use, `make enter` is all you need 90% of the time. diff --git a/scripts/init.sh b/scripts/init.sh index 7856c8e..373d506 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -41,8 +41,10 @@ if ! docker info >/dev/null 2>&1; then exit 1 fi -# Check if container exists -if ! docker compose ps | grep -q "$CONTAINER_NAME"; then +# Check if container exists and its state +CONTAINER_STATE=$(docker inspect "$CONTAINER_NAME" 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || echo "missing") + +if [ "$CONTAINER_STATE" = "missing" ]; then log_warning "Container not found. You may need to build it first." read -p "Do you want to build the environment? (y/N): " -n 1 -r echo @@ -55,21 +57,17 @@ if ! docker compose ps | grep -q "$CONTAINER_NAME"; then log_info "Run 'make build' to build the environment." exit 1 fi -fi - -# Start the container if it's not running -if ! docker compose ps | grep -q "Up"; then - log_info "Starting the container..." - if docker compose up -d; then +elif [ "$CONTAINER_STATE" = "running" ]; then + log_info "Container is already running" +else + log_info "Container exists but is stopped. Starting it..." + if docker compose start; then log_success "Container started successfully" - # Wait a moment for the container to be fully ready sleep 2 else - log_error "Failed to start container" + log_error "Failed to start existing container" exit 1 fi -else - log_info "Container is already running" fi # Enter the container From f8659a6046d3b106a12ac65d7b09dd2deeb688e3 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Fri, 27 Jun 2025 17:08:20 -0600 Subject: [PATCH 14/14] fix: update version placeholder in docker-compose and improve README formatting --- README.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 06a0db6..f7d197a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ services: code-editor: build: args: - VERSION: 1.2.0 + VERSION: x.x.x TIMEZONE: America/Mexico_City # Change to your timezone environment: - TZ=America/Mexico_City # Change to your timezone @@ -135,7 +135,7 @@ lazyvim-docker/ --- -## �️ Included Tools +## 🛠️ Included Tools **Core Development:** - Neovim with LazyVim configuration @@ -209,16 +209,6 @@ make clean # Free up disk space --- -## ⭐ Support - -If this project helps you, please: -- ⭐ Star the repository -- 🐛 Report issues -- 💡 Suggest improvements -- 📖 Improve documentation - ---- - **Ready to code? Run `make quick` and start developing! 🚀** ## 💡 Usage Tips @@ -275,7 +265,7 @@ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file ## 👨‍💻 Author Created by **ManghiDev** -🌐 Website: [Personal web](https://manghi.dev) +🌐 Website: [Personal Web](https://manghi.dev) 📧 Contact: [GitHub Issues](https://github.com/manghidev/lazyvim-docker/issues) ---