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

mailcatcher/Dockerfile build is failing on initial attempt #458

Closed
5 tasks done
andrewrice opened this issue Feb 6, 2024 · 8 comments · Fixed by #476 or #484
Closed
5 tasks done

mailcatcher/Dockerfile build is failing on initial attempt #458

andrewrice opened this issue Feb 6, 2024 · 8 comments · Fixed by #476 or #484
Milestone

Comments

@andrewrice
Copy link

Describe the bug

Mailcatcher dockerfile build appears to fail due to a dependency error when running pnpm saas up on fresh project. See full logs below.

Steps to reproduce

  1. pnpm create saas-boilerplate .
  2. At prompt, enter project name and skip through other configuration.
  3. pnpm saas up

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 9.76 GB / 31.95 GB
  Binaries:
    Node: 18.19.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.1 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Chromium (121.0.2277.98)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    @apollo/client: ^3.8.8 => 3.8.8
    @apollo/rover: ^0.19.1 => 0.19.1
    @aws-sdk/client-cloudformation: ^3.462.0 => 3.462.0
    @aws-sdk/client-codebuild: ^3.462.0 => 3.462.0
    @aws-sdk/client-ecr: ^3.462.0 => 3.462.0
    @aws-sdk/client-ecs: ^3.462.0 => 3.462.0
    @aws-sdk/client-iam: ^3.462.0 => 3.462.0
    @aws-sdk/client-lambda: ^3.462.0 => 3.462.0
    @aws-sdk/client-s3: ^3.462.0 => 3.462.0
    @aws-sdk/client-ses: ^3.462.0 => 3.462.0
    @aws-sdk/client-sfn: ^3.462.0 => 3.462.0
    @aws-sdk/client-sts: ^3.462.0 => 3.462.0
    @babel/preset-react: ^7.23.3 => 7.23.3
    @graphql-codegen/cli: ^5.0.0 => 5.0.0
    @graphql-typed-document-node/core: ^3.2.0 => 3.2.0
    @iconify-icons/ion: ^1.2.10 => 1.2.10
    @iconify/react: ^4.1.1 => 4.1.1
    @nx/devkit: 17.1.3 => 17.1.3
    @nx/eslint: 17.1.3 => 17.1.3
    @nx/eslint-plugin: 17.1.3 => 17.1.3
    @nx/jest: 17.1.3 => 17.1.3
    @nx/js: 17.1.3 => 17.1.3
    @nx/node: 17.1.3 => 17.1.3
    @nx/plugin: 17.1.3 => 17.1.3
    @nx/react: 17.1.3 => 17.1.3
    @nx/web: 17.1.3 => 17.1.3
    @nx/webpack: 17.1.3 => 17.1.3
    @sb/cli: * => 2.4.1
    @sb/core: * => 2.4.1
    @sentry/react: ^7.84.0 => 7.84.0
    @storybook/addon-actions: ^7.6.1 => 7.6.1
    @storybook/react: ^7.6.1 => 7.6.1
    @supercharge/strings: ^2.0.0 => 2.0.0
    @svgr/webpack: ^8.1.0 => 8.1.0
    @tailwindcss/typography: ^0.5.10 => 0.5.10
    @testing-library/dom: ^9.3.3 => 9.3.3
    @testing-library/jest-dom: ^6.1.4 => 6.1.4
    @testing-library/react: 14.0.0 => 14.0.0
    @testing-library/react-hooks: ^8.0.1 => 8.0.1
    @testing-library/user-event: ^14.5.1 => 14.5.1
    @trivago/prettier-plugin-sort-imports: ^4.3.0 => 4.3.0
    @types/gtag.js: ^0.0.14 => 0.0.14
    @types/jest: ^29.5.10 => 29.5.10
    @types/node: ^18.18.14 => 18.18.14
    @types/ramda: ^0.28.25 => 0.28.25
    @types/react: 18.2.24 => 18.2.24
    @types/react-dom: 18.2.9 => 18.2.9
    @types/react-router: ^5.1.20 => 5.1.20
    @types/react-router-dom: 5.3.3 => 5.3.3
    @types/react-test-renderer: ^18.0.7 => 18.0.7
    @typescript-eslint/eslint-plugin: 6.13.1 => 6.13.1
    @typescript-eslint/parser: 6.13.1 => 6.13.1
    @typescript-eslint/scope-manager: 5.62.0 => 5.62.0
    @vitejs/plugin-react: ^4.2.0 => 4.2.0
    aws-cdk: ^2.111.0 => 2.111.0
    aws-cdk-lib: ^2.111.0 => 2.111.0
    babel-jest: 29.7.0 => 29.7.0
    constructs: ^10.3.0 => 10.3.0
    esbuild: 0.19.8 => 0.19.8
    eslint: ^8.54.0 => 8.54.0
    eslint-config-prettier: 9.0.0 => 9.0.0
    eslint-import-resolver-typescript: ^3.6.1 => 3.6.1
    eslint-plugin-formatjs: ^4.11.3 => 4.11.3
    eslint-plugin-import: 2.28.1 => 2.28.1
    eslint-plugin-jsx-a11y: ^6.8.0 => 6.8.0
    eslint-plugin-react: 7.33.2 => 7.33.2
    eslint-plugin-react-hooks: 4.6.0 => 4.6.0
    eslint-plugin-testing-library: ^6.2.0 => 6.2.0
    graphql: ^16.8.1 => 16.8.1
    husky: ^8.0.3 => 8.0.3
    jest: 29.7.0 => 29.7.0
    jest-environment-jsdom: 29.7.0 => 29.7.0
    jest-matcher-utils: ^29.7.0 => 29.7.0
    jest-watch-typeahead: ^2.2.2 => 2.2.2
    lint-staged: ^14.0.1 => 14.0.1
    nx: 17.1.3 => 17.1.3
    nx-cloud: 16.5.2 => 16.5.2
    plop: ^4.0.0 => 4.0.0
    prettier: ^3.1.0 => 3.1.0
    prettier-plugin-tailwindcss: ^0.5.7 => 0.5.7
    ramda: ^0.28.0 => 0.28.0
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    react-helmet-async: ^1.3.0 => 1.3.0
    react-hook-form: ^7.48.2 => 7.48.2
    react-intl: ^6.5.5 => 6.5.5
    react-loading-skeleton: ^3.3.1 => 3.3.1
    react-markdown: ^8.0.7 => 8.0.7
    react-router: ^6.16.0 => 6.16.0
    react-router-dom: 6.16.0 => 6.16.0
    regenerator-runtime: ^0.14.0 => 0.14.0
    styled-components: 6.0.8 => 6.0.8
    tailwindcss: ^3.3.5 => 3.3.5
    tailwindcss-animate: ^1.0.7 => 1.0.7
    ts-jest: 29.1.1 => 29.1.1
    ts-node: 10.9.1 => 10.9.1
    tsconfig-paths: ^4.2.0 => 4.2.0
    tslib: ^2.6.2 => 2.6.2
    typescript: 5.2.2 => 5.2.2
    vite: ^4.5.0 => 4.5.0
    vite-plugin-eslint: ^1.8.1 => 1.8.1
    vite-plugin-svgr: ^3.3.0 => 3.3.0
    vite-tsconfig-paths: ^4.2.1 => 4.2.1

