Skip to content

Commit 0671120

Browse files
committed
remote cache with leeway and GCP buckets
1 parent f32fb08 commit 0671120

File tree

7 files changed

+90
-5
lines changed

7 files changed

+90
-5
lines changed

.gitpod.Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
FROM gitpod/workspace-full:latest
22

3+
USER root
4+
5+
# leeway
6+
ENV LEEWAY_NESTED_WORKSPACE=true
7+
RUN cd /usr/bin && curl -fsSL https://github.com/gitpod-io/leeway/releases/download/v0.2.5/leeway_0.2.5_Linux_x86_64.tar.gz | tar xz
8+
9+
USER gitpod
10+
311
# We use latest major version of Node.js distributed VS Code. (see about dialog in your local VS Code)
412
RUN bash -c ". .nvm/nvm.sh \
513
&& nvm install 14 \
@@ -17,3 +25,33 @@ RUN sudo apt-get update \
1725
libasound2 libgbm1 xfonts-base xfonts-terminus fonts-noto fonts-wqy-microhei \
1826
fonts-droid-fallback vim-tiny nano libgconf2-dev libgtk-3-dev twm \
1927
&& sudo apt-get clean && sudo rm -rf /var/cache/apt/* && sudo rm -rf /var/lib/apt/lists/* && sudo rm -rf /tmp/*
28+
29+
## Register leeway autocompletion in bashrc
30+
RUN bash -c "echo . \<\(leeway bash-completion\) >> ~/.bashrc"
31+
32+
### Google Cloud ###
33+
# not installed via repository as then 'docker-credential-gcr' is not available
34+
ARG GCS_DIR=/opt/google-cloud-sdk
35+
ENV PATH=$GCS_DIR/bin:$PATH
36+
RUN sudo chown gitpod: /opt \
37+
&& mkdir $GCS_DIR \
38+
&& curl -fsSL https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-344.0.0-linux-x86_64.tar.gz \
39+
| tar -xzvC /opt \
40+
&& /opt/google-cloud-sdk/install.sh --quiet --usage-reporting=false --bash-completion=true \
41+
--additional-components docker-credential-gcr alpha beta \
42+
# needed for access to our private registries
43+
&& docker-credential-gcr configure-docker
44+
45+
# Install tools for gsutil
46+
RUN sudo install-packages \
47+
gcc \
48+
python-dev \
49+
python-setuptools
50+
51+
RUN bash -c "pip uninstall crcmod; pip install --no-cache-dir -U crcmod"
52+
53+
# Set Application Default Credentials (ADC) based on user-provided env var
54+
RUN echo ". /workspace/vscode/scripts/setup-google-adc.sh" >> ~/.bashrc
55+
56+
ENV LEEWAY_WORKSPACE_ROOT=/workspace/vscode
57+
ENV LEEWAY_REMOTE_CACHE_BUCKET=gitpod-core-leeway-cache-branch

.gitpod.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ ports:
55
onOpen: open-browser
66
tasks:
77
- init: |
8-
yarn
9-
yarn --cwd ./build compile
10-
yarn compile
11-
yarn download-builtin-extensions
8+
export VSCODE_INIT_BUILD_DIR=$(leeway describe "//:init" -t "/tmp/build/{{ .Metadata.Name }}.{{ .Metadata.Version }}")
9+
leeway build
10+
sudo cp -rup "$VSCODE_INIT_BUILD_DIR/install/." . | true
1211
command: |
1312
gp sync-done init
1413
export NODE_ENV=development

.leewayignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules/
2+
/out/
3+
/.build/
4+
/.git/

BUILD.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
packages:
2+
- name: install
3+
type: generic
4+
srcs:
5+
- "**"
6+
config:
7+
commands:
8+
- ["yarn"]
9+
- name: init
10+
type: generic
11+
deps:
12+
- ":install"
13+
config:
14+
commands:
15+
- ["yarn", "--cwd", "./install/build", "compile"]
16+
- ["yarn", "--cwd", "./install", "compile"]
17+
- ["yarn", "--cwd", "./install", "download-builtin-extensions"]

WORKSPACE.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
defaultTarget: "//:init"

build/npm/postinstall.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,8 @@ runtime "${runtime}"`;
8888
yarnInstall(watchPath);
8989
}
9090

91-
cp.execSync('git config pull.rebase merges');
91+
try {
92+
cp.execSync('git config pull.rebase merges');
93+
} catch (e) {
94+
console.error(e)
95+
}

scripts/setup-google-adc.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# #### Instructions to fill the GCP_ADC_FILE env var
3+
# 1. `gcloud auth login <gcp-email>` and authenticate
4+
# 2. `gcloud auth application-default login` and authenticate
5+
# 3. `cat ~/.config/gcloud/application_default_credentials.json` and copy the output
6+
# 4. Go to https://gitpod.io/settings/ and create:
7+
# - name: GCP_ADC_FILE
8+
# - value: paste-the-output
9+
# - repo: gitpod-io/vscode
10+
11+
GCLOUD_ADC_PATH="/home/gitpod/.config/gcloud/application_default_credentials.json"
12+
13+
if [ ! -f "$GCLOUD_ADC_PATH" ]; then
14+
if [ -z "$GCP_ADC_FILE" ]; then
15+
echo "GCP_ADC_FILE not set, doing nothing."
16+
return;
17+
fi
18+
echo "$GCP_ADC_FILE" > "$GCLOUD_ADC_PATH"
19+
echo "Set GOOGLE_APPLICATION_CREDENTIALS value based on contents from GCP_ADC_FILE"
20+
fi
21+
export GOOGLE_APPLICATION_CREDENTIALS="$GCLOUD_ADC_PATH"
22+

0 commit comments

Comments
 (0)