Skip to content

Commit

Permalink
feat: add multi-platform docker image support (#19)
Browse files Browse the repository at this point in the history
This commit adds support for multi-platform docker images. It includes changes to the CI workflow file to setup QEMU and Docker Buildx, login to Docker Hub, and build and push the docker image for both amd64 and arm64 platforms.

Future improvements
Use node:18-bullseye-slim instead of node:18-bullseye, the image is half the size (compressed). Potential problem: "npm ci" (on arm64 at least) requires node-gyp requires python, so it must be installed first ("half the size" is only without python...).
  • Loading branch information
jtakalai authored May 27, 2024
1 parent fa50b18 commit 7ecfa26
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
push: ${{ github.ref == 'refs/heads/main' }}
tags: streamr/stream-metrics-index:latest
platforms: linux/amd64,linux/arm64
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN npm run build
RUN chmod +x dist/bin/*.js
RUN rm -rf node_modules

FROM node:18-bullseye-slim
FROM node:18-bullseye
USER node
WORKDIR /usr/src/app
COPY --chown=node:node --from=build /usr/src/app/ .
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"private": true,
"scripts": {
"build": "tsc -b tsconfig.build.json",
"docker:build": "docker build --tag streamr/stream-metrics-index:latest .",
"docker:push": "docker buildx build --platform linux/amd64,linux/arm64 --tag streamr/stream-metrics-index:latest --push .",
"test": "jest --runInBand",
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'"
},
Expand Down

0 comments on commit 7ecfa26

Please sign in to comment.