Skip to content

Commit

Permalink
Simplify generation of standard node images
Browse files Browse the repository at this point in the history
  • Loading branch information
cprussin committed Jun 12, 2024
1 parent 29aa0b9 commit 33ee63f
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 79 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/push-price-pusher-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ jobs:
- uses: aws-actions/amazon-ecr-login@v1
id: ecr_login
- run: |
DOCKER_BUILDKIT=1 docker build -t builder -f Dockerfile.builder .
DOCKER_BUILDKIT=1 docker build -t runner -f Dockerfile.runner .
DOCKER_BUILDKIT=1 docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f apps/price_pusher/Dockerfile .
DOCKER_BUILDKIT=1 docker build --build-arg package="@pythnetwork/price-pusher" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile.node .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
env:
ECR_REGISTRY: public.ecr.aws
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/push-xc-admin-crank-executor-image.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/push-xc-admin-frontend-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
run: |
DOCKER_BUILDKIT=1 docker build -t builder -f Dockerfile.builder .
DOCKER_BUILDKIT=1 docker build -t runner -f Dockerfile.runner .
DOCKER_BUILDKIT=1 docker build -t builder-base --target builder-base -f Dockerfile.node .
DOCKER_BUILDKIT=1 docker build -t runner-base --target runner-base -f Dockerfile.node .
DOCKER_BUILDKIT=1 docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
--build-arg NEXT_PUBLIC_RPC_POOL_TOKEN=${{ secrets.NEXT_PUBLIC_RPC_POOL_TOKEN }} \
-f governance/xc_admin/packages/xc_admin_frontend/Dockerfile .
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/push-xc-admin-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and Push Cross Chain Admin
on:
push:
tags:
- xc-admin-v*
permissions:
contents: read
id-token: write
packages: write
env:
REGISTRY: ghcr.io
jobs:
xc-admin-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set image tag to version of the git tag
if: ${{ startsWith(github.ref, 'refs/tags/xc-admin-v') }}
run: |
PREFIX="refs/tags/xc-admin-"
VERSION="${GITHUB_REF:${#PREFIX}}"
echo "IMAGE_TAG=${VERSION}" >> "${GITHUB_ENV}"
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
run: |
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 .
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 .
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 .
- name: Push docker image
run: |
docker push ${{ env.REGISTRY }}/pyth-network/xc-admin-crank-executor:${{ env.IMAGE_TAG }}
docker push ${{ env.REGISTRY }}/pyth-network/xc-admin-crank-pythnet-relayer:${{ env.IMAGE_TAG }}
docker push ${{ env.REGISTRY }}/pyth-network/xc-admin-proposer-server:${{ env.IMAGE_TAG }}
7 changes: 0 additions & 7 deletions Dockerfile.builder

This file was deleted.

26 changes: 26 additions & 0 deletions Dockerfile.node
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:18.20-slim@sha256:1da7652745e9ba5de396e436aa086588ea50d532540fa3147fbc1957c43a46ab as builder-base
WORKDIR /usr/src/pyth
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apt-get update && apt-get install -y git python3 make gcc g++ && corepack enable
COPY ./ .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile


FROM node:18.20-alpine@sha256:6937be95129321422103452e2883021cc4a96b63c32d7947187fcb25df84fc3f as runner-base
WORKDIR /srv
ENV NODE_ENV production
RUN addgroup --system --gid 1001 pyth && adduser --system --uid 1001 pyth -g pyth && chown pyth:pyth .
USER pyth


FROM builder-base AS builder
ARG package
RUN pnpm exec lerna run build --scope="$package" --include-dependencies
RUN pnpm deploy --filter $package --prod /srv/$package


FROM runner-base AS runner
ARG package
COPY --from=builder --chown=pyth:pyth /srv/${package} ./
CMD [ "npm", "start" ]
5 changes: 0 additions & 5 deletions Dockerfile.runner

This file was deleted.

11 changes: 0 additions & 11 deletions apps/price_pusher/Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions governance/xc_admin/packages/crank_executor/Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions governance/xc_admin/packages/crank_executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"scripts": {
"build": "tsc",
"start": "node lib/index.js",
"format": "prettier --write \"src/**/*.ts\""
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"scripts": {
"build": "tsc",
"start": "node lib/index.js",
"format": "prettier --write \"src/**/*.ts\""
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions governance/xc_admin/packages/proposer_server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"scripts": {
"build": "tsc",
"start": "node lib/index.js",
"format": "prettier --write \"src/**/*.ts\""
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions governance/xc_admin/packages/xc_admin_frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Defined in Dockerfile.builder
FROM builder AS xc-admin-frontend-builder
# Defined in Dockerfile.node
FROM builder-base AS xc-admin-frontend-builder
ARG NEXT_PUBLIC_RPC_POOL_TOKEN
ENV NEXT_TELEMETRY_DISABLED 1
ENV BUILD_STANDALONE true
Expand All @@ -8,8 +8,8 @@ RUN pnpm exec lerna run build --scope="@pythnetwork/xc-admin-frontend" --include


# See https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
# Defined in Dockerfile.runner
FROM runner as xc-admin-frontend
# Defined in Dockerfile.node
FROM runner-base as xc-admin-frontend
COPY --from=xc-admin-frontend-builder --chown=pyth:pyth /usr/src/pyth/governance/xc_admin/packages/xc_admin_frontend/.next/standalone ./
COPY --from=xc-admin-frontend-builder --chown=pyth:pyth /usr/src/pyth/governance/xc_admin/packages/xc_admin_frontend/.next/static ./governance/xc_admin/packages/xc_admin_frontend/.next/static
COPY --from=xc-admin-frontend-builder /usr/src/pyth/governance/xc_admin/packages/xc_admin_frontend/public ./governance/xc_admin/packages/xc_admin_frontend/public
Expand Down

0 comments on commit 33ee63f

Please sign in to comment.