Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ RUN cargo install cargo-chef --version 0.1.45

FROM cargo-chef AS cargo-chef-plan

WORKDIR /app

COPY . .
RUN cargo chef prepare --recipe-path recipe.json
RUN cargo chef prepare --recipe-path /recipe.json \
&& cd .. \
&& rm -rf /app

FROM cargo-chef AS graph-node-build

Expand All @@ -37,7 +41,7 @@ ARG REPO_NAME=unknown
ARG BRANCH_NAME=unknown
ARG TAG_NAME=unknown

COPY --from=cargo-chef-plan /app/recipe.json cargo-chef-recipe.json
COPY --from=cargo-chef-plan /recipe.json cargo-chef-recipe.json

RUN apt-get update \
&& apt-get install -y cmake
Expand Down
66 changes: 37 additions & 29 deletions docker/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,43 @@ options:
machineType: "N1_HIGHCPU_32"
timeout: 1800s
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--target', 'graph-node-build',
'--build-arg', 'COMMIT_SHA=$COMMIT_SHA',
'--build-arg', 'REPO_NAME=$REPO_NAME',
'--build-arg', 'BRANCH_NAME=$BRANCH_NAME',
'--build-arg', 'TAG_NAME=$TAG_NAME',
'-t', 'gcr.io/$PROJECT_ID/graph-node-build:$SHORT_SHA',
'-f', 'docker/Dockerfile', '.']
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--target', 'graph-node',
'--build-arg', 'COMMIT_SHA=$COMMIT_SHA',
'--build-arg', 'REPO_NAME=$REPO_NAME',
'--build-arg', 'BRANCH_NAME=$BRANCH_NAME',
'--build-arg', 'TAG_NAME=$TAG_NAME',
'-t', 'gcr.io/$PROJECT_ID/graph-node:$SHORT_SHA',
'-f', 'docker/Dockerfile', '.']
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--target', 'graph-node-debug',
'--build-arg', 'COMMIT_SHA=$COMMIT_SHA',
'--build-arg', 'REPO_NAME=$REPO_NAME',
'--build-arg', 'BRANCH_NAME=$BRANCH_NAME',
'--build-arg', 'TAG_NAME=$TAG_NAME',
'-t', 'gcr.io/$PROJECT_ID/graph-node-debug:$SHORT_SHA',
'-f', 'docker/Dockerfile', '.']
- name: 'gcr.io/cloud-builders/docker'
args: ['tag',
'gcr.io/$PROJECT_ID/graph-node:$SHORT_SHA',
'lutter/graph-node:$SHORT_SHA']
- name: 'gcr.io/kaniko-project/executor:latest'
args: [
'--build-arg', 'COMMIT_SHA=$COMMIT_SHA',
'--build-arg', 'REPO_NAME=$REPO_NAME',
'--build-arg', 'BRANCH_NAME=$BRANCH_NAME',
'--build-arg', 'TAG_NAME=$TAG_NAME',
'--cache=true',
'--cache-ttl=96h',
'--cache-run-layers=true',
'--cache-repo=gcr.io/$PROJECT_ID/graph-node/cache',
'--skip-unused-stages',
'--snapshot-mode=redo',
'--target=graph-node',
'--destination=gcr.io/$PROJECT_ID/graph-node:$SHORT_SHA',
'--dockerfile=docker/Dockerfile',
]
- name: 'gcr.io/kaniko-project/executor:latest'
args: [
'--build-arg', 'COMMIT_SHA=$COMMIT_SHA',
'--build-arg', 'REPO_NAME=$REPO_NAME',
'--build-arg', 'BRANCH_NAME=$BRANCH_NAME',
'--build-arg', 'TAG_NAME=$TAG_NAME',
'--cache=true',
'--cache-ttl=96h',
'--cache-run-layers=true',
# Cache is shared between `graph-node` and `graph-node-debug`, because the
# build stages are identical.
'--cache-repo=gcr.io/$PROJECT_ID/graph-node/cache',
'--snapshot-mode=redo',
'--target=graph-node-debug',
'--destination=gcr.io/$PROJECT_ID/graph-node-debug:$SHORT_SHA',
'--dockerfile=docker/Dockerfile',
]
#- name: 'gcr.io/cloud-builders/docker'
# args: ['tag',
# 'gcr.io/$PROJECT_ID/graph-node:$SHORT_SHA',
# 'lutter/graph-node:$SHORT_SHA']
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['docker/tag.sh']
Expand All @@ -41,7 +50,6 @@ steps:
- 'DOCKER_HUB_USER=$_DOCKER_HUB_USER'
- 'BRANCH_NAME=$BRANCH_NAME'
images:
- 'gcr.io/$PROJECT_ID/graph-node-build:$SHORT_SHA'
- 'gcr.io/$PROJECT_ID/graph-node:$SHORT_SHA'
- 'gcr.io/$PROJECT_ID/graph-node-debug:$SHORT_SHA'
substitutions:
Expand Down
2 changes: 2 additions & 0 deletions docker/tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

tag_and_push() {
tag=$1
docker pull gcr.io/$PROJECT_ID/graph-node:$SHORT_SHA
docker tag gcr.io/$PROJECT_ID/graph-node:$SHORT_SHA \
graphprotocol/graph-node:$tag
docker push graphprotocol/graph-node:$tag

docker pull gcr.io/$PROJECT_ID/graph-node-debug:$SHORT_SHA
docker tag gcr.io/$PROJECT_ID/graph-node-debug:$SHORT_SHA \
graphprotocol/graph-node-debug:$tag
docker push graphprotocol/graph-node-debug:$tag
Expand Down