Logs

Click to expand!
#0 building with "default" instance using docker driver
#1 [mailcatcher internal] load build definition from Dockerfile
#1 transferring dockerfile:
#1 ...
#2 [mailcatcher internal] load .dockerignore
#2 transferring context: 2B 0.0s done
#2 DONE 0.4s
#3 [localwsserver internal] load build definition from Dockerfile
#3 transferring dockerfile: 172B 0.0s done
#3 DONE 0.5s
#1 [mailcatcher internal] load build definition from Dockerfile
#1 transferring dockerfile: 406B 0.2s done
#1 DONE 0.5s
#4 [localwsserver internal] load .dockerignore
#4 transferring context: 52B 0.0s done
#4 DONE 0.5s
#5 [mailcatcher internal] load metadata for docker.io/dockage/alpine:3.15.4
#5 ...
#6 [mailcatcher auth] dockage/alpine:pull token for registry-1.docker.io
#6 DONE 0.0s
#7 [localwsserver auth] library/node:pull token for registry-1.docker.io
#7 DONE 0.0s
#8 [localwsserver internal] load metadata for docker.io/library/node:20-alpine
#8 DONE 2.9s
#5 [mailcatcher internal] load metadata for docker.io/dockage/alpine:3.15.4
#5 ...
#9 [localwsserver 1/5] FROM docker.io/library/node:20-alpine@sha256:2f46fd49c767554c089a5eb219115313b72748d8f62f5eccb58ef52bc36db4ad
#9 DONE 0.0s
#10 [localwsserver internal] load build context
#10 transferring context: 301B 0.1s done
#10 DONE 0.7s
#5 [mailcatcher internal] load metadata for docker.io/dockage/alpine:3.15.4
#5 ...
#11 [localwsserver 2/5] WORKDIR /app
#11 CACHED
#12 [localwsserver 3/5] COPY package.json yarn.lock /app/
#12 CACHED
#13 [localwsserver 4/5] RUN yarn
#13 CACHED
#14 [localwsserver 5/5] COPY . /app/
#14 CACHED
#15 [localwsserver] exporting to image
#15 exporting layers done
#15 writing image sha256:1ebcc9a0c63156794e9058f1fd9f00a86d53eefbb89af0a178c857cf799d69b4 0.0s done
#15 naming to docker.io/library/saas-boilerplate-localwsserver 0.0s done
#15 DONE 0.0s
#5 [mailcatcher internal] load metadata for docker.io/dockage/alpine:3.15.4
#5 DONE 4.3s
#16 [mailcatcher 1/2] FROM docker.io/dockage/alpine:3.15.4@sha256:3d208f187240cb1f8cdfa4021dfc34b028ae79637194a316d34346d994420112
#16 CACHED
#17 [mailcatcher 2/2] RUN apk --no-cache --update add build-base ruby ruby-dev ruby-json ruby-etc sqlite-dev     && gem install mailcatcher:0.8.2 --no-document     && apk del --rdepends --purge build-base
#17 0.774 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
#17 0.992 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
#17 1.196 fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
#17 1.476 fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
#17 1.769 fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
#17 2.217 ERROR: unable to select packages:
#17 2.221   musl-1.2.2-r7:
#17 2.221     breaks: musl-dev-1.2.2-r9[musl=1.2.2-r9]
#17 2.221     satisfies: apk-tools-2.12.7-r3[musl>=1.2]
#17 2.221                apk-tools-2.12.7-r3[so:libc.musl-x86_64.so.1]
#17 2.221                ruby-libs-3.0.6-r0[so:libc.musl-x86_64.so.1]
#17 2.221                pkgconf-1.8.1-r0[so:libc.musl-x86_64.so.1]
#17 2.221                gcc-10.3.1_git20211027-r0[so:libc.musl-x86_64.so.1]
#17 2.221                g++-10.3.1_git20211027-r0[so:libc.musl-x86_64.so.1]
#17 2.221                libffi-3.4.2-r1[so:libc.musl-x86_64.so.1]
#17 2.221                patch-2.7.6-r7[so:libc.musl-x86_64.so.1]
#17 2.221                libgmpxx-6.2.1-r1[so:libc.musl-x86_64.so.1]
#17 2.221                ca-certificates-20211220-r0[so:libc.musl-x86_64.so.1]
#17 2.221                binutils-2.37-r3[so:libc.musl-x86_64.so.1]
#17 2.221                busybox-1.34.1-r5[so:libc.musl-x86_64.so.1]
#17 2.221                ruby-3.0.6-r0[so:libc.musl-x86_64.so.1]
#17 2.221                sqlite-libs-3.36.0-r0[so:libc.musl-x86_64.so.1]
#17 2.221                libucontext-1.1-r0[so:libc.musl-x86_64.so.1]
#17 2.221                libretls-3.3.4-r3[so:libc.musl-x86_64.so.1]
#17 2.221                ncurses-libs-6.3_p20211120-r2[so:libc.musl-x86_64.so.1]
#17 2.221                musl-utils-1.2.2-r7[so:libc.musl-x86_64.so.1]
#17 2.221                libstdc++-10.3.1_git20211027-r0[so:libc.musl-x86_64.so.1]
#17 2.221                file-5.41-r0[so:libc.musl-x86_64.so.1]
#17 2.221                mpc1-1.2.1-r0[so:libc.musl-x86_64.so.1]
#17 2.221                libmagic-5.41-r0[so:libc.musl-x86_64.so.1]
#17 2.221                gdbm-1.22-r0[so:libc.musl-x86_64.so.1]
#17 2.221                libgphobos-10.3.1_git20211027-r0[so:libc.musl-x86_64.so.1]
#17 2.221                su-exec-0.2-r1[so:libc.musl-x86_64.so.1]
#17 2.221                mpfr4-4.1.0-r0[so:libc.musl-x86_64.so.1]
#17 2.221                zlib-1.2.12-r0[so:libc.musl-x86_64.so.1]
#17 2.221                libgomp-10.3.1_git20211027-r0[so:libc.musl-x86_64.so.1]
#17 2.221                readline-8.1.1-r0[so:libc.musl-x86_64.so.1]
#17 2.221                make-4.3-r0[so:libc.musl-x86_64.so.1]
#17 2.221                libgcc-10.3.1_git20211027-r0[so:libc.musl-x86_64.so.1]
#17 2.221                libssl1.1-1.1.1n-r0[so:libc.musl-x86_64.so.1]
#17 2.221                alpine-baselayout-3.2.0-r18[so:libc.musl-x86_64.so.1]
#17 2.314                libcrypto1.1-1.1.1n-r0[so:libc.musl-x86_64.so.1]
#17 2.314                libatomic-10.3.1_git20211027-r0[so:libc.musl-x86_64.so.1]
#17 2.314                yaml-0.2.5-r0[so:libc.musl-x86_64.so.1]
#17 2.314                scanelf-1.3.3-r0[so:libc.musl-x86_64.so.1]
#17 2.314                gmp-6.2.1-r1[so:libc.musl-x86_64.so.1]
#17 2.314                isl22-0.22-r0[so:libc.musl-x86_64.so.1]
#17 2.314                ssl_client-1.34.1-r5[so:libc.musl-x86_64.so.1]
#17 ERROR: process "/bin/sh -c apk --no-cache --update add build-base ruby ruby-dev ruby-json ruby-etc sqlite-dev     && gem install mailcatcher:${MAILCATCHER_VERSION} --no-document
     && apk del --rdepends --purge build-base" did not complete successfully: exit code: 4
