diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96b4fbe4..29520bb5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
+## v0.38.7 (2024-03-28)
+
+### Fix
+
+* **configuration:** Remove unnecessary commented-out code and prompts for various services. ([`ed66e3d`](https://github.com/entelecheia/dotfiles/commit/ed66e3d475b54db3fd49de54af30fa39cc460c96))
+
## v0.38.6 (2024-03-27)
### Fix
diff --git a/README.md b/README.md
index 4128d38d..fb4cc105 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,112 @@ Easily manage and synchronize your dotfiles across multiple environments with th
The Dotfiles project offers a comprehensive solution for managing and synchronizing your dotfiles across various environments, including local development, CI/CD pipelines, and production systems. With this tool, you can effortlessly maintain a consistent development environment, simplifying collaboration and reducing the time spent on setting up new machines. The Dotfiles project uses the Chezmoi framework, providing a secure and flexible way to manage your configuration files. The project also includes support for additional integrations, such as Docker, GitHub repositories, and password management tools, further enhancing your development experience. Get started with the Dotfiles project today and enjoy a seamless, hassle-free configuration management process.
+## Getting started
+
+The following guide will walk you through the process of installing and initializing the Dotfiles project on your machine. This will help you set up a consistent development environment across different systems, simplifying your workflow and making it easier to collaborate with others.
+
+### Prerequisites
+
+Before proceeding with the installation, ensure that your system has the following tools:
+
+- `wget` or `curl`: To fetch the installation script from the internet.
+- `git`: To clone the Dotfiles repository.
+
+Most Linux distributions come with these tools pre-installed. If not, you can install them using your package manager.
+
+### Installing Dotfiles
+
+To install the Dotfiles project on your machine, you need to fetch the installation script and execute it. You can do this using either `wget` or `curl`:
+
+#### Using `wget`:
+
+```bash
+sh -c "$(wget -qO- https://dotfiles.entelecheia.ai/install)"
+```
+
+#### Using `curl`:
+
+```bash
+sh -c "$(curl -fsSL https://dotfiles.entelecheia.ai/install)"
+```
+
+Running the above command will download the installation script and execute it, cloning the Dotfiles repository to your machine and setting up the necessary configurations.
+
+![install dotfiles script](https://github.com/entelecheia/dotfiles/blob/main/docs/figs/install_dotfiles_script.png?raw=true)
+For unattended installations such as in a dockerfile, you can use the environment variables to initialize the dotfiles automatically. For example:
+
+```dockerfile
+# install dotfiles
+ARG USER_FULLNAME="John Doe"
+ARG USER_EMAIL="john.doe@email.com"
+ARG GITHUB_USERNAME="john-doe"
+ARG SYSTEM_HOSTNANE="devcon-arm64"
+
+ENV USER_FULLNAME=$USER_FULLNAME
+ENV USER_EMAIL=$USER_EMAIL
+ENV GITHUB_USERNAME=$GITHUB_USERNAME
+ENV SYSTEM_HOSTNAME=$SYSTEM_HOSTNAME
+ENV WORKSPACE_LOCATION="/"
+ENV DOTFILES_APPLY_ROOTMOI=0
+ENV REMOTE_CONTAINERS=1
+
+RUN sh -c "$(wget -qO- https://dotfiles.entelecheia.ai/install)"
+
+CMD ["zsh"]
+```
+
+Or you can provide the environment variables in the command line:
+
+```bash
+USER_FULLNAME="John Doe" \
+USER_EMAIL="john.doe@email.com" \
+GITHUB_USERNAME="john-doe" \
+SYSTEM_HOSTNAME="devcon-arm64" \
+WORKSPACE_LOCATION="/" \
+DOTFILES_APPLY_ROOTMOI=0 \
+REMOTE_CONTAINERS=1 \
+sh -c "$(wget -qO- https://dotfiles.entelecheia.ai/install)"
+```
+
+### Initializing Dotfiles
+
+After the installation, the initialization process will start automatically. This step applies the configurations defined in your dotfiles to your system, ensuring a consistent development environment.
+
+![initialize dotfiles](https://github.com/entelecheia/dotfiles/blob/main/docs/figs/initialize_dotfiles.png?raw=true)
+
+If you need to re-initialize your dotfiles manually, you can run the following command:
+
+```bash
+dotu init
+```
+
+This command will update your system with the latest configurations from your dotfiles, keeping your environment up-to-date and in sync with any changes you've made.
+
+Once the initialization process is complete, you can start using your newly configured development environment. Feel free to explore the available configurations and customize them to your preferences.
+
+## Repositories and repository templates for setting up your own dotfiles
+
+- [dotdrop-files](https://github.com/entelecheia/dotdrop-files)
+- [password-store](https://github.com/entelecheia/password-store)
+- [passage-store](https://github.com/entelecheia/passage-store)
+
+## Installing the font on **Windows**
+
+1. [Download Fira Code Regular Nerd Font Complete](https://github.com/ryanoasis/nerd-fonts/raw/HEAD/patched-fonts/FiraCode/Regular/complete/Fira%20Code%20Regular%20Nerd%20Font%20Complete.ttf).
+2. Open the downloaded file and click **Install**.
+3. Restart **Windows Terminal** or **VS Code**.
+
+### Configuring the font in **VS Code**
+
+1. Open settings by pressing Ctrl/Cmd+,.
+2. Change the font family to **FiraCode Nerd Font** in **_Terminal › Integrated: Font Family_**.
+
+### Configuring the font in **Windows Terminal**
+
+1. On **Windows Terminal**, press Ctrl+, to open the settings.
+2. Go to **_Profiles -> Defaults_** in the left panel. Then, go to **_Additional settings -> Appearance_**.
+3. At **_Text -> Font face_**, enable the **_Show all fonts_** option and select **_FiraCode Nerd Font_**. Like below:
+
## Changelog
See the [CHANGELOG] for more information.
diff --git a/chezmoi/.chezmoidata.yaml b/chezmoi/.chezmoidata.yaml
index c8016b52..891f773b 100644
--- a/chezmoi/.chezmoidata.yaml
+++ b/chezmoi/.chezmoidata.yaml
@@ -1,4 +1,4 @@
-DOTFILES_VERSION: 0.38.6
+DOTFILES_VERSION: 0.38.7
packages:
- name: 1password-cli
apt: true
diff --git a/chezmoi/dot_config/shrc/20-export.tmpl b/chezmoi/dot_config/shrc/20-export.tmpl
index e8e3b84f..b009f003 100644
--- a/chezmoi/dot_config/shrc/20-export.tmpl
+++ b/chezmoi/dot_config/shrc/20-export.tmpl
@@ -69,3 +69,10 @@ fi
if command -v fig >/dev/null 2>&1 && [ -d "${HOME}/.fig/bin" ]; then
export PATH="${HOME}/.fig/bin:${PATH}"
fi
+
+{{ if not .system.is_wsl -}}
+# Allow connections from any host
+export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
+# Allow connections from Docker containers
+export LIBGL_ALWAYS_INDIRECT=1
+{{- end }}
diff --git a/chezmoi/dot_local/bin/executable_dk-compose.tmpl b/chezmoi/dot_local/bin/executable_dk-compose.tmpl
index c652dd0c..8a11aa01 100644
--- a/chezmoi/dot_local/bin/executable_dk-compose.tmpl
+++ b/chezmoi/dot_local/bin/executable_dk-compose.tmpl
@@ -18,6 +18,7 @@ Options:
--variant IMAGE_VARIANT Specify a variant for the Docker image.
--from-project Use the project directory to build the Docker image.
--project-directory DIR Specify the project directory. Default is the Docker name inside the workspace project directory.
+--project-id PROJECT_ID Specify the project id to differentiate between multiple containers.
--dockerfiles-directory DIR Specify the directory containing Docker files. Default is the .docker directory inside the project directory.
-c, --compose-file FILE Specify the Docker Compose file. Default is docker-compose.yaml inside the Docker files directory.
-e, --env-file FILE Specify the environment file for Docker Compose.
@@ -29,6 +30,7 @@ Options:
--push Push the Docker image after building it.
--registry CONTAINER_REGISTRY Specify the Docker registry.
-n, --name IMAGE_NAME Specify the name of the Docker image.
+--service SERVICE_NAME Specify the name of the Docker service.
--network NETWORK_NAME Specify the Docker network.
-u, --username USERNAME Specify the username. Default is the current user.
-h, --help Display this help message.
@@ -41,8 +43,9 @@ dk-compose build my-service --variant app --version latest --from-project --proj
# declare arguments
COMMAND=""
-DOCKER_PROJECT_NAME=""
-IMAGE_VARIANT="base"
+DOCKER_PROJECT_NAME=${DOCKER_PROJECT_NAME:-""}
+DOCKER_PROJECT_ID=${DOCKER_PROJECT_ID:-"default"}
+IMAGE_VARIANT=${IMAGE_VARIANT:-"base"}
PROJECT_DIR=""
DOCKERFILES_DIR=""
COMPOSE_FILENAME=""
@@ -54,8 +57,9 @@ SECRET_ENV_FILE=""
IMAGE_VERSION=""
LATEST="false"
PUSH="false"
-FROM_PROJECT="false"
+FROM_PROJECT="true"
IMAGE_NAME=""
+SERVICE_NAME="workspace"
CONTAINER_NETWORK_NAME=""
CONTAINER_REGISTRY=${CONTAINER_REGISTRY:-"{{ .docker.container_registry }}"}
USERNAME=${USERNAME:-"{{ .chezmoi.username }}"}
@@ -66,7 +70,11 @@ set +u
# first argument is the command
COMMAND="$1"
shift
-if [[ "$COMMAND" != "build" ]] && [[ "$COMMAND" != "run" ]] && [[ "$COMMAND" != "up" ]] && [[ "$COMMAND" != "down" ]] && [[ "$COMMAND" != "config" ]]; then
+if [[ "$COMMAND" == "" ]] || [[ "$COMMAND" == "-h" ]] || [[ "$COMMAND" == "--help" ]]; then
+ echo "Usage: $0 $USAGE" >&2
+ exit 1
+fi
+if [[ "$COMMAND" != "build" ]] && [[ "$COMMAND" != "run" ]] && [[ "$COMMAND" != "up" ]] && [[ "$COMMAND" != "down" ]] && [[ "$COMMAND" != "config" ]] && [[ "$COMMAND" != "push" ]]; then
echo "Invalid command: $COMMAND" >&2
echo "Usage: $0 $USAGE" >&2
exit 1
@@ -74,12 +82,12 @@ fi
# check second argument starts with a dash
# if it does, it's an option and DOCKER_PROJECT_NAME can be the last argument
# if not, it's the DOCKER_PROJECT_NAME
-if [[ "$1" != -* ]]; then
+if [[ "$1" != -* ]] && [[ $# -gt 0 ]]; then
# if no arguments, print usage
- if [[ $# -eq 0 ]]; then
- echo "Usage: $0 $USAGE" >&2
- exit 1
- fi
+ # if [[ $# -eq 0 ]]; then
+ # echo "Usage: $0 $USAGE" >&2
+ # exit 1
+ # fi
DOCKER_PROJECT_NAME="$1"
shift
fi
@@ -103,6 +111,13 @@ while [[ $# -gt 0 ]]; do
--project-directory=*)
PROJECT_DIR="${1#*=}"
;;
+ --project-id)
+ DOCKER_PROJECT_ID="$2"
+ shift
+ ;;
+ --project-id=*)
+ DOCKER_PROJECT_ID="${1#*=}"
+ ;;
--dockerfiles-directory)
DOCKERFILES_DIR="$2"
shift
@@ -165,6 +180,13 @@ while [[ $# -gt 0 ]]; do
--name=*)
IMAGE_NAME="${1#*=}"
;;
+ --service)
+ SERVICE_NAME="$2"
+ shift
+ ;;
+ --service=*)
+ SERVICE_NAME="${1#*=}"
+ ;;
--registry)
CONTAINER_REGISTRY="$2"
shift
@@ -222,10 +244,22 @@ export IMAGE_VERSION
DOCKERFILES_SHARE_DIR=${DOCKERFILES_SHARE_DIR:-"{{ .docker.share_dir }}"}
# check PATHs
if [[ -z "$PROJECT_DIR" ]]; then
- PROJECT_DIR="${WORKSPACE_PROJECT_DIR}/${DOCKER_PROJECT_NAME}"
+ if [[ -z "$DOCKER_PROJECT_NAME" ]]; then
+ PROJECT_DIR="."
+ else
+ PROJECT_DIR="${WORKSPACE_PROJECT_DIR}/${DOCKER_PROJECT_NAME}"
+ fi
+fi
+# if project directory does not exist, try WORKSPACE_CONTAINER_DIR
+if [[ ! -d "$PROJECT_DIR" ]]; then
+ PROJECT_DIR="${WORKSPACE_CONTAINER_DIR}/${DOCKER_PROJECT_NAME}"
+fi
+# if project directory does not exist, try current directory
+if [[ ! -d "$PROJECT_DIR" ]]; then
+ PROJECT_DIR="./${DOCKER_PROJECT_NAME}"
fi
# if project directory does not exist or FROM_PROJECT is false, use dockerfile repo path
-if [[ ! -d "$PROJECT_DIR" ]] || [[ "$FROM_PROJECT" != "false" ]]; then
+if [[ ! -d "$PROJECT_DIR" ]] || [[ "$FROM_PROJECT" == "false" ]]; then
PROJECT_DIR="${DOCKERFILES_SHARE_DIR}/src/${DOCKER_PROJECT_NAME}"
fi
# if it still does not exist, exit
@@ -244,12 +278,8 @@ if [[ -n "$COMPOSE_FILENAME" ]]; then
else
if [[ -n "$IMAGE_VARIANT" ]]; then
# {base_name}-{IMAGE_VARIANT}.{ext}
- COMPOSE_FILENAME="docker-compose-${IMAGE_VARIANT}.yaml"
+ COMPOSE_FILENAME="docker-compose.${IMAGE_VARIANT}.yaml"
COMPOSE_FILE="${DOCKERFILES_DIR}/${COMPOSE_FILENAME}"
- if [[ ! -f "$COMPOSE_FILE" ]]; then
- COMPOSE_FILENAME="docker-compose.${IMAGE_VARIANT}.yaml"
- COMPOSE_FILE="${DOCKERFILES_DIR}/${COMPOSE_FILENAME}"
- fi
else
# {base_name}.{ext}
COMPOSE_FILENAME="docker-compose.yaml"
@@ -273,7 +303,6 @@ if [[ -n "$CONTAINER_REGISTRY" ]]; then
export CONTAINER_REGISTRY
fi
# export user id and group id
-export USERNAME
USER_UID="$(id -u)"
USER_GID="$(id -g)"
export USER_UID
@@ -291,6 +320,45 @@ if [[ -f "$DOCKER_GLOBAL_ENV_FILE" ]]; then
set +a
fi
+# project env file
+ENV_ARGS=""
+if [[ -f "$ENV_FILE" ]]; then
+ ENV_ARGS="--env-file ${ENV_FILE}"
+ log_task "Loading environment variables for the services from ${ENV_FILE}"
+fi
+# shellcheck disable=SC1091
+DOCKER_VERSION_FILE="${DOCKERFILES_DIR}/docker.version"
+if [[ -f "$DOCKER_VERSION_FILE" ]]; then
+ log_task "Loading Docker version from ${DOCKER_VERSION_FILE}"
+ set -a
+ # shellcheck disable=SC1090
+ c source "$DOCKER_VERSION_FILE"
+ set +a
+fi
+PROJECT_ID_ENV_FILE="${DOCKERFILES_DIR}/.ids/${DOCKER_PROJECT_ID}.env"
+if [ -e "${PROJECT_ID_ENV_FILE}" ]; then
+ echo "Loading project ID specific environment variables from ${PROJECT_ID_ENV_FILE}"
+ set -a
+ # shellcheck disable=SC1091,SC1090
+ c source "${PROJECT_ID_ENV_FILE}"
+ set +a
+fi
+COMMON_ENV_FILE="${DOCKERFILES_DIR}/docker.common.env"
+if [ -e "${COMMON_ENV_FILE}" ]; then
+ echo "Loading common environment variables from ${COMMON_ENV_FILE}"
+ set -a
+ # shellcheck disable=SC1091
+ c source "${COMMON_ENV_FILE}"
+ set +a
+fi
+# VARIANT_ENV_FILE="${DOCKERFILES_DIR}/docker.${IMAGE_VARIANT}.env"
+# if [ -e "${VARIANT_ENV_FILE}" ]; then
+# echo "Loading environment variables from ${VARIANT_ENV_FILE}"
+# set -a
+# # shellcheck disable=SC1091,SC1090
+# c source "${VARIANT_ENV_FILE}"
+# set +a
+# fi
# shell env file
if [ -z "$SHELL_ENV_FILE" ]; then
if [[ -n "$IMAGE_VARIANT" ]]; then
@@ -327,12 +395,6 @@ if [[ -f "$SECRET_ENV_FILE" ]]; then
set +a
fi
-# project env file
-ENV_ARGS=""
-if [[ -f "$ENV_FILE" ]]; then
- ENV_ARGS="--env-file ${ENV_FILE}"
- log_task "Loading environment variables for the services from ${ENV_FILE}"
-fi
# if network does not exist, create it
if [[ -n "$CONTAINER_NETWORK_NAME" ]]; then
@@ -347,12 +409,34 @@ else
log_info "CONTAINER_NETWORK_NAME not set, skipping creation of docker network."
fi
+# prepare local workspace to be mounted
+echo "Preparing local workspace directories"
+[ ! -d "${HOST_WORKSPACE_ROOT}" ] && mkdir -p "${HOST_WORKSPACE_ROOT}"
+[ ! -d "${HOST_SCRIPTS_DIR}" ] && cp -r "${DOCKERFILES_DIR}/scripts" "${HOST_SCRIPTS_DIR}"
+[ ! -d "${HOST_SSH_DIR}" ] && mkdir -p "${HOST_SSH_DIR}"
+[ ! -d "${HOST_CACHE_DIR}" ] && mkdir -p "${HOST_CACHE_DIR}"
+[ ! -d "${HOST_HF_HOME}" ] && mkdir -p "${HOST_HF_HOME}"
+[ ! -d "${HOST_GH_CONFIG_DIR}" ] && mkdir -p "${HOST_GH_CONFIG_DIR}"
+[ ! -d "${HOST_PASSAGE_DIR}" ] && mkdir -p "${HOST_PASSAGE_DIR}"
+
+if docker --version &>/dev/null; then
+ if [ "${COMMAND}" == "push" ]; then
+ CMD="docker push ${CONTAINER_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
+ elif [ "${COMMAND}" == "login" ]; then
+ echo "GITHUB_CR_PAT: $GITHUB_CR_PAT"
+ CMD="docker login ghcr.io -u $GITHUB_USERNAME"
+ fi
+fi
if docker-compose version &>/dev/null; then
log_task "docker compose ${COMMAND} for [${DOCKER_PROJECT_NAME}] with variant [${IMAGE_VARIANT}] and version [${IMAGE_VERSION}] from [${PROJECT_DIR}]"
# change to the directory of the build context
c cd "${PROJECT_DIR}" || exit 1
- CMD="docker-compose --project-directory ${PROJECT_DIR} -f ${COMPOSE_FILE} ${ENV_ARGS} ${COMMAND} ${ADDITIONAL_ARGS}"
+ if [ "${COMMAND}" == "run" ]; then
+ CMD="docker-compose --project-directory ${PROJECT_DIR} -f ${COMPOSE_FILE} ${ENV_ARGS} ${COMMAND} ${SERVICE_NAME} ${ADDITIONAL_ARGS}"
+ else
+ CMD="docker-compose --project-directory ${PROJECT_DIR} -f ${COMPOSE_FILE} ${ENV_ARGS} ${COMMAND} ${ADDITIONAL_ARGS}"
+ fi
c eval "$CMD" || exit 1
if [[ "$PUSH" == "true" ]]; then
diff --git a/chezmoi/dot_local/bin/executable_dotfiles-initialize-zsh.tmpl b/chezmoi/dot_local/bin/executable_dotfiles-initialize-zsh.tmpl
index c82337c8..8a0913b0 100755
--- a/chezmoi/dot_local/bin/executable_dotfiles-initialize-zsh.tmpl
+++ b/chezmoi/dot_local/bin/executable_dotfiles-initialize-zsh.tmpl
@@ -6,6 +6,17 @@ log_task "Initializing ZSH"
zsh_path="/bin/zsh"
+# if zsh is not installed, install it
+if ! command -v zsh &>/dev/null; then
+ # {{ if .system.is_sudoer }}
+ log_task "Installing ZSH"
+ c sudo apt-get install -y zsh
+# {{ else }}
+ log_error "ZSH is not installed and the user is not a sudoer. Unable to install ZSH and change the default shell."
+ exit 0
+# {{ end }}
+fi
+
if ! getent passwd '{{ .chezmoi.username }}' | cut -d : -f 7- | grep -q "^${zsh_path}$"; then
log_task "Configuring ZSH as default shell"
diff --git a/chezmoi/dot_local/bin/executable_pass-init.tmpl b/chezmoi/dot_local/bin/executable_pass-init.tmpl
index 4fe208f9..7ff123df 100644
--- a/chezmoi/dot_local/bin/executable_pass-init.tmpl
+++ b/chezmoi/dot_local/bin/executable_pass-init.tmpl
@@ -4,6 +4,12 @@
# shellcheck source=/dev/null
source "${HOME}/.config/shrc/00-dotfiles-export"
+# check if pass is installed, otherwise exit
+if ! command -v pass &>/dev/null; then
+ log_error "pass command not found. Please install pass before running this script."
+ exit 0
+fi
+
log_task "Initializing pass"
# Environment variables
diff --git a/chezmoi/dot_local/bin/executable_passage-init.tmpl b/chezmoi/dot_local/bin/executable_passage-init.tmpl
index e4b42436..3cf0daae 100644
--- a/chezmoi/dot_local/bin/executable_passage-init.tmpl
+++ b/chezmoi/dot_local/bin/executable_passage-init.tmpl
@@ -4,6 +4,12 @@
# shellcheck source=/dev/null
source "${HOME}/.config/shrc/00-dotfiles-export"
+# check if passage is installed, otherwise exit
+if ! command -v passage &>/dev/null; then
+ log_error "passage command not found. Please install passage before running this script."
+ exit 0
+fi
+
log_task "Initializing passage"
# Environment variables
@@ -47,8 +53,8 @@ if ! git -C "${PASSAGE_DIR}" remote get-url origin >/dev/null 2>&1; then
fi
if ! gh auth status &>/dev/null; then
- log_info "GitHub is not authenticated, skipping fetching and checking out main branch"
- exit 0
+ log_info "GitHub is not authenticated, skipping fetching and checking out main branch"
+ exit 0
fi
# fetch and checkout the main branch
diff --git a/docs/usage/index.md b/docs/usage/index.md
index d9075f38..6295e743 100644
--- a/docs/usage/index.md
+++ b/docs/usage/index.md
@@ -85,7 +85,6 @@ Once the initialization process is complete, you can start using your newly conf
## Repositories and repository templates for setting up your own dotfiles
-- [dockerfiles](https://github.com/entelecheia/dockerfiles)
- [dotdrop-files](https://github.com/entelecheia/dotdrop-files)
- [password-store](https://github.com/entelecheia/password-store)
- [passage-store](https://github.com/entelecheia/passage-store)
diff --git a/pyproject.toml b/pyproject.toml
index 4311ef5c..5f04896c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dotfiles"
-version = "0.38.6"
+version = "0.38.7"
description = "Easily manage and synchronize your dotfiles across multiple environments with the Dotfiles project, streamlining your development setup and CI/CD pipeline."
authors = ["Young Joon Lee "]
license = "MIT"