Skip to content

Commit

Permalink
feat(ci): add docker image builds per PR
Browse files Browse the repository at this point in the history
  • Loading branch information
vpavlin committed Aug 9, 2023
1 parent c8446ae commit b78488b
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,58 @@ jobs:
fi
make V=1 LOG_LEVEL=DEBUG QUICK_AND_DIRTY_COMPILER=1 test2 testwakunode2
build-docker-image:
needs: changes
if: ${{ needs.changes.outputs.v2 == 'true' || needs.changes.outputs.common == 'true' }}
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 60

name: docker-build-v2-${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get submodules hash
id: submodules
run: |
echo "hash=$(git submodule status | awk '{print $1}' | sort | shasum -a 256 | sed 's/[ -]*//g')" >> $GITHUB_OUTPUT
- name: Cache submodules
uses: actions/cache@v3
with:
path: |
vendor/
.git/modules
key: ${{ runner.os }}-vendor-modules-${{ steps.submodules.outputs.hash }}

- name: Build binaries
id: build
run: |
make -j${NPROC} V=1 QUICK_AND_DIRTY_COMPILER=1 wakunode2
TAG=$([ "${PR_NUMBER}" == "" ] && echo "master" || echo "${PR_NUMBER}")
IMAGE=quay.io/wakuorg/nwaku-pr:${TAG}
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
docker login -u ${QUAY_USER} -p ${QUAY_PASSWORD} quay.io
docker build -t ${IMAGE} -f docker/binaries/Dockerfile.bn.amd64 --label quay.expires-after=7d .
docker push ${IMAGE}
env:
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
QUAY_USER: ${{ secrets.QUAY_USER }}
PR_NUMBER: ${{ github.event.number }}

- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
You can find the image built from this PR at
```
${{steps.build.outputs.image}}
```
34 changes: 34 additions & 0 deletions docker/binaries/Dockerfile.bn.amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Dockerfile to build a distributable container image from pre-existing binaries
FROM debian:stable-slim as prod

ARG MAKE_TARGET=wakunode2

LABEL maintainer="vaclav@status.im"
LABEL source="https://github.com/waku-org/nwaku"
LABEL description="Waku node reference implementation"
LABEL commit="unknown"

# DevP2P, LibP2P, and JSON RPC ports
EXPOSE 30303 60000 8545

# Referenced in the binary
RUN apt-get update &&\
apt-get install -y libpcre3 libpq-dev &&\
apt-get clean && rm -rf /var/lib/apt/lists/*

# Fix for 'Error loading shared library libpcre.so.3: No such file or directory'
RUN ln -s /usr/lib/libpcre.so /usr/lib/libpcre.so.3

# Copy to separate location to accomodate different MAKE_TARGET values
ADD ./build/$MAKE_TARGET /usr/local/bin/

# Copy migration scripts for DB upgrades
ADD ./migrations/ /app/migrations/

# Symlink the correct wakunode binary
RUN ln -sv /usr/local/bin/$MAKE_TARGET /usr/bin/wakunode

ENTRYPOINT ["/usr/bin/wakunode"]

# By default just show help if called without arguments
CMD ["--help"]

0 comments on commit b78488b

Please sign in to comment.