Skip to content

Commit

Permalink
feat(base): check for local dotfiles when running container
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonemms committed Aug 22, 2023
1 parent 9b257c9 commit 28d4758
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions base/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ RUN { echo && echo "PS1='\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[0

COPY --chown=vscode:vscode bash_aliases .bash_aliases
COPY --chown=vscode:vscode gitconfig .config/git/config
COPY --chown=vscode:vscode exec-dotfiles.sh $HOME/.local/bin/exec-dotfiles

# Custom PATH additions
ENV PATH=$HOME/.local/bin:$PATH
Expand Down
15 changes: 13 additions & 2 deletions base/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@
},
"shutdownAction": "stopContainer",
"remoteUser": "vscode",
"initializeCommand": {
"ensure-dotfiles": "mkdir -p ${localEnv:HOME}${localEnv:USERPROFILE}/.dotfiles"
},
"postCreateCommand": {
"direnv": "direnv allow || true"
}
"direnv": "direnv allow || true",
"exec-dotfiles": "exec-dotfiles"
},
"mounts": [
{
"source": "${localEnv:HOME}${localEnv:USERPROFILE}/.dotfiles",
"target": "/home/vscode/.dotfiles",
"type": "bind"
}
]
}
30 changes: 30 additions & 0 deletions base/.devcontainer/exec-dotfiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Copyright 2023 Simon Emms <simon@simonemms.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This gives the same functionality as Gitpod's implementation
# @link https://www.gitpod.io/docs/configure/user-settings/dotfiles
# @link https://github.com/gitpod-io/gitpod/blob/158a948b4d6bdff636da1d23404f8d9232ea9ff6/components/supervisor/pkg/supervisor/supervisor.go#L524,L687

DOTFILES_DIR="${HOME}/.dotfiles"
files=("install.sh" "install" "bootstrap.sh" "bootstrap" "script/bootstrap" "setup.sh" "setup" "script/setup")

for file in "${files[@]}"; do
full_path="${DOTFILES_DIR}/${file}"
if [ -f "${full_path}" ]; then
echo "Found ${full_path} - executing"

echo ${full_path}
fi
done

0 comments on commit 28d4758

Please sign in to comment.