diff --git a/.dockerignore b/.dockerignore index 93f13619..1675f407 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ node_modules +modules npm-debug.log diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c56b3b93..c419d462 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,3 +17,65 @@ jobs: - run: npm run test:lint if: matrix.os != 'windows-latest' - run: npm run test:unit + + docker: + name: Build and test Docker + runs-on: ubuntu-latest + permissions: + contents: read + packages: read + env: + REGISTRY: ghcr.io + + steps: + - uses: actions/checkout@v3 + + - uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: "arm64" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and load Docker image + id: docker_build + uses: docker/build-push-action@v4 + with: + context: . + load: true + tags: core-test + cache-from: type=registry,ref=ghcr.io/filecoin-station/core + cache-to: type=inline + + - name: Build Docker image for other platforms + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/arm64 + cache-from: type=registry,ref=ghcr.io/filecoin-station/core + cache-to: type=inline + + - name: Start Station Core container + run: | + docker run \ + --name station \ + --detach \ + --env FIL_WALLET_ADDRESS=f1abjxfbp274xpdqcpuaykwkfb43omjotacm2p3za \ + $IMAGEID + env: + IMAGEID: ${{ steps.docker_build.outputs.imageid }} + + - name: Print station activity + run: | + sleep 10 # Wait for Station modules to start + docker exec station bin/station.js activity + + - name: Check | Saturn started + run: docker exec station bin/station.js activity | grep "Saturn module started" diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1d653f8b..09d7d68a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,7 +2,6 @@ name: Docker build on: push: tags: ["*"] - branches: ["*"] env: REGISTRY: ghcr.io @@ -35,11 +34,11 @@ jobs: - uses: martinbeentjes/npm-get-version-action@main id: package-version - - name: Build and optionally push Docker image + - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . - push: ${{ startsWith(github.ref, 'refs/tags/v') }} + push: true tags: | ghcr.io/filecoin-station/core ghcr.io/filecoin-station/core:${{ steps.package-version.outputs.current-version }} diff --git a/Dockerfile b/Dockerfile index ff6f1e6a..972075e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,6 @@ FROM node:18-alpine LABEL org.opencontainers.image.source https://github.com/filecoin-station/core USER node WORKDIR /usr/src/app -COPY package*.json ./ -COPY scripts/post-install.js ./scripts/ -RUN npm ci --omit=dev COPY . . +RUN npm ci --omit=dev CMD [ "./bin/station.js" ] diff --git a/bin/station.js b/bin/station.js index f12e701d..08a524ea 100755 --- a/bin/station.js +++ b/bin/station.js @@ -61,7 +61,7 @@ yargs(hideBin(process.argv)) commands.activity ) .command('logs [module]', 'Show module logs', () => {}, commands.logs) - .choices('module', ['saturn-l2-node']) + .choices('module', modules) .version(`${pkg.name}: ${pkg.version}`) .alias('v', 'version') .alias('h', 'help') diff --git a/lib/saturn-node.js b/lib/saturn-node.js index 127e2b82..d9c50621 100644 --- a/lib/saturn-node.js +++ b/lib/saturn-node.js @@ -5,14 +5,14 @@ import { fetch } from 'undici' import * as Sentry from '@sentry/node' import { installBinaryModule, getBinaryModuleExecutable } from './modules.js' -const DIST_TAG = 'v0.5.0' +const DIST_TAG = 'v0.5.1' export async function install () { await installBinaryModule({ - module: 'saturn-l2-node', + module: 'saturn-L2-node', repo: 'filecoin-saturn/L2-node', distTag: DIST_TAG, - executable: 'L2-node', + executable: 'saturn-L2-node', arch: platform() === 'darwin' ? 'x64' : arch(), targets: [ { platform: 'darwin', arch: 'x64', asset: 'L2-node_Darwin_x86_64.zip' }, @@ -36,8 +36,8 @@ async function start ({ const childProcess = execa( getBinaryModuleExecutable({ - module: 'saturn-l2-node', - executable: 'L2-node' + module: 'saturn-L2-node', + executable: 'saturn-L2-node' }), { env: { ROOT_DIR: storagePath, diff --git a/test/metrics.js b/test/metrics.js index 337c620b..e9d990ed 100644 --- a/test/metrics.js +++ b/test/metrics.js @@ -51,12 +51,12 @@ describe('Metrics', () => { { recursive: true } ) await fs.writeFile( - join(getPaths(CACHE_ROOT, STATE_ROOT).metrics, 'saturn-l2-node.log'), + join(getPaths(CACHE_ROOT, STATE_ROOT).metrics, 'saturn-L2-node.log'), '[date] {"totalJobsCompleted":1,"totalEarnings":"2"}\n' ) const { stdout } = await execa( station, - ['metrics', 'saturn-l2-node'], + ['metrics', 'saturn-L2-node'], { env: { CACHE_ROOT, STATE_ROOT } } ) assert.deepStrictEqual(