Pact-js: Problem with ruby in docker alpine

Created on 30 May 2019  Â·  17Comments  Â·  Source: pact-foundation/pact-js

Software versions

  • OS: Alpine
  • Consumer Pact library: 8.2.4
  • Provider Pact library: N/A
  • Node Version: 10.15.3

Expected behaviour

The ruby binary is installed and usable for testing.

Actual behaviour

The ruby binary is missing:

[2019-05-30T13:36:23.268Z] ERROR: [email protected]/52 on 2f21113fe9d5:
    Pact Binary Error: /usr/src/app/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.65.1/lib/ruby/bin/ruby: line 6: /usr/src/app/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.65.1/lib/ruby/bin.real/ruby: No such file or directory

Steps to reproduce

Clone https://github.com/kjenney/pact-js-test-consumer and run docker build ..

docker build -f Dockerfile.ubuntu . works fine but the alpine tests fail because the standalone ruby version is missing.

Most helpful comment

Thanks @YOU54F!

All 17 comments

https://github.com/pact-foundation/pact-js/issues/296

you need bash :) as alpine ships with sh

I installed bash:

# Install prod dependencies RUN apk -Uuv add --no-cache \ make \ curl \ groff \ less \ nodejs-npm \ bash \ python \ ruby

The suspense is killing me, did it work or not? 🌮

In your example repo, you don't have bash installed?

https://github.com/kjenney/pact-js-test-consumer/blob/master/Dockerfile

just tested it, this works

FROM node:10.15.3-alpine

ARG NODE_ENV

RUN apk update

# Install base and dev packages
RUN apk add --no-cache --virtual build-dependencies build-base

# Install prod dependencies
RUN apk -Uuv add --no-cache \
  make \
  curl \
  groff \
  less \
  nodejs-npm \
  python 

RUN  apk --no-cache add ca-certificates wget bash \
&& wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk \
&& apk add glibc-2.29-r0.apk

SHELL ["/bin/bash", "-c"]

# Set timezone to UTC by default
RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime

# Update npm
RUN npm install -g npm

WORKDIR /usr/src/app

# Copy Package.json and lock
COPY package* ./

# Install NodeJS Dependencies
RUN npm install

# Copy code
COPY . .

# Run tests
RUN npm run test

[2019-05-30T22:53:01.991Z]  INFO: [email protected]/64 on 3394e6f190f0: Created './standalone/linux-x64-1.65.1/bin/pact-mock-service service --consumer 'Test' --cors 'true' --pact_dir '/usr/src/app/pacts' --host '127.0.0.1' --log '/usr/src/app/logs/mockserver-verification.log' --pact-file-write-mode 'update' --port '8991' --provider 'Factory' --pact_specification_version '2'' process with PID: 105
[2019-05-30T22:53:03.030Z]  INFO: [email protected]/64 on 3394e6f190f0:
    Setting up Pact with Consumer "Test" and Provider "Factory"
        using mock service on Port: "8991"
[2019-05-30T22:53:03.146Z] ERROR: [email protected]/64 on 3394e6f190f0:
    Pact Binary Error: WARN: No content type found, performing text diff on body

[2019-05-30T22:53:03.238Z]  INFO: [email protected]/64 on 3394e6f190f0: Pact File Written
[2019-05-30T22:53:03.239Z]  INFO: [email protected]/64 on 3394e6f190f0: Removing Pact with PID: 105
[2019-05-30T22:53:03.244Z]  INFO: [email protected]/64 on 3394e6f190f0:
    Deleting Pact Server with options:
    consumer = Test,
    cors = true,
    dir = /usr/src/app/pacts,
    host = 127.0.0.1,
    log = /usr/src/app/logs/mockserver-verification.log,
    pactFileWriteMode = update,
    port = 8991,
    provider = Factory,
    spec = 2,
    ssl = false,
    sslcert = ,
    sslkey =
PASS tests/unit/factory.pact.js

Test Suites: 2 passed, 2 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        4.412s
Ran all test suites.
Removing intermediate container 3394e6f190f0
 ---> fac2a6d11856
Successfully built fac2a6d11856

Magic step appeared to be this

RUN  apk --no-cache add ca-certificates wget bash \
&& wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk \
&& apk add glibc-2.29-r0.apk

not sure how I feel about alpine, as by the time you've added in all your deps, the image is massive.

that comes in at ~770mb uncompressed, obvs you've got the full project and node_modules in there too.

I tend to use debian:stretch and don't have to faff around with sprinking in extra magic to get small things to work.

Total Image size: 774 MB
Potential wasted space: 33 MB
Image efficiency score: 97 %

@kjenney sorted fella :)

btw I have some docker templates albeit for pact-ruby-standalone based on a few flavours. I'll pop up an alpine image soon

They are here - https://github.com/YOU54F/pact-standalone-docker-slim

Thanks for following this up @YOU54F! Closing this issue, #296 has a working Alpine image.

Thanks @YOU54F!

What do we need bash for? Is it in the standalone scripts?

possibly, the four additions I made were

glibc-2.29-r0.apk plus the wget calls for the keys,
bash
build-dependencies
build-base

I'm about to crash for the night as it's well late here but worth isolating it by removing each one and seeing when it stops working :)

My tests passed without switching the shell. All I needed was glibc.

Thanks!

On Thu, May 30, 2019, 7:05 PM Yousaf Nabi notifications@github.com wrote:

btw I have some docker templates albeit for pact-ruby-standalone based on
a few flavours. I'll pop up an alpine image soon

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pact-foundation/pact-js/issues/305?email_source=notifications&email_token=ABR7776A7HY2ZX4HXBY2FL3PYBMR7A5CNFSM4HRFLGV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWTX6GQ#issuecomment-497516314,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABR7773NT5VSJ4PPER37R5LPYBMR7ANCNFSM4HRFLGVQ
.

I think there are some bashisms in the distribution. I'll see if I can pinpoint it Beth. I recall a conversation (it'll be in an issue _somewhere_)

Yep, in fact a few of the tools use it directly (e.g. https://github.com/pact-foundation/pact-ruby-standalone/blob/master/packaging/pact-provider-verifier.sh#L1-L4).

So you need bash installed but don't need to switch to the bash shell during install/test.

Exactly.

On Sat, Jun 1, 2019, 4:47 PM Ken Jenney notifications@github.com wrote:

So you need bash installed but don't need to switch to the bash shell
during install/test.

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/pact-foundation/pact-js/issues/305?email_source=notifications&email_token=AAANFDCI35KMPVQR2XF3JDDPYILRVA5CNFSM4HRFLGV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWW2JHQ#issuecomment-497919134,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAANFDEJYWCE6OHVW76QXP3PYILRVANCNFSM4HRFLGVQ
.

Was this page helpful?
0 / 5 - 0 ratings