Skip to content

Commit f845add

Browse files
authored
Merge pull request #1686 from cprussin/fix-xc-admin-frontend-docker-build
chore(docker): fix & rewrite Node Dockerfiles
2 parents 2c39401 + fe0e96f commit f845add

File tree

19 files changed

+354
-166
lines changed

19 files changed

+354
-166
lines changed

.github/workflows/push-price-pusher-image.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ jobs:
3939
- uses: aws-actions/amazon-ecr-login@v1
4040
id: ecr_login
4141
- run: |
42-
DOCKER_BUILDKIT=1 docker build -t lerna -f Dockerfile.lerna .
43-
DOCKER_BUILDKIT=1 docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f apps/price_pusher/Dockerfile .
42+
DOCKER_BUILDKIT=1 docker build --build-arg package="@pythnetwork/price-pusher" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile.node .
4443
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
4544
env:
4645
ECR_REGISTRY: public.ecr.aws

.github/workflows/push-xc-admin-frontend-image.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
password: ${{ secrets.GITHUB_TOKEN }}
2929
- name: Build docker image
3030
run: |
31-
DOCKER_BUILDKIT=1 docker build -t lerna -f Dockerfile.lerna .
31+
DOCKER_BUILDKIT=1 docker build -t builder-base --target builder-base -f Dockerfile.node .
32+
DOCKER_BUILDKIT=1 docker build -t runner-base --target runner-base -f Dockerfile.node .
3233
DOCKER_BUILDKIT=1 docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
3334
--build-arg NEXT_PUBLIC_RPC_POOL_TOKEN=${{ secrets.NEXT_PUBLIC_RPC_POOL_TOKEN }} \
3435
-f governance/xc_admin/packages/xc_admin_frontend/Dockerfile .

.github/workflows/push-xc-admin-image.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build and Push Cross Chain Admin
2+
on:
3+
push:
4+
tags:
5+
- xc-admin-v*
6+
permissions:
7+
contents: read
8+
id-token: write
9+
packages: write
10+
env:
11+
REGISTRY: ghcr.io
12+
jobs:
13+
xc-admin-image:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set image tag to version of the git tag
18+
if: ${{ startsWith(github.ref, 'refs/tags/xc-admin-v') }}
19+
run: |
20+
PREFIX="refs/tags/xc-admin-"
21+
VERSION="${GITHUB_REF:${#PREFIX}}"
22+
echo "IMAGE_TAG=${VERSION}" >> "${GITHUB_ENV}"
23+
- name: Log in to the Container registry
24+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
- name: Build docker image
30+
run: |
31+
DOCKER_BUILDKIT=1 docker build --build-arg package="@pythnetwork/xc-admin-crank-executor" -t ${{ env.REGISTRY }}/pyth-network/xc-admin-crank-executor:${{ env.IMAGE_TAG }} -f Dockerfile.node .
32+
DOCKER_BUILDKIT=1 docker build --build-arg package="@pythnetwork/xc-admin-crank-pythnet-relayer" -t ${{ env.REGISTRY }}/pyth-network/xc-admin-crank-pythnet-relayer:${{ env.IMAGE_TAG }} -f Dockerfile.node .
33+
DOCKER_BUILDKIT=1 docker build --build-arg package="@pythnetwork/xc-admin-proposer-server" -t ${{ env.REGISTRY }}/pyth-network/xc-admin-proposer-server:${{ env.IMAGE_TAG }} -f Dockerfile.node .
34+
- name: Push docker image
35+
run: |
36+
docker push ${{ env.REGISTRY }}/pyth-network/xc-admin-crank-executor:${{ env.IMAGE_TAG }}
37+
docker push ${{ env.REGISTRY }}/pyth-network/xc-admin-crank-pythnet-relayer:${{ env.IMAGE_TAG }}
38+
docker push ${{ env.REGISTRY }}/pyth-network/xc-admin-proposer-server:${{ env.IMAGE_TAG }}

Dockerfile.lerna

Lines changed: 0 additions & 38 deletions
This file was deleted.

Dockerfile.node

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM node:18.20-slim@sha256:1da7652745e9ba5de396e436aa086588ea50d532540fa3147fbc1957c43a46ab as builder-base
2+
WORKDIR /usr/src/pyth
3+
ENV PNPM_HOME="/pnpm"
4+
ENV PATH="$PNPM_HOME:$PATH"
5+
RUN apt-get update && apt-get install -y git python3 make gcc g++ && corepack enable
6+
COPY ./ .
7+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
8+
9+
10+
FROM node:18.20-alpine@sha256:6937be95129321422103452e2883021cc4a96b63c32d7947187fcb25df84fc3f as runner-base
11+
WORKDIR /srv
12+
ENV NODE_ENV production
13+
RUN addgroup --system --gid 1001 pyth && adduser --system --uid 1001 pyth -g pyth && chown pyth:pyth .
14+
USER pyth
15+
16+
17+
FROM builder-base AS builder
18+
ARG package
19+
RUN pnpm exec lerna run build --scope="$package" --include-dependencies
20+
RUN pnpm deploy --filter $package --prod /srv/$package
21+
22+
23+
FROM runner-base AS runner
24+
ARG package
25+
COPY --from=builder --chown=pyth:pyth /srv/${package} ./
26+
CMD [ "npm", "start" ]

apps/price_pusher/Dockerfile

Lines changed: 0 additions & 22 deletions
This file was deleted.

apps/price_pusher/docker-compose.beta.sample.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
services:
22
price-pusher:
3-
# Use this to build the price pusher from source. A dependency of the pusher docker
4-
# image is the pyth-crosschain monorepo lerna docker image. Build lerna image
5-
# using the following command from the repo root:
6-
# `docker buildx build -f Dockerfile.lerna -t lerna .`
3+
# Use this to build the price pusher from source.
74
#
85
# Please note that the docker build from source only works in x86_64 platforms
96
# and doesn't work on arm platforms (like Apple M1/M2).
107
#
118
# build:
12-
# context: .
9+
# context: ../..
10+
# dockerfile: Dockerfile.node
11+
# args:
12+
# package: "@pythnetwork/price-pusher"
1313

1414
# Replace <version> with the latest released image of the price pusher from here:
1515
# https://gallery.ecr.aws/pyth-network/xc-price-pusher

apps/price_pusher/docker-compose.stable.sample.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
services:
22
price-pusher:
3-
# Use this to build the price pusher from source. A dependency of the pusher docker
4-
# image is the pyth-crosschain monorepo lerna docker image. Build lerna image
5-
# using the following command from the repo root:
6-
# `docker buildx build -f Dockerfile.lerna -t lerna .`
3+
# Use this to build the price pusher from source.
74
#
85
# Please note that the docker build from source only works in x86_64 platforms
96
# and doesn't work on arm platforms (like Apple M1/M2).
107
#
118
# build:
12-
# context: .
9+
# context: ../..
10+
# dockerfile: Dockerfile.node
11+
# args:
12+
# package: "@pythnetwork/price-pusher"
1313

1414
# Replace <version> with the latest released image of the price pusher from here:
1515
# https://gallery.ecr.aws/pyth-network/xc-price-pusher

governance/xc_admin/Dockerfile

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)