Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor: Simplify images, upload multi-arch images, pipeline updates #59

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 133 additions & 37 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,155 @@
name: "ethereum-writer-deployer"

on:
push:
branches:
- '**'
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened
- edited
- labeled
release:
types: [ published ]

jobs:
build-and-test:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Print tooling versions
run: |
node --version
npm --version
docker --version
python --version
- name: Run npm ci
run: npm ci
- run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
path: ./dist

test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build
path: ./dist
- run: npm install --no-save tap-xunit
- run: mkdir -p _out/unit _out/e2e
- run: npm test -- --timeout=1m

create-version-file:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v3
- name: Determine next version
id: getVersion
uses: Luke-Rogerson/pr-bump-version@v1
- name: Write version to file
run: |
echo "Outputted version is ${{ steps.getVersion.outputs.version }}"
echo ${{ steps.getVersion.outputs.version }} > .version
- name: Upload .version file as artifact
uses: actions/upload-artifact@v3
with:
node-version: 16
- name: setup-docker
uses: docker-practice/actions-setup-docker@master
- run: node --version
- run: npm --version
- run: docker --version
- run: python --version
- run: env
- name: Run npm install
run: npm install
- run: npm install --no-save tap-xunit
- run: mkdir -p _out/unit _out/e2e
- run: npm test -- --timeout=1m
- run: npm run build

build-and-release-to-staging:
name: version
path: .version


release-to-staging:
needs:
- build
- test
- create-version-file
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Setup Docker
uses: docker-practice/actions-setup-docker@master

- name: Download build artifact
uses: actions/download-artifact@v3
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v3
name: build
path: ./dist

- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: version
path: ./

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
node-version: 16
- name: setup-docker
username: ${{ secrets.DOCKER_HUB_STAGING_LOGIN }}
password: ${{ secrets.DOCKER_HUB_STAGING_PASSWORD }}

- name: Build and push image
run: |
echo "Tagging image with $(cat .version)"
docker buildx build --platform linux/amd64,linux/arm64 -t orbsnetworkstaging/ethereum-writer:$(cat .version) --push .


release-to-staging-immediate:
if: github.event_name == 'pull_request' && github.event.label.name == 'immediate'
needs:
- build
- test
- create-version-file
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Setup Docker
uses: docker-practice/actions-setup-docker@master
- run: ./boyar/create-version-file.sh
- name: Run npm install
run: npm install
- run: ./boyar/docker-build.sh
- name: release-to-docker-hub-staging
env:
DOCKER_HUB_IMAGE_PATH: orbsnetworkstaging/ethereum-writer
DOCKER_HUB_LOGIN: ${{ secrets.DOCKER_HUB_STAGING_LOGIN }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_STAGING_PASSWORD }}
run: ./.github/release-to-staging.sh

- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build
path: ./dist

- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: version
path: ./

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_STAGING_LOGIN }}
password: ${{ secrets.DOCKER_HUB_STAGING_PASSWORD }}

- name: Build and push image

run: |
IMMEDIATE_VERSION=$(awk -F'-' '{print $1"-immediate"}' .version)
echo "Tagging image with $IMMEDIATE_VERSION"
docker buildx build --platform linux/amd64,linux/arm64 -t orbsnetworkstaging/ethereum-writer:$IMMEDIATE_VERSION --push .
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ WORKDIR /opt/orbs
COPY package*.json ./
COPY .version ./version

RUN apk add --no-cache git
# Add daemontools as a requirement from the ethereum-writer Dockerfile
RUN apk add --no-cache git daemontools --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing

# see https://github.com/nodejs/docker-node/issues/282

# --no-cache: download package index on-the-fly, no need to cleanup afterwards
# --virtual: bundle packages, remove whole bundle at once, when done
RUN apk --no-cache --virtual build-dependencies add \
python3 \
make \
g++ \
&& npm install \
&& apk del build-dependencies

RUN npm install
COPY ./healthcheck/healthcheck ./
COPY ./healthcheck/healthcheck.js ./
COPY ./healthcheck/entrypoint.sh /opt/orbs/service

HEALTHCHECK CMD /opt/orbs/healthcheck

COPY dist ./dist

CMD [ "npm", "start" ]
CMD [ "npm", "start" ]
9 changes: 0 additions & 9 deletions boyar/Dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions boyar/docker-build.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"pretest": "npm run typecheck && npm run lint",
"clean": "rimraf ./dist/",
"prebuild": "npm run clean",
"build": "tsc --skipLibCheck -p ./tsconfig.prod.json && ./boyar/create-version-file.sh && docker build -t local/ethereum-writer .",
"build": "tsc --skipLibCheck -p ./tsconfig.prod.json && ./create-version-file.sh && docker build -t local/ethereum-writer .",
"build:quick": "tsc --skipLibCheck -p ./tsconfig.prod.json",
"test": "ava --verbose --serial",
"test:quick": "echo '-- TEST --' && ava --verbose",
Expand Down Expand Up @@ -65,4 +65,4 @@
"web3": "1.2.6",
"yargs": "^15.3.1"
}
}
}