Skip to content

Commit

Permalink
docker action
Browse files Browse the repository at this point in the history
  • Loading branch information
jhunsaker committed Jul 27, 2021
1 parent 91d6eb0 commit 18d0bf6
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Docker

on:
push:
pull_request:
branches: [ main ]

env:
SOLANA_VERSION: 1.6.19

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- run: echo "BRANCH=$( echo ${GITHUB_REF##*/} )" >> $GITHUB_ENV
- run: echo "DOCKER_TAG=${BRANCH}" >> $GITHUB_ENV
- run: echo "DOCKER_IMAGE=$( echo ${GITHUB_REPOSITORY}:${DOCKER_TAG} )" >> $GITHUB_ENV
- run: docker build -f docker/Dockerfile --build-arg SOLANA_VERSION=${{ env.SOLANA_VERSION }} --tag ${{ env.DOCKER_IMAGE }} .
# publish to ghcr.io
- run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- run: docker image tag ${DOCKER_IMAGE} ghcr.io/${DOCKER_IMAGE}
- run: docker image push ghcr.io/${{ env.DOCKER_IMAGE }}
if: startsWith( github.ref, 'refs/tags/' )
# publish to docker.io
- run: echo "${{ secrets.DOCKER_IO_PASS }}" | docker login docker.io -u ${{ secrets.DOCKER_IO_USER }} --password-stdin
- run: docker image tag ${DOCKER_IMAGE} docker.io/pythfoundation/pyth-client:${DOCKER_TAG}
- run: docker image push docker.io/pythfoundation/pyth-client:${DOCKER_TAG}
if: startsWith( github.ref, 'refs/tags/' )
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required( VERSION 3.16 )
cmake_minimum_required( VERSION 3.13 )

# project pyth-client
project( pyth-client )
Expand Down
32 changes: 32 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARG SOLANA_VERSION

FROM solanalabs/solana:v${SOLANA_VERSION}

RUN apt-get update
RUN apt-get install -y cmake curl g++ git libzstd1 libzstd-dev zlib1g zlib1g-dev

RUN useradd -m pyth
USER pyth
WORKDIR /home/pyth

COPY --chown=pyth:pyth ${GITHUB_WORKSPACE} pyth-client/

RUN cd pyth-client && mkdir build && cd build && cmake .. && make && ctest

RUN echo "\nexport PATH=\$PATH:$HOME/pyth-client/build" >> .bashrc

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none

# Link Solana location for makefile
RUN mkdir solana && cp -a /usr/bin/sdk solana

# Build the program
RUN PATH=$PATH:$HOME/.cargo/bin && cd pyth-client/program && make

# Print hash of the program
RUN sha256sum -b pyth-client/target/oracle.so

ENTRYPOINT []
CMD []

0 comments on commit 18d0bf6

Please sign in to comment.