Skip to content

Commit

Permalink
Configure Kaniko to cache build deps
Browse files Browse the repository at this point in the history
  • Loading branch information
gino-m committed May 25, 2020
1 parent 94907a7 commit e5db423
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 51 deletions.
19 changes: 14 additions & 5 deletions cloud-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@

FROM node:latest

# Download nad install Chrome. We don't actually use Chrome directly, but
# this is the easiest way to ensure all of its latest dependencies are
# installed.
# Download and install Chrome. We don't actually use Chrome directly, but
# Puppeteers needs several libraries that Chrome depends on, and this is the
# easiest way to ensure all of its latest dependencies are installed.
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& apt-get update \
&& apt -y install ./google-chrome-stable_current_amd64.deb \
&& rm google-chrome-stable_current_amd64.deb \
&& rm -rf /var/lib/apt/lists/* \
&& npm install node-pre-gyp -g
&& rm -rf /var/lib/apt/lists/*

# Pre-install deps required to build and test Ground Firestore Cloud Functions.
WORKDIR /workspace/functions
COPY functions/package*.json ./
RUN npm install

# Pre-install deps required to build and test the Ground web console.
WORKDIR /workspace/web-ng
COPY web-ng/package*.json ./
RUN npm install
71 changes: 25 additions & 46 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Initialize gcloud via CLI
# $ gcloud init
#
# Steps (1, 2, 3, and 4 run simultaneously):
# ==========================================
# 1. Install npm packages for functions
# 2. Install npm packages for web-ng
# |
# |
# 3. Run lint checks
# 4. Run unit tests
# This build is run automatically on pushes and pull requests.

steps:
# The first time the Docker image is created, the total build time can exceed
# the 10 min default. Increase the max. build time to 16 min to prevent timeouts.
timeout: 900s

# Install node packages for functions
- name: 'gcr.io/ground-android-gcb/node-chrome'
id: 'Install npm packages for functions'
waitFor: ['-']
entrypoint: 'bash'
args:
- '-c'
- |
cd functions && npm install
# Install node packages for web-ng
- name: 'gcr.io/ground-android-gcb/node-chrome'
id: &install_web_ng 'Install npm packages for web-ng'
waitFor: ['-']
entrypoint: 'bash'
# Build Docker image and run checks and tests. See name property of each step
# for description.
steps:
- name: "gcr.io/kaniko-project/executor:v0.22.0"
id: "Rebuild Docker image with deps as needed"
args:
- '-c'
- |
cd web-ng && npm install
- --destination=gcr.io/$PROJECT_ID/ground-platform-build
- --dockerfile=cloud-build/Dockerfile
- --cache=true
- -v=debug

# Run eslint for web-ng
- name: 'gcr.io/ground-android-gcb/node-chrome'
id: 'Run lint checks for web-ng'
waitFor: [*install_web_ng]
entrypoint: 'bash'
- name: "gcr.io/$PROJECT_ID/ground-platform-build"
id: "Run lint checks for web-ng"
entrypoint: "bash"
args:
- '-c'
- |
cd web-ng && npm run check
- "-c"
- |
cd web-ng && npm run check
# Run tests for web-ng
- name: 'gcr.io/ground-android-gcb/node-chrome'
id: 'Run tests for web-ng'
waitFor: [*install_web_ng]
entrypoint: 'bash'
- name: "gcr.io/$PROJECT_ID/ground-platform-build"
id: "Run tests for web-ng"
entrypoint: "bash"
args:
- '-c'
- |
cd web-ng && npm run test
- "-c"
- |
cd web-ng && npm run test

0 comments on commit e5db423

Please sign in to comment.