Skip to content

Commit 3cf87ef

Browse files
committed
feat: add docker push action and use docker pull in the setup
1 parent 3538d59 commit 3cf87ef

8 files changed

Lines changed: 58 additions & 7 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build & Push Docker Image from Dispatch
2+
3+
on:
4+
repository_dispatch:
5+
types: [docker-release]
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Log payload
16+
run: echo "Received tag: ${{ github.event.client_payload.tag }}"
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
- name: Log in to Docker Hub
22+
uses: docker/login-action@v3
23+
with:
24+
username: ${{ secrets.DOCKER_USERNAME }}
25+
password: ${{ secrets.DOCKER_PASSWORD }}
26+
27+
- name: Build and push Docker image
28+
run: |
29+
TAG=${{ github.event.client_payload.tag }}
30+
docker build \
31+
-t canopynetwork/canopy:${TAG} \
32+
-t canopynetwork/canopy:latest \
33+
--build-arg BRANCH=${TAG} \
34+
--build-arg BUILD_PATH=cmd/cli \
35+
./docker_image/
36+
docker push canopynetwork/canopy:${TAG}
37+
docker push canopynetwork/canopy:latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ LOCK
229229
MANIFEST
230230
.gz
231231
log
232+
log*.gz
232233
book.json
233234
validator_key.json
234235
keystore.json

docker_image/Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM node:18-alpine AS builder
22

33
ARG WALLET_DIR
44
ARG EXPLORER_DIR
5-
ARG BRANCH='main'
5+
ARG BRANCH='latest'
66
ARG CLI_DIR
77
ARG BUILD_PATH=cmd/cli
88
ARG GO_BIN_DIR
@@ -12,8 +12,17 @@ ARG BIN_PATH=/bin/cli
1212
# downloads git and clones selected version
1313
RUN apk add --no-cache git ca-certificates alpine-sdk
1414
WORKDIR /go/src/github.com/canopy-network/canopy
15-
RUN echo "Building ${BRANCH} version"
16-
RUN echo "Cloning" && git clone -b ${BRANCH} https://github.com/canopy-network/canopy.git .
15+
RUN echo "Building from BRANCH=${BRANCH}" && \
16+
if [ "$BRANCH" = "latest" ]; then \
17+
echo "Fetching latest tag..."; \
18+
git clone https://github.com/canopy-network/canopy.git . && \
19+
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) && \
20+
echo "Checking out tag $LATEST_TAG" && \
21+
git checkout $LATEST_TAG; \
22+
else \
23+
echo "Cloning branch $BRANCH" && \
24+
git clone -b "$BRANCH" https://github.com/canopy-network/canopy.git .; \
25+
fi
1726
# copy golang
1827
COPY --from=golang:1.23.9-alpine /usr/local/go/ /usr/local/go/
1928
ENV PATH="/usr/local/go/bin:${PATH}"

monitoring-stack/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ endif
66

77
build:
88
docker compose build
9+
pull:
10+
docker pull canopynetwork/canopy
911
up:
1012
docker compose down
1113
docker compose up -d

monitoring-stack/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
WALLET_BASE_PATH: '/'
2626
BUILD_PATH: cmd/cli
2727
BIN_PATH: $BIN_PATH
28-
BRANCH: beta-0.1.3
28+
BRANCH: latest
2929
env_file:
3030
- .env
3131
ports:

setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
echo "setting up the validator key"
3-
docker build -t canopy --build-arg 'BRANCH=beta-0.1.3' --build-arg BUILD_PATH=cmd/cli ./docker_image/ && \
4-
docker run --user root -it -p 50000:50000 -p 50001:50001 -p 50002:50002 -p 50003:50003 -p 9001:9001 --name canopy-config --volume ${PWD}/canopy_data/node1/:/root/.canopy/ canopy && \
3+
docker pull canopynetwork/canopy:latest && \
4+
docker run --user root -it -p 50000:50000 -p 50001:50001 -p 50002:50002 -p 50003:50003 -p 9001:9001 --name canopy-config --volume ${PWD}/canopy_data/node1/:/root/.canopy/ canopynetwork/canopy:latest && \
55
docker stop canopy-config && docker rm canopy-config && \
66
cp canopy_data/node1/validator_key.json canopy_data/node2/ && \
77
cp canopy_data/node1/keystore.json canopy_data/node2/

simple-stack/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ endif
66

77
build:
88
docker compose build
9+
pull:
10+
docker pull canopynetwork/canopy
911
up:
1012
docker compose down
1113
docker compose up -d

simple-stack/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
WALLET_BASE_PATH: '/'
1313
BUILD_PATH: cmd/cli
1414
BIN_PATH: $BIN_PATH
15-
BRANCH: beta-0.1.3
15+
BRANCH: latest
1616
env_file:
1717
- .env
1818
ports:

0 commit comments

Comments
 (0)