------
 > [mailcatcher 2/2] RUN apk --no-cache --update add build-base ruby ruby-dev ruby-json ruby-etc sqlite-dev     && gem install mailcatcher:0.8.2 --no-document     && apk del --rdepends --purge build-base:
2.221                libgcc-10.3.1_git20211027-r0[so:libc.musl-x86_64.so.1]
2.221                libssl1.1-1.1.1n-r0[so:libc.musl-x86_64.so.1]
2.221                alpine-baselayout-3.2.0-r18[so:libc.musl-x86_64.so.1]
2.314                libcrypto1.1-1.1.1n-r0[so:libc.musl-x86_64.so.1]
2.314                libatomic-10.3.1_git20211027-r0[so:libc.musl-x86_64.so.1]
2.314                yaml-0.2.5-r0[so:libc.musl-x86_64.so.1]
2.314                scanelf-1.3.3-r0[so:libc.musl-x86_64.so.1]
2.314                gmp-6.2.1-r1[so:libc.musl-x86_64.so.1]
2.314                isl22-0.22-r0[so:libc.musl-x86_64.so.1]
2.314                ssl_client-1.34.1-r5[so:libc.musl-x86_64.so.1]
------
failed to solve: process "/bin/sh -c apk --no-cache --update add build-base ruby ruby-dev ruby-json ruby-etc sqlite-dev     && gem install mailcatcher:${MAILCATCHER_VERSION} --no-document     && apk del --rdepends --purge build-base" did not complete successfully: exit code: 4
Warning: run-commands command "docker-compose up --force-recreate -d backend workers" exited with non-zero status code

 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target docker-compose:up for project core and 2 task(s) they depend on (4m)

    ×    1/3 failed
    √    2/3 succeeded [0 read from cache]

    Error: "pnpm nx run core:docker-compose:up" failed with code 1

