FROM rocker/tidyverse:4.4.2

RUN apt-get update && apt-get install -y --no-install-recommends \
    libpq-dev \
  && rm -rf /var/lib/apt/lists/*

# Install deps from DESCRIPTION before copying the rest (layer cache)
COPY DESCRIPTION /pkg/DESCRIPTION
RUN Rscript -e "remotes::install_deps('/pkg', dependencies = TRUE)"

COPY . /pkg
RUN R CMD INSTALL /pkg

EXPOSE 3838

CMD ["Rscript", "-e", "beekeeper::run_app()"]
