Skip to content

Commit

Permalink
Merge pull request #73 from entelecheia/entelecheia/issue72
Browse files Browse the repository at this point in the history
  • Loading branch information
entelecheia authored Aug 31, 2023
2 parents 600a764 + ceb8a18 commit 5479501
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 32 deletions.
65 changes: 47 additions & 18 deletions chezmoi/.chezmoi.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,16 @@
# {{- end -}}

# {{- $dockerfiles_share_dir := joinPath .chezmoi.homeDir ".local/share/dockerfiles" -}}
# {{- $docker_global_env_filename := ".env.docker" -}}
# {{- $docker_secret_env_filename := ".env.secret" -}}
# {{- $docker_container_registry := "ghcr.io" -}}
# {{- $dockerfiles_repo := "https://github.com/entelecheia/dockerfiles.git" -}}
# {{- if and (hasKey . "docker") (hasKey .docker "repo") -}}
# {{- $dockerfiles_repo = .docker.repo -}}
# {{- end -}}
# {{- if and (hasKey . "docker") (hasKey .docker "container_registry") -}}
# {{- $docker_container_registry = .docker.container_registry -}}
# {{- end -}}

# {{- $workspace_location := "" -}}
# {{- $winhome := or (env "WINHOME") (output "sh" "-c" "command -v wslpath > /dev/null && command -v wslvar > /dev/null && wslpath $(wslvar USERPROFILE) || echo ''" | trim) -}}
Expand Down Expand Up @@ -489,22 +495,6 @@
# {{- writeToStdout "❎ GitHub username not set\n" -}}
# {{- end -}}

# {{- if $interactive -}}
# {{- $question := "❔ What is your Docker username" -}}
# {{- $answer := "" -}}
# {{- if $docker_username -}}
# {{- $answer = promptString $question $docker_username -}}
# {{- else -}}
# {{- $answer = promptString $question -}}
# {{- end -}}
# {{- $docker_username = $answer -}}
# {{- end -}}
# {{- if $docker_username -}}
# {{- writeToStdout (printf "✅ Docker username set as '%s'\n" $docker_username) -}}
# {{- else -}}
# {{- writeToStdout "❎ Docker username not set\n" -}}
# {{- end -}}

# {{- if $interactive -}}
# {{- range $i := until 99 -}}
# {{- $question := "❔ What is your email" -}}
Expand Down Expand Up @@ -627,6 +617,38 @@
# {{- end -}}
# {{- writeToStdout (printf "✅ dotdrop user profile set as '%s'\n" $dotdrop_user_profile) -}}

# {{- if $interactive -}}
# {{- $question := "❔ What is your Docker username" -}}
# {{- $answer := "" -}}
# {{- if $docker_username -}}
# {{- $answer = promptString $question $docker_username -}}
# {{- else -}}
# {{- $answer = promptString $question -}}
# {{- end -}}
# {{- $docker_username = $answer -}}
# {{- end -}}
# {{- if $docker_username -}}
# {{- writeToStdout (printf "✅ Docker username set as '%s'\n" $docker_username) -}}
# {{- else -}}
# {{- writeToStdout "❎ Docker username not set\n" -}}
# {{- end -}}

# {{- if $interactive -}}
# {{- $question := "❔ What is your Docker container registry (ex: ghcr.io)" -}}
# {{- $answer := "" -}}
# {{- if $docker_container_registry -}}
# {{- $answer = promptString $question $docker_container_registry -}}
# {{- else -}}
# {{- $answer = promptString $question -}}
# {{- end -}}
# {{- $docker_container_registry = $answer -}}
# {{- end -}}
# {{- if $docker_container_registry -}}
# {{- writeToStdout (printf "✅ Docker container registry set as '%s'\n" $docker_container_registry) -}}
# {{- else -}}
# {{- writeToStdout "❎ Docker container registry not set\n" -}}
# {{- end -}}