Validations

@gabrii
Copy link

gabrii commented Feb 10, 2024

You need to change /packages/internal/mailcatcher/Dockerfile

In the first line, bump the version of alpine from 3.15.4 to 3.19.0

Although that makes the build succeed, I have not tested the email functionality.

@andrewrice
Copy link
Author

andrewrice commented Feb 10, 2024

Thanks for the response.

Modifying the Mailcatcher Dockerfile to dockage/alpine:3.19.0 allows the build to successfully complete, but the container isn't able to start (there appears to then be an error with the sqlite dependency?):

2024-02-10 17:51:02 Starting MailCatcher v0.8.2
2024-02-10 17:51:02 <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/sqlite3-1.7.2-x86_64-linux/lib/sqlite3.rb:6:in `rescue in <top (required)>'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/sqlite3-1.7.2-x86_64-linux/lib/sqlite3.rb:2:in `<top (required)>'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher/mail.rb:6:in `<top (required)>'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher/smtp.rb:5:in `<top (required)>'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:183:in `block (2 levels) in run!'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:233:in `rescue_port'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:182:in `block in run!'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run_machine'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:180:in `run!'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/bin/mailcatcher:6:in `<top (required)>'
2024-02-10 17:51:02     from /usr/bin/mailcatcher:25:in `load'
2024-02-10 17:51:02     from /usr/bin/mailcatcher:25:in `<main>'
2024-02-10 17:51:02 <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': Error relocating /usr/lib/ruby/gems/3.2.0/gems/sqlite3-1.7.2-x86_64-linux/lib/sqlite3/3.2/sqlite3_native.so: posix_fallocate64: symbol not found - /usr/lib/ruby/gems/3.2.0/gems/sqlite3-1.7.2-x86_64-linux/lib/sqlite3/3.2/sqlite3_native.so (LoadError)
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/sqlite3-1.7.2-x86_64-linux/lib/sqlite3.rb:4:in `<top (required)>'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher/mail.rb:6:in `<top (required)>'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher/smtp.rb:5:in `<top (required)>'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:183:in `block (2 levels) in run!'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:233:in `rescue_port'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:182:in `block in run!'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run_machine'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:180:in `run!'
2024-02-10 17:51:02     from /usr/lib/ruby/gems/3.2.0/gems/mailcatcher-0.8.2/bin/mailcatcher:6:in `<top (required)>'
2024-02-10 17:51:02     from /usr/bin/mailcatcher:25:in `load'
2024-02-10 17:51:02     from /usr/bin/mailcatcher:25:in `<main>'

@andrewrice
Copy link
Author

andrewrice commented Feb 11, 2024

Thanks for the response @gabrii, some thoughts below:

Using Alpine 3.19

Alpine 3.19 isn't a viable option unfortunately, as it seems there's an issue with the sqlite native precompiled gem, introduced by a breaking change in Musl 1.2 (which I think this is actually a root cause of my original issue). This prevents the container from starting up properly, even though the build completes.

This issue on the sqlite3-ruby repository covers it:
sparklemotion/sqlite3-ruby#434

More information on this from the Alpine repo:
https://gitlab.alpinelinux.org/alpine/aports/-/issues/15583

Using Alpine 3.18

Using dockage/alpine:3.18 allows the build to complete, but another incompatibility issue (this time with Ruby 3.x and Fixnum initialization) prevents the container from starting. Details for this issue can be found in sj26/mailcatcher#545

Using Alpine 3.18 and Mailcatcher 0.9

My latest attempt, using Alpine 3.18 and Mailcatcher 0.9, allows the build to complete and the container to successfully start. However, when I attempt to send an email from the backend I'm seeing this error in the workers container log:

2024-02-10 20:42:08 stdout: 
2024-02-10 20:42:08 > workers@2.4.2 sls /app/packages/workers
2024-02-10 20:42:08 > sls "invoke" "local" "-f" "SendEmail" "-d" "{\"source\":\"backend.email\",\"detail-type\":\"PASSWORD_RESET\",\"detail\":{\"id\":\"a862778ef5b54c4ca3eb15ede2a26768\",\"type\":\"PASSWORD_RESET\",\"to\":\"test@myaddress.com\",\"user_id\":\"OVwJAm8\",\"token\":\"c27m28-5da18398207311ea3a5f1d9bdd16fead\"}}"
2024-02-10 20:42:08 stderr: node:internal/modules/cjs/loader:1080
2024-02-10 20:42:08   throw err;
2024-02-10 20:42:08   ^
2024-02-10 20:42:08 Error: Cannot find module '/app/packages/workers/node_modules/serverless/bin/serverless.js'
2024-02-10 20:42:08     at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
2024-02-10 20:42:08     at Module._load (node:internal/modules/cjs/loader:922:27)
2024-02-10 20:42:08     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2024-02-10 20:42:08     at node:internal/main/run_main_module:23:47 {
2024-02-10 20:42:08   code: 'MODULE_NOT_FOUND',
2024-02-10 20:42:08   requireStack: []
2024-02-10 20:42:08 }
2024-02-10 20:42:08 Node.js v18.17.1
2024-02-10 20:42:08 stdout:  ELIFECYCLE  Command failed with exit code 1.
2024-02-10 20:42:08 child process exited with code 1

No idea what's happening here, but it does seem like you've seen a similar error in the past: #426 (comment)

@gabrii
Copy link

gabrii commented Feb 11, 2024

Hi @andrewrice, you are right. I got it to start with:

FROM dockage/alpine:3.18
ENV MAILCATCHER_VERSION=0.9.0

I proceeded to try to send a recovery email, and just made it this far:

> workers@2.4.0 sls /app/packages/workers
> sls "invoke" "local" "-f" "SendEmail" "-d" "{\"source\":\"backend.email\",\"detail-type\":\"PASSWORD_RESET\",\"detail\":{\"id\":\"19b2108dc0ba43ebb19c1628c690947c\",\"type\":\"PASSWORD_RESET\",\"to\":\"admin@example.com\",\"user_id\":\"ajeypWr\",\"token\":\"c289p8-56adb95d4ca2224858352d0c5e37b4c9\"}}"
stderr: (node:146) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.
Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy
(Use `node --trace-warnings ...` to show where the warning was created)
stderr: Environment: linux, node 18.17.1, framework 3.35.2 (local), plugin 7.0.3, SDK 4.4.0
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues
stderr: 
stdout: Error:
Cannot resolve serverless.yml: Variables resolution errored with:
  - Cannot resolve variable at "custom.conf.eventBusArn": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
  - Cannot resolve variable at "custom.conf.environment.SENTRY_DSN": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
  - Cannot resolve variable at "custom.conf.SendEmail.environment.FROM_EMAIL": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
  - Cannot resolve variable at "custom.conf.ExportUsers.environment.HASHID_SALT": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
  - Cannot resolve variable at "custom.conf.SynchronizeContentfulContent.environment.CONTENTFUL_SPACE_ID": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
  - Cannot resolve variable at "custom.conf.WebSocketsHandler.environment.HASHID_SALT": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
  - Cannot resolve variable at "custom.conf.SendEmail.environment.WEB_APP_URL": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
  - Cannot resolve variable at "custom.conf.SynchronizeContentfulContent.environment.CONTENTFUL_ACCESS_TOKEN": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
  - Cannot resolve variable at "custom.conf.SynchronizeContentfulContent.environment.CONTENTFUL_ENVIRONMENT": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
  - Cannot resolve variable at "custom.conf.WebSocketsHandler.environment.JWT_SECRET": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .
stdout:  ELIFECYCLE  Command failed with exit code 1.
child process exited with code 1

To get the workers to run (albeit with bad configuration) I had to do the exact change you reference in the comment, as it seems like node_modules are affected somehow otherwise:

diff --git a/packages/workers/Dockerfile b/packages/workers/Dockerfile
index b56b52a..2c7f573 100644
--- a/packages/workers/Dockerfile
+++ b/packages/workers/Dockerfile
@@ -39,12 +39,12 @@ COPY $SRC_CORE_PATH/package.json $DEST_CORE_PATH/
 COPY $SRC_WORKERS_PATH/package.json $DEST_WORKERS_PATH/
 COPY tsconfig* $APP_PATH/
 COPY $SRC_CLI_PATH $DEST_CLI_PATH/
-RUN pnpm install --include-workspace-root --frozen-lockfile --filter=workers... --filter=cli...
 
 COPY nx.json tsconfig* jest* babel* .eslintrc* .prettier* .eslintrc* $APP_PATH/
 COPY $SRC_CORE_PATH $DEST_CORE_PATH/
 COPY $SRC_WORKERS_PATH $DEST_WORKERS_PATH/
 RUN chmod +x $DEST_WORKERS_PATH/scripts/*.sh
+RUN pnpm install --include-workspace-root --frozen-lockfile --filter=workers... --filter=cli...
 
 ENV PYTHONPATH=/pkgs/__pypackages__/3.11/lib \
     PATH=$PATH:/pkgs/__pypackages__/3.11/bin

It seems like @pziemkowski gave some solutions in discord to fix the wrong configuration inside the workers: https://discord.com/channels/1122849885335597088/1125769784018087967/1156618189862608928

I'll leave this to the experts, right now deploying is not my priority. Apologies.

mkleszcz added a commit that referenced this issue Feb 12, 2024
…cher instance built from Dockerfile with image from Docker Hub
mkleszcz added a commit that referenced this issue Feb 12, 2024
…cher instance built from Dockerfile with image from Docker Hub
@mkleszcz
Copy link
Contributor

@andrewrice @gabrii Please check the PR with the fix. It will be included in the next release

@mkleszcz mkleszcz added this to the 2.4.3 milestone Feb 12, 2024
@andrewrice
Copy link
Author

andrewrice commented Feb 12, 2024

@mkleszcz I've integrated the changes in your PR and it resolves the build/startup issues with the mailcatcher container (thank you!), but there it still seems to be an issue in the worker's container that @gabrii highlighted when attempting to send an email from the backend:

Here's an excerpt from workers-1 container log:

2024-02-12 13:02:58 > nx run workers:serve
2024-02-12 13:02:58 
2024-02-12 13:02:59 Local trigger server listening at http://0.0.0.0:3005
2024-02-12 13:03:13 stdout: 
2024-02-12 13:03:13 > workers@2.4.2 sls /app/packages/workers
2024-02-12 13:03:13 > sls "invoke" "local" "-f" "SynchronizeContentfulContent" "-d" "{\"source\":\"backend.contentfulSync\",\"detail-type\":\"complete\",\"detail\":{\"id\":\"c6b09ef97bae46adb6a795ea3367924a\",\"type\":\"complete\"}}"
2024-02-12 13:03:13 stderr: node:internal/modules/cjs/loader:1080
2024-02-12 13:03:13   throw err;
2024-02-12 13:03:13   ^
2024-02-12 13:03:13 Error: Cannot find module '/app/packages/workers/node_modules/serverless/bin/serverless.js'
2024-02-12 13:03:13     at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
2024-02-12 13:03:13     at Module._load (node:internal/modules/cjs/loader:922:27)
2024-02-12 13:03:13     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2024-02-12 13:03:13     at node:internal/main/run_main_module:23:47 {
2024-02-12 13:03:13   code: 'MODULE_NOT_FOUND',
2024-02-12 13:03:13   requireStack: []
2024-02-12 13:03:13 }
2024-02-12 13:03:13 Node.js v18.17.1
2024-02-12 13:03:13 stdout:  ELIFECYCLE  Command failed with exit code 1.
2024-02-12 13:03:13 child process exited with code 1
2024-02-12 13:30:05 stdout: 
2024-02-12 13:30:05 > workers@2.4.2 sls /app/packages/workers
2024-02-12 13:30:05 > sls "invoke" "local" "-f" "SendEmail" "-d" "{\"source\":\"backend.email\",\"detail-type\":\"ACCOUNT_ACTIVATION\",\"detail\":{\"id\":\"6c7f5d65bda0437da211dc4a348730b6\",\"type\":\"ACCOUNT_ACTIVATION\",\"to\":\"test@example.com\",\"user_id\":\"OVwJAm8\",\"token\":\"c2are4-5570785471b3b919ba9e6aa72d0ce915\"}}"
2024-02-12 13:30:05 stderr: node:internal/modules/cjs/loader:1080
2024-02-12 13:30:05   throw err;
2024-02-12 13:30:05   ^
2024-02-12 13:30:05 Error: Cannot find module '/app/packages/workers/node_modules/serverless/bin/serverless.js'
2024-02-12 13:30:05     at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
2024-02-12 13:30:05     at Module._load (node:internal/modules/cjs/loader:922:27)
2024-02-12 13:30:05     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2024-02-12 13:30:05     at node:internal/main/run_main_module:23:47 {
2024-02-12 13:30:05   code: 'MODULE_NOT_FOUND',
2024-02-12 13:30:05   requireStack: []
2024-02-12 13:30:05 }
2024-02-12 13:30:05 Node.js v18.17.1
2024-02-12 13:30:05 stdout:  ELIFECYCLE  Command failed with exit code 1.
2024-02-12 13:30:05 child process exited with code 1
2024-02-12 13:30:30 stdout: 
2024-02-12 13:30:30 > workers@2.4.2 sls /app/packages/workers
2024-02-12 13:30:30 > sls "invoke" "local" "-f" "SendEmail" "-d" "{\"source\":\"backend.email\",\"detail-type\":\"PASSWORD_RESET\",\"detail\":{\"id\":\"2ca0c55002ac4c2aa6ca10b83174aff1\",\"type\":\"PASSWORD_RESET\",\"to\":\"test@example.com\",\"user_id\":\"OVwJAm8\",\"token\":\"c2areu-bead185dfdb85583ed35d171bd3bf2a3\"}}"

It seems like the worker container is unable to locate the serverless module. Maybe something is still caching on my end?

Not sure if this helpful, but this is what the worker-1 container file tree looks like at /app/packages/workers/node_modules:

image

It's almost like the symlink between .bin and bin isn't generated? Any thoughts?

Very much appreciate you!

@mkleszcz
Copy link
Contributor

@andrewrice please check #484 for the fixes for above issues ;)

@andrewrice
Copy link
Author

@andrewrice please check #484 for the fixes for above issues ;)

Thanks @mkleszcz -- I'll give a shot tomorrow afternoon and will report back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants