Skip to content

Using the pact ruby standalone with Alpine Linux Docker

Yousaf Nabi edited this page Feb 9, 2024 · 6 revisions

TL;DR - apk --no-cache add gcompat libc6-compat

Replace your entrypoint to other pact standalone commands, or adjust the Dockerfiles to suit your needs.

Be sure to let us know what cool stuff you get up to

x86_64

FROM alpine:latest

WORKDIR ../

ENV TARGET_ARCH=x86_64
ENV PACT_VERSION=2.0.0

RUN apk --no-cache add gcompat libc6-compat
RUN wget -q https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v${PACT_VERSION}/pact-${PACT_VERSION}-linux-${TARGET_ARCH}.tar.gz \
     && tar xzf pact-${PACT_VERSION}-linux-${TARGET_ARCH}.tar.gz \
     && rm -rf pact-${PACT_VERSION}-linux-${TARGET_ARCH}.tar.gz \
     && ln -s /pact/bin/* /usr/local/bin

ENTRYPOINT ["pact-mock-service"]

arm64 / aarch64

FROM arm64v8/alpine

WORKDIR ../

ENV TARGET_ARCH=arm64
ENV PACT_VERSION=2.0.0

RUN apk --no-cache add gcompat libc6-compat
RUN wget -q https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v${PACT_VERSION}/pact-${PACT_VERSION}-linux-${TARGET_ARCH}.tar.gz \
     && tar xzf pact-${PACT_VERSION}-linux-${TARGET_ARCH}.tar.gz \
     && rm -rf pact-${PACT_VERSION}-linux-${TARGET_ARCH}.tar.gz \
     && ln -s /pact/bin/* /usr/local/bin

ENTRYPOINT ["pact-mock-service"]

x86_64 users can install replace libc6-compat with glibc directly, but gcompat is recommended on Alpine's website.

FROM alpine:latest

WORKDIR ../

ENV TARGET_ARCH=x86_64
ENV PACT_VERSION=2.0.0
ENV GLIBC_VERSION=2.35-r0

RUN apk --no-cache add gcompat bash \
     && wget -O /etc/apk/keys/sgerrand.rsa.pub -q https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
     && wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk \
     && apk --no-cache --force-overwrite add glibc-${GLIBC_VERSION}.apk

RUN wget -q https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v${PACT_VERSION}/pact-${PACT_VERSION}-linux-${TARGET_ARCH}.tar.gz \
     && tar xzf pact-${PACT_VERSION}-linux-${TARGET_ARCH}.tar.gz \
     && rm -rf pact-${PACT_VERSION}-linux-${TARGET_ARCH}.tar.gz \
     && ln -s /pact/bin/* /usr/local/bin

ENTRYPOINT ["pact-mock-service"]

Note: Versions prior to v2.3.0 require bash

Clone this wiki locally