gitpod
                                
                                 gitpod copied to clipboard
                                
                                    gitpod copied to clipboard
                            
                            
                            
                        Add ability to cache arbitrary directories across workspaces
Is your feature request related to a problem? Please describe
I run an extensive suite of pre-commit hooks on my default projects (example). These take quite some time to install every time I start a new workspace, somewhere in the region of 2-5 minutes. As pre-commit, by design, blocks git commit it means that I'm often waiting around if I have a quick change to make.
Describe the behaviour you'd like
Allow caching of arbitrary directories in the .gitpod.yml file. In both GitHub and GitLab, I'm able to cache things so the install is only about 20 seconds.
The cache could follow the GitLab syntax:
cache:
  paths:
    - /path/to/cache
To further emulate the GitLab behaviour, anything cached in the default branch should be available in default branch and all branches, and anything cached in a branch should only be available to the same branch name.
Eg:
- cache directory on mainshould be available tomainandfeat/some-branch
- anything cached by feat/some-other-branch, that should only be available tofeat/some-other-branch
Describe alternatives you've considered
- wait for ages
- use dev containers
- wait longer
Additional context
Hi @mrsimonemms! 👋
Using a custom dockerfile might be the best way to optimize this.
.gitpod.Dockerfile contents:
FROM gitpod/workspace-full
RUN sudo pip3 install pre-commit
ARG onetime_cache_dir="/tmp/.workdir"
RUN mkdir -p "${onetime_cache_dir}"
COPY --chown=gitpod:gitpod . "${onetime_cache_dir}"
RUN cd "${onetime_cache_dir}" \
  && pre-commit install --install-hooks -t pre-commit -t commit-msg
Customized for https://github.com/mrsimonemms/new
FROM gitpod/workspace-full
RUN curl -sfL gpm.simonemms.com | bash \
  && sudo pip3 install pre-commit cookieninja cruft
ARG onetime_cache_dir="/tmp/.workdir"
RUN mkdir -p "${onetime_cache_dir}"
COPY --chown=gitpod:gitpod . "${onetime_cache_dir}"
RUN cd "${onetime_cache_dir}" \
  && pre-commit install --install-hooks -t pre-commit -t commit-msg
.gitpod.yml contents:
image:
  file: .gitpod.Dockerfile
tasks:
  - name: Setup
    init: |
      pre-commit install --install-hooks -t pre-commit -t commit-msg
Customized for https://github.com/mrsimonemms/new
image:
  file: .gitpod.Dockerfile
tasks:
  - name: Setup
    init: pre-commit install --install-hooks -t pre-commit -t commit-msg && exit 0
vscode:
  extensions:
    - donjayamanne.git-extension-pack
    - EditorConfig.EditorConfig
    - waderyan.gitblame
    - GitHub.vscode-github-actions
    - ms-vscode.makefile-tools
With this setup it was almost instant, took no longer than a second to run the pre-commit command in the init task.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.