Skip to content

Commit

Permalink
Test docker build on arm64 (#618)
Browse files Browse the repository at this point in the history
* Test if docker will build for every PR

* We didn't need this new action, docker-publish already had this target

* Nicer label?

* Fix more labels

* intall docker maybe!

* Hopeful fix

* Do we need this?

* Roll the dice!

* Giving up on macOs build

* Run Node 22 ?

* Remove remove-peer-dependencies

* Guessing here

* Newer python doesn't ship with setuptools, which breaks our build

* We need pip as well :'(

* Does alpine have this package

* Grasping at straws. Copying what @usrrname was doign

* Try node 20 again

* Node-gyp install?

* More comments

* Can we add libsodium via apk?

* Update changelog

* Seems like readFile from fs/promises struggles with large files.

* Remove some (now) unneeded dependencies

* Revert "Seems like readFile from fs/promises struggles with large files."

This reverts commit 8c3ca43.

* Better?

* We might not need any of the binary packages anymore. Lets see!
  • Loading branch information
evert authored Feb 10, 2025
1 parent 164f823 commit af77cc3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@ jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest

name: Testing Docker Build for ${{matrix.os}}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]

steps:
- uses: actions/checkout@v4

- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
- name: docker build
run: docker build . --file Dockerfile

# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
Expand Down
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
FROM node:20-alpine as build-stage
WORKDIR /opt/app

# Needed for building @vscode/sqlite3 package
RUN apk add python3 make gcc musl-dev g++

COPY package.json package.json Makefile tsconfig.json ./
COPY assets assets
COPY templates templates
COPY schemas schemas
COPY src src

# --legacy-peer-deps should be removed when all dependencies are marked as stable
RUN npm i --legacy-peer-deps --environment=dev && npx tsc && npm prune --production && rm -r src/
RUN npm i --environment=dev && npx tsc && npm prune --production && rm -r src/

# Stage 2: run!
FROM node:20-alpine
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changelog
* Removed outdated `eff-diceware-passphrase` dependency. It was breaking the
build on arm64 due to old transitive dependencies. We've instead included the
EFF wordlist and generate diceware passwords ourselves.
* Docker image could not be built on arm64 due to a transative dependency using
an old version of libsodium.


0.29.0 (2025-02-07)
Expand Down
12 changes: 10 additions & 2 deletions src/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ export function uuidUrn() {


const wordList:string[] = [];
export async function loadWordList() {

/**
* Load the EFF large word list.
*
* This function has a quiet parameter, so the console statement won't run.
*
* The reason is that it seems to break node --test.
*/
export async function loadWordList(quiet = false) {
if (wordList.length === 0) {
const __dirname = dirname(fileURLToPath(import.meta.url));
console.info('🎲 Loading EFF large word list');
if (!quiet) console.info('🎲 Loading EFF large word list');
const result = await readFile(join(__dirname, '../assets/eff_large_wordlist.txt'), 'utf8');
for(const line of result.split('\n')) {
wordList.push(line.split('\t')[1]);
Expand Down
2 changes: 1 addition & 1 deletion test/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Crypto utilities', () => {

it('should generate a password', async () => {

await loadWordList();
await loadWordList(true);
const password = generatePassword();
assert.match(password, /^[a-z-]{20,}$/);
assert.equal(password.split('-').length, 6);
Expand Down

0 comments on commit af77cc3

Please sign in to comment.