# {{- if and $interactive ($minimum | not) -}}
# {{- $question := "❔ What is your dockerfiles repository URL (ex: https://github.com/entelecheia/dockerfiles.git)" -}}
# {{- $answer := "" -}}
Expand Down Expand Up @@ -672,7 +694,9 @@
# {{- writeToStdout (printf "✅ Worksapce root symlinked to '%s'\n" $workspace_home) -}}
# {{- $project_dir := joinPath $workspace_home "projects" -}}
# {{- $reference_dir := joinPath $workspace_home "references" -}}
# {{- $containers_dir := joinPath $workspace_home "containers" -}}
# {{- $container_dir := joinPath $workspace_home "containers" -}}
# {{- $model_dir := joinPath $workspace_home "models" -}}
# {{- $dataset_dir := joinPath $workspace_home "datasets" -}}

# {{- if and $interactive ($minimum | not) -}}
# {{- $question := "❔ Do you want to symlink workspace to colab default google drive directory to maintain persistence across sessions" -}}
Expand Down Expand Up @@ -1087,7 +1111,10 @@ data:
docker:
repo: {{ $dockerfiles_repo | quote }}
share_dir: {{ $dockerfiles_share_dir | quote }}
global_env_filename: {{ $docker_global_env_filename | quote }}
secret_env_filename: {{ $docker_secret_env_filename | quote }}
username: {{ $docker_username | quote }}
container_registry: {{ $docker_container_registry | quote }}
pass:
enabled: {{ $use_pass }}
store_dir: {{ $pass_store_dir | quote }}
Expand Down Expand Up @@ -1158,7 +1185,9 @@ data:
colab_drive: "/content/drive/MyDrive"
project_dir: {{ $project_dir | quote }}
reference_dir: {{ $reference_dir | quote }}
container_dir: {{ $containers_dir | quote }}
container_dir: {{ $container_dir | quote }}
model_dir: {{ $model_dir | quote }}
dataset_dir: {{ $dataset_dir | quote }}
github_repos:
# {{- if $github_clones -}}
# {{- range (split "," $github_clones) }}
Expand Down
14 changes: 12 additions & 2 deletions chezmoi/dot_config/shrc/00-dotfiles-export.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,24 @@ export DOTDROP_PROFILE="{{ .dotdrop.user_profile }}"
export DOTDROP_CONFIGDIR="{{ .dotdrop.config_dir }}"
export DOTDROP_CONFIG="{{ .dotdrop.config_file }}"
export GITHUB_USERNAME="{{ .github.username }}"
export DOCKER_USERNAME="{{ .docker.username }}"
export WORKSPACE_LOCATION="{{ .workspace.location }}"
export WORKSPACE_ROOT="{{ .workspace.root }}"
export WORKSPACE_HOME="{{ .workspace.home }}"
export WORKSPACE_PROJECT_DIR="{{ .workspace.project_dir }}"
export GIT_WORKSPACE="${WORKSPACE_PROJECT_DIR}"
export WORKSPACE_REFERENCE_DIR="{{ .workspace.reference_dir }}"
export WORKSPACE_CONTAINER_DIR="{{ .workspace.container_dir }}"
export GIT_COMMIT_GPGSIGN="{{ .git.gpgsign }}"
export WORKSPACE_MODEL_DIR="{{ .workspace.model_dir }}"
export WORKSPACE_DATASET_DIR="{{ .workspace.dataset_dir }}"

export DOCKER_USERNAME="{{ .docker.username }}"
export CONTAINER_REGISTRY="{{ .docker.container_registry }}"
export DOCKERFILES_SHARE_DIR="{{ .docker.share_dir }}"
export DOCKER_GLOBAL_ENV_FILENAME="{{ .docker.global_env_filename }}"
DOCKER_GLOBAL_ENV_FILE="${DOCKERFILES_SHARE_DIR}/${DOCKER_GLOBAL_ENV_FILENAME}"
export DOCKER_GLOBAL_ENV_FILE="${DOCKER_GLOBAL_ENV_FILE}"
export DOCKER_SECRET_ENV_FILENAME="{{ .docker.secret_env_filename }}"

export CODECOV_TOKEN="{{ .codecov.api_token }}"
export WAKATIME_API_KEY="{{ .wakatime.api_key }}"
export OPENAI_API_KEY="{{ .openai.api_key }}"
Expand All @@ -90,6 +99,7 @@ fi
export GITHUB_TOKEN="${GITHUB_TOKEN:-${GH_TOKEN}}"
export GH_TOKEN="${GITHUB_TOKEN}"
export GITHUB_USER="${GITHUB_USERNAME}"
export GIT_COMMIT_GPGSIGN="{{ .git.gpgsign }}"

