# This is for alpine base
FROM node:alpine
RUN apk update
RUN apk upgrade
RUN apk add curl git libcap htop

# This for ubuntu base
# FROM node
# RUN apt-get update
# RUN apt-get dist-upgrade -y
# RUN apt-get install curl git libcap2 htop -y

# Allow node to listen on ports 80 and 443 as normal user.
RUN setcap cap_net_bind_service=+ep $(readlink -f $(which node))

WORKDIR /opt/goldilocks

# Copy in just package.json and install npm dependencies first
COPY package.json /opt/goldilocks/
RUN yarn install

# Then copy in the rest and link as global binary
COPY . /opt/goldilocks/
RUN yarn link

# Copy in a goldilocks config to test it.
# TODO: pull this from the user somehow
COPY etc/goldilocks/goldilocks.example.yml /opt/goldilocks/etc/goldilocks/goldilocks.yml

# Run as unpriviledged user
USER node
EXPOSE 80 443 5353
CMD ["/usr/local/bin/goldilocks"]
