This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add github actions * fix arm builds * move dockerfile * fix: file is not executable * feat: change target repo to dashpay * fix: match travis python versions to GH action
- Loading branch information
Showing
4 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Release to Docker Hub | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
python-version: [3.8, 3.9] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
mkdir ~/.dashcore | ||
cp share/dash.conf.example ~/.dashcore/dash.conf | ||
- name: Run tests | ||
run: | | ||
py.test -svv test/unit/ | ||
find ./lib ./test ./bin -name \*.py -exec pycodestyle --show-source --ignore=E501,E402,E722,E129,W503,W504 {} + | ||
release: | ||
name: Release to Docker Hub | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Docker meta | ||
id: docker_meta | ||
uses: crazy-max/ghaction-docker-meta@v1 | ||
with: | ||
images: dashpay/sentinel | ||
tag-semver: | | ||
{{version}} | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
labels: ${{ steps.docker_meta.outputs.labels }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
|
||
- # Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ python: | |
- "2.7" | ||
- "3.5" | ||
- "3.6" | ||
- "3.8" | ||
- "3.9" | ||
|
||
install: | ||
- pip install -r requirements.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM python:3.9-slim-buster | ||
LABEL maintainer="Dash Developers <[email protected]>" | ||
LABEL description="Dockerised Sentinel" | ||
|
||
COPY . /sentinel | ||
|
||
RUN cd /sentinel && \ | ||
rm sentinel.conf && \ | ||
pip install -r requirements.txt | ||
|
||
ENV HOME /sentinel | ||
WORKDIR /sentinel | ||
|
||
ADD share/run.sh / | ||
|
||
CMD /run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bash | ||
|
||
# SIGTERM-handler | ||
term_handler() { | ||
exit 0 | ||
} | ||
trap term_handler SIGTERM | ||
|
||
if [ ! -f /sentinel/dash.conf ]; then | ||
if [ -z "$RPCUSER" -o -z "$RPCPASSWORD" -o -z "$RPCPORT" ]; then | ||
echo "When no /sentinel/dash.conf is present, you must at least set RPCUSER, RPCPORT and RPCPASSWORD environment variables" | ||
exit 1 | ||
fi | ||
|
||
echo "" > /sentinel/dash.conf | ||
if [ -n "$RPCUSER" ]; then | ||
echo "rpcuser=${RPCUSER}" >> /sentinel/dash.conf | ||
fi | ||
if [ -n "$RPCPASSWORD" ]; then | ||
echo "rpcpassword=${RPCPASSWORD}" >> /sentinel/dash.conf | ||
fi | ||
if [ -n "$RPCPORT" ]; then | ||
echo "rpcport=${RPCPORT}" >> /sentinel/dash.conf | ||
fi | ||
fi | ||
|
||
if [ ! -f /sentinel/sentinel.conf ]; then | ||
if [ -z "$RPCHOST" ]; then | ||
echo "When no /sentinel/sentinal.conf is present, you must at least set the RPCHOST environment variable" | ||
exit 1 | ||
fi | ||
|
||
echo "dash_conf=/sentinel/dash.conf" > /sentinel/sentinel.conf | ||
if [ -n "$RPCHOST" ]; then | ||
echo "rpchost=${RPCHOST}" >> /sentinel/sentinel.conf | ||
fi | ||
if [ -n "$NETWORK" ]; then | ||
echo "network=${NETWORK}" >> /sentinel/sentinel.conf | ||
fi | ||
|
||
# If these variables are not present, we let sentinel handle default values (which will use sqlite) | ||
if [ -n "$DB_HOST" ]; then | ||
echo "db_host=${DB_HOST}" >> /sentinel/sentinel.conf | ||
fi | ||
if [ -n "$DB_PORT" ]; then | ||
echo "db_port=${DB_PORT}" >> /sentinel/sentinel.conf | ||
fi | ||
if [ -n "$DB_NAME" ]; then | ||
echo "db_name=${DB_NAME}" >> /sentinel/sentinel.conf | ||
fi | ||
if [ -n "$DB_USER" ]; then | ||
echo "db_user=${DB_USER}" >> /sentinel/sentinel.conf | ||
fi | ||
if [ -n "$DB_PASSWORD" ]; then | ||
echo "db_password=${DB_PASSWORD}" >> /sentinel/sentinel.conf | ||
fi | ||
if [ -n "$DB_CHARSET" ]; then | ||
echo "db_charset=${DB_CHARSET}" >> /sentinel/sentinel.conf | ||
fi | ||
if [ -n "$DB_DRIVER" ]; then | ||
echo "db_driver=${DB_DRIVER}" >> /sentinel/sentinel.conf | ||
fi | ||
fi | ||
|
||
while true; do | ||
python ./bin/sentinel.py | ||
sleep 1m | ||
done |