fix: minor fixes to wasm and price dockerfiles (#197)

CU-2frzq03

Co-authored-by: Eran Davidovich <edavidovich@jumptrading.com>
This commit is contained in:
Eran Davidovich 2022-05-03 12:41:36 +02:00 committed by GitHub
parent e13b146dfd
commit 5be5576f0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 30 deletions

View File

@ -1,14 +1,15 @@
# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
FROM docker.io/library/rust:1.49@sha256:a50165ea96983c21832578afb1c8c028674c965bc1ed43b607871b1f362e06a5 AS build
RUN apt-get update && apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang
RUN rustup component add rustfmt
RUN rustup default nightly-2022-01-02
RUN apt-get update && \
apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN rustup component add rustfmt && \
rustup default nightly-2022-01-02
WORKDIR /usr/src/bridge
RUN cargo install wasm-pack --vers 0.9.1
ENV RUST_LOG="solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=trace,solana_bpf_loader=debug,solana_rbpf=debug"
ENV EMITTER_ADDRESS="11111111111111111111111111111115"
ENV BRIDGE_ADDRESS="Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
@ -25,21 +26,10 @@ ARG SED_REMOVE_INVALID_REFERENCE="/^\s*wasm.__wbg_systeminstruction_free(ptr);$/
# TODO: it appears that wasm-pack ignores our lockfiles even with --locked
# Run unit tests
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=third_party/pyth/p2w-sdk/rust/target \
cd third_party/pyth/p2w-sdk/rust \
&& cargo test --locked
# Compile pyth2wormhole
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=third_party/pyth/p2w-sdk/rust/target \
cd third_party/pyth/p2w-sdk/rust \
&& /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=third_party/pyth/p2w-sdk/rust/target \
cd third_party/pyth/p2w-sdk/rust \
&& /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
WORKDIR /usr/src/bridge/third_party/pyth/p2w-sdk/rust
RUN cargo test --locked && \
/usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
/usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
FROM scratch AS export

View File

@ -1,25 +1,18 @@
FROM node:16-alpine@sha256:72a490e7ed8aed68e16b8dc8f37b5bcc35c5b5c56ee3256effcdee63e2546f93
ARG BASE_PATH=/usr/src/pyth2wormhole
WORKDIR ${BASE_PATH}
RUN addgroup -S pyth -g 10001 && adduser -S pyth -G pyth -u 10001
USER pyth
# Adds p2w-sdk/js dependency
ARG P2W_SDK_REL_PATH=third_party/pyth/p2w-sdk/js
WORKDIR ${BASE_PATH}/${P2W_SDK_REL_PATH}
ADD --chown=pyth:pyth ${P2W_SDK_REL_PATH} .
COPY --chown=pyth:pyth ${P2W_SDK_REL_PATH} .
RUN npm ci && npm run build && npm cache clean --force
ARG PRICE_SERVICE_REL_PATH=third_party/pyth/price-service
WORKDIR ${BASE_PATH}/${PRICE_SERVICE_REL_PATH}
ADD --chown=pyth:pyth ${PRICE_SERVICE_REL_PATH} .
COPY --chown=pyth:pyth ${PRICE_SERVICE_REL_PATH} .
RUN npm ci && npm run build && npm cache clean --force
# If you are building for production