FROM node:12-alpine3.13

ENV NPM_CONFIG_LOGLEVEL error
ARG NPM_TOKEN

WORKDIR /var/app
COPY . /var/app

# inspired by https://github.com/Blizzard/node-rdkafka/blob/master/examples/docker-alpine.md

RUN apk update && apk add --no-cache --virtual build-dependencies \
    bash \
    make \
    g++ \
    python3

RUN apk --no-cache add \
    zlib-dev \
    libc-dev \
    bsd-compat-headers \
    py-setuptools \
    ca-certificates \
    lz4-dev \
    musl-dev \
    cyrus-sasl-dev \
    cyrus-sasl \
    openssl \
    openssl-dev \
    libsasl

RUN yarn install --production --frozen-lockfile
RUN apk del build-dependencies
RUN yarn run build

ENTRYPOINT ["node", "dist/index.js"]
