meztez / bigrquerystorage

R Client for BigQuery Storage API
Apache License 2.0
19 stars 3 forks source link

working docker image #58

Closed michaelgap360 closed 5 months ago

michaelgap360 commented 5 months ago

Hi,

Are there any examples of a working docker image to build an instance of R with this package installed,

thanks

meztez commented 5 months ago

not that I know of. Do you have trouble installing?

You can check the github actions yaml maybe? They are close to Docker image.

michaelgap360 commented 5 months ago

yep all attempts have failed to build a docker image,

I've tried adding to an existing image with the standard RUN R -e "install.packages('bigrquerystorage', repos='https://cloud.r-project.org/')" and also building from a new image from scratch

# Use the official Ubuntu base image
FROM ubuntu:20.04

# Install dependencies
RUN apt-get update && \
    apt-get install -y \
    build-essential \
    libssl-dev \
    libcurl4-openssl-dev \
    software-properties-common \
    curl \
    wget \
    gnupg2 \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install gRPC and protobuf
RUN apt-get update && \
    apt-get install -y \
    autoconf \
    automake \
    libtool \
    make \
    g++ \
    unzip \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Install protoc
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protobuf-all-3.14.0.tar.gz && \
    tar -xzf protobuf-all-3.14.0.tar.gz && \
    cd protobuf-3.14.0 && \
    ./configure && \
    make && \
    make install && \
    ldconfig && \
    cd .. && \
    rm -rf protobuf-3.14.0 protobuf-all-3.14.0.tar.gz

# Install R
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 51716619E084DAB9 && \
    add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/' && \
    apt-get update && \
    apt-get install -y r-base && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Install necessary R packages
RUN R -e "install.packages('bigrquerystorage', repos='https://cloud.r-project.org/')"

# Expose the port that your gRPC server will use
EXPOSE 50051
meztez commented 5 months ago

I'll take a look at it. Thanks for sharing.

meztez commented 5 months ago

Ubuntu 20.04 is too far back, 22.04 should work as 24.04

meztez commented 5 months ago

See installation instructions in the readme for ubuntu and you should be fine

michaelgap360 commented 5 months ago

brill

I'll see if I can get it working

thanks

michaelgap360 commented 5 months ago

Looks like the below does create a working image

# Use the official Ubuntu 22.04 as a base image
FROM ubuntu:22.04

# Set environment variables to non-interactive to avoid prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y libssl-dev
RUN apt-get install -y libcurl4-openssl-dev

# Update the package list and install dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential \
    autoconf \
    automake \
    libtool \
    curl \
    make \
    g++ \
    unzip \
    wget \
    ca-certificates \
    software-properties-common \
    gnupg \
    libgrpc++-dev \
    libprotobuf-dev \
    protobuf-compiler-grpc \
    pkg-config

# Install Protocol Buffers (protoc)
RUN apt-get install -y protobuf-compiler

# Install R
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    dirmngr \
    gnupg2 \
    software-properties-common && \
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 'E298A3A825C0D65DFD57CBB651716619E084DAB9' && \
    add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/' && \
    apt-get update && \
    apt-get install -y r-base

# Install necessary R packages
RUN R -e "install.packages('openssl',dependencies=TRUE, repos='http://cran.rstudio.com/')"

RUN R -e "install.packages('httr',dependencies=TRUE, repos='http://cran.rstudio.com/')"

RUN R -e "install.packages('gargle',dependencies=TRUE, repos='http://cran.rstudio.com/')"

RUN R -e "install.packages('bigrquery',dependencies=TRUE, repos='http://cran.rstudio.com/')"

RUN R -e "install.packages('bigrquerystorage', repos='http://cran.rstudio.com/')"

# Expose the port that your gRPC server will use
EXPOSE 50051