diff --git a/.gitea/workflows/docker-image.yml b/.gitea/workflows/docker-image.yml new file mode 100644 index 0000000..5ebf1fc --- /dev/null +++ b/.gitea/workflows/docker-image.yml @@ -0,0 +1,29 @@ +name: Publish azimuth-watcher docker image on release + +on: + release: + types: [published] + +jobs: + build: + name: Run docker build and publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run docker build + run: docker build -t cerc/watcher-azimuth -f Dockerfile . + - name: Get the version + id: vars + run: | + echo "sha=$(echo ${GITHUB_SHA:0:7})" >> $GITHUB_OUTPUT + echo "tag=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT + - name: Tag docker image with SHA + run: docker tag cerc/watcher-azimuth git.vdb.to/laconicnetwork/cerc/watcher-azimuth:${{steps.vars.outputs.sha}} + - name: Tag docker image with release tag + run: docker tag git.vdb.to/laconicnetwork/cerc/watcher-azimuth:${{steps.vars.outputs.sha}} git.vdb.to/laconicnetwork/cerc/watcher-azimuth:${{steps.vars.outputs.tag}} + - name: Docker Login + run: echo ${{ secrets.CICD_PUBLISH_TOKEN }} | docker login https://git.vdb.to -u laconiccicd --password-stdin + - name: Docker Push SHA + run: docker push git.vdb.to/laconicnetwork/cerc/watcher-azimuth:${{steps.vars.outputs.sha}} + - name: Docker Push TAGGED + run: docker push git.vdb.to/laconicnetwork/cerc/watcher-azimuth:${{steps.vars.outputs.tag}} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ce43612 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM node:18.16.0-alpine3.16 + +RUN apk --update --no-cache add git python3 alpine-sdk jq + +WORKDIR /app + +COPY . . + +# Get the latest Git commit hash and set it in package.json of all watchers +RUN COMMIT_HASH=$(git rev-parse HEAD) && \ + find . -name 'package.json' -exec sh -c ' \ + for packageFile; do \ + jq --arg commitHash "$0" ".commitHash = \$commitHash" "$packageFile" > "$packageFile.tmp" && \ + mv "$packageFile.tmp" "$packageFile"; \ + done \ + ' "$COMMIT_HASH" {} \; + +RUN echo "installing dependencies" && \ + yarn + +RUN echo "Building azimuth-watcher and gateway-server" && \ + yarn build --scope @cerc-io/azimuth-watcher --scope @cerc-io/gateway-server + +RUN echo "Install toml-js to update watcher config files" && \ + yarn add --dev --ignore-workspace-root-check toml-js diff --git a/lerna.json b/lerna.json index d9a660c..4bb78f5 100644 --- a/lerna.json +++ b/lerna.json @@ -3,6 +3,6 @@ "packages/*" ], "useWorkspaces": true, - "version": "0.1.9", + "version": "0.1.10", "npmClient": "yarn" } diff --git a/packages/azimuth-watcher/package.json b/packages/azimuth-watcher/package.json index bb34df7..a665bf6 100644 --- a/packages/azimuth-watcher/package.json +++ b/packages/azimuth-watcher/package.json @@ -1,6 +1,6 @@ { "name": "@cerc-io/azimuth-watcher", - "version": "0.1.9", + "version": "0.1.10", "description": "azimuth-watcher", "private": true, "main": "dist/index.js",