export VISUAL="{{ .editor }}"
export EDITOR="{{ .editor }}"
Expand Down
25 changes: 13 additions & 12 deletions chezmoi/dot_local/bin/executable_dk-compose.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ COMPOSE_FILENAME=""
ENV_FILE=""
SHELL_ENV_FILE=""
SHELL_ENV_FILENAME=""
GLOBAL_ENV_FILE=""
DOCKER_GLOBAL_ENV_FILE=${DOCKER_GLOBAL_ENV_FILE:-""}
SECRET_ENV_FILE=""
IMAGE_VERSION=""
LATEST="false"
PUSH="false"
FROM_PROJECT="false"
IMAGE_NAME=""
CONTAINER_NETWORK_NAME=""
CONTAINER_REGISTRY=""
USERNAME="{{ .chezmoi.username }}"
CONTAINER_REGISTRY=${CONTAINER_REGISTRY:-"{{ .docker.container_registry }}"}
USERNAME=${USERNAME:-"{{ .chezmoi.username }}"}
ADDITIONAL_ARGS=""

set +u
Expand Down Expand Up @@ -132,11 +132,11 @@ while [[ $# -gt 0 ]]; do
SHELL_ENV_FILE="${1#*=}"
;;
--global-env-file)
GLOBAL_ENV_FILE="$2"
DOCKER_GLOBAL_ENV_FILE="$2"
shift
;;
--global-env-file=*)
GLOBAL_ENV_FILE="${1#*=}"
DOCKER_GLOBAL_ENV_FILE="${1#*=}"
;;
--secret-env-file)
SECRET_ENV_FILE="$2"
Expand Down Expand Up @@ -219,7 +219,7 @@ elif [[ "$IMAGE_VERSION" == "pre*" ]] || [[ "$IMAGE_VERSION" == "night*" ]]; the
fi
export IMAGE_VERSION

DOCKERFILES_SHARE_DIR="{{- .docker.share_dir }}"
DOCKERFILES_SHARE_DIR=${DOCKERFILES_SHARE_DIR:-"{{ .docker.share_dir }}"}
# check PATHs
if [[ -z "$PROJECT_DIR" ]]; then
PROJECT_DIR="${WORKSPACE_PROJECT_DIR}/${DOCKER_PROJECT_NAME}"
Expand Down Expand Up @@ -280,14 +280,14 @@ export USER_UID
export USER_GID

# global env file
if [ -z "$GLOBAL_ENV_FILE" ]; then
GLOBAL_ENV_FILE="${DOCKERFILES_SHARE_DIR}/src/global.env"
if [ -z "$DOCKER_GLOBAL_ENV_FILE" ]; then
DOCKER_GLOBAL_ENV_FILE="${DOCKERFILES_SHARE_DIR}/{{ .docker.global_env_filename }}"
fi
if [[ -f "$GLOBAL_ENV_FILE" ]]; then
log_task "Exporting global environment variables from ${GLOBAL_ENV_FILE}"
if [[ -f "$DOCKER_GLOBAL_ENV_FILE" ]]; then
log_task "Exporting global environment variables from ${DOCKER_GLOBAL_ENV_FILE}"
set -a # export all variables (set -o allexport)
# shellcheck disable=SC1090
c source "$GLOBAL_ENV_FILE"
c source "$DOCKER_GLOBAL_ENV_FILE"
set +a
fi

Expand Down Expand Up @@ -316,7 +316,8 @@ fi

# secret env file
if [ -z "$SECRET_ENV_FILE" ]; then
SECRET_ENV_FILE="${PROJECT_DIR}/.env.secret"
DOCKER_SECRET_ENV_FILENAME=${DOCKER_SECRET_ENV_FILENAME:-"{{ .docker.secret_env_filename }}"}
SECRET_ENV_FILE="${PROJECT_DIR}/${DOCKER_SECRET_ENV_FILENAME}"
fi
if [[ -f "$SECRET_ENV_FILE" ]]; then
log_task "Exporting secret environment variables from ${SECRET_ENV_FILE}"
Expand Down

0 comments on commit 5479501

Please sign in to comment.