Skip to content

Commit a5c91c8

Browse files
authored
Add deployment for swap beacon (#124)
1 parent a3d8a7f commit a5c91c8

File tree

7 files changed

+180
-24
lines changed

7 files changed

+180
-24
lines changed

.github/workflows/push-rust-services.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ jobs:
4545
tags: |
4646
type=sha,event=branch
4747
type=ref,event=tag
48+
- name: Extract metadata (tags, labels) for Docker
49+
id: meta_swap_beacon
50+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-swap-beacon
53+
tags: |
54+
type=sha,event=branch
55+
type=ref,event=tag
4856
- name: Build and push server docker image
4957
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
5058
with:
@@ -60,3 +68,10 @@ jobs:
6068
push: true
6169
tags: ${{ steps.meta_monitor.outputs.tags }}
6270
labels: ${{ steps.meta_monitor.outputs.labels }}
71+
- name: Build and push swap beacon docker image
72+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
73+
with:
74+
context: ./scripts/swap-beacon
75+
push: true
76+
tags: ${{ steps.meta_swap_beacon.outputs.tags }}
77+
labels: ${{ steps.meta_swap_beacon.outputs.labels }}

scripts/swap-beacon/.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.classpath
8+
**/.dockerignore
9+
**/.env
10+
**/.git
11+
**/.gitignore
12+
**/.project
13+
**/.settings
14+
**/.toolstarget
15+
**/.vs
16+
**/.vscode
17+
**/.next
18+
**/.cache
19+
**/*.*proj.user
20+
**/*.dbmdl
21+
**/*.jfm
22+
**/charts
23+
**/docker-compose*
24+
**/compose*
25+
**/Dockerfile*
26+
**/node_modules
27+
**/npm-debug.log
28+
**/obj
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
**/build
32+
**/dist
33+
LICENSE
34+
README.md

scripts/swap-beacon/Dockerfile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Comments are provided throughout this file to help you get started.
4+
# If you need more help, visit the Dockerfile reference guide at
5+
# https://docs.docker.com/go/dockerfile-reference/
6+
7+
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
8+
9+
ARG NODE_VERSION=18.20.2
10+
11+
################################################################################
12+
# Use node image for base image for all stages.
13+
FROM node:${NODE_VERSION}-alpine as base
14+
15+
# Set working directory for all build stages.
16+
WORKDIR /usr/src/app
17+
18+
19+
################################################################################
20+
# Create a stage for installing production dependecies.
21+
FROM base as deps
22+
23+
# Download dependencies as a separate step to take advantage of Docker's caching.
24+
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
25+
# Leverage bind mounts to package.json and package-lock.json to avoid having to copy them
26+
# into this layer.
27+
RUN --mount=type=bind,source=package.json,target=package.json \
28+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
29+
--mount=type=cache,target=/root/.npm \
30+
npm ci --omit=dev
31+
32+
################################################################################
33+
# Create a stage for building the application.
34+
FROM deps as build
35+
36+
# Download additional development dependencies before building, as some projects require
37+
# "devDependencies" to be installed to build. If you don't need this, remove this step.
38+
RUN --mount=type=bind,source=package.json,target=package.json \
39+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
40+
--mount=type=cache,target=/root/.npm \
41+
npm ci
42+
43+
# Copy the rest of the source files into the image.
44+
COPY . .
45+
# Run the build script.
46+
RUN npm run build
47+
48+
################################################################################
49+
# Create a new stage to run the application with minimal runtime dependencies
50+
# where the necessary files are copied from the build stage.
51+
FROM base as final
52+
53+
# Use production node environment by default.
54+
ENV NODE_ENV production
55+
56+
# Run the application as a non-root user.
57+
USER node
58+
59+
# Copy package.json so that package manager commands can be used.
60+
COPY package.json .
61+
62+
# Copy the production dependencies from the deps stage and also
63+
# the built application from the build stage into the image.
64+
COPY --from=deps /usr/src/app/node_modules ./node_modules
65+
COPY --from=build /usr/src/app/dist ./dist

scripts/swap-beacon/README.Docker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Building and running your application
2+
3+
When you're ready, start your application by running:
4+
`docker compose up --build`.

scripts/swap-beacon/compose.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Comments are provided throughout this file to help you get started.
2+
# If you need more help, visit the Docker Compose reference guide at
3+
# https://docs.docker.com/go/compose-spec-reference/
4+
5+
# Here the instructions define your application as a service called "server".
6+
# This service is built from the Dockerfile in the current directory.
7+
# You can add other services your application may depend on here, such as a
8+
# database or a cache. For examples, see the Awesome Compose repository:
9+
# https://github.com/docker/awesome-compose
10+
services:
11+
server:
12+
build:
13+
context: .
14+
command:
15+
- node
16+
- ./dist/index.js
17+
- "--endpoint"
18+
- "https://pyth-express-relay-mainnet.asymmetric.re/"
19+
- "--chain-ids"
20+
- "mode"
21+
environment:
22+
NODE_ENV: production
23+
# The commented out section below is an example of how to define a PostgreSQL
24+
# database that your application can use. `depends_on` tells Docker Compose to
25+
# start the database before your application. The `db-data` volume persists the
26+
# database data between container restarts. The `db-password` secret is used
27+
# to set the database password. You must create `db/password.txt` and add
28+
# a password of your choosing to it before running `docker-compose up`.
29+
# depends_on:
30+
# db:
31+
# condition: service_healthy
32+
# db:
33+
# image: postgres
34+
# restart: always
35+
# user: postgres
36+
# secrets:
37+
# - db-password
38+
# volumes:
39+
# - db-data:/var/lib/postgresql/data
40+
# environment:
41+
# - POSTGRES_DB=example
42+
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
43+
# expose:
44+
# - 5432
45+
# healthcheck:
46+
# test: [ "CMD", "pg_isready" ]
47+
# interval: 10s
48+
# timeout: 5s
49+
# retries: 5
50+
# volumes:
51+
# db-data:
52+
# secrets:
53+
# db-password:
54+
# file: db/password.txt

scripts/swap-beacon/package-lock.json

Lines changed: 5 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/swap-beacon/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
"devDependencies": {
1515
"@types/node": "^22.0.0",
1616
"@types/yargs": "^17.0.33",
17-
"typescript": "^5.5.4",
18-
"yargs": "^17.7.2"
17+
"typescript": "^5.5.4"
1918
},
2019
"dependencies": {
2120
"@pythnetwork/express-relay-evm-js": "^0.8.1",
2221
"axios": "^1.7.3",
23-
"viem": "^2.18.6"
22+
"viem": "^2.18.6",
23+
"yargs": "^17.7.2"
2424
}
2525
}

0 commit comments

Comments
 (0)