我有一个多阶段 Docker 文件,尝试构建它时出现错误。我希望缓存 R 包以加快 docker 构建速度。此外,它还连接到 gitlab CI/CD 以进行自动部署...
我有一个多阶段 Docker 文件,在尝试构建它时出现错误。我希望缓存 R 包以加快 Docker 构建速度。此外,它还连接到 gitlab CI/CD 以自动部署到 Cloud run
# Stage 1: Install R and R packages in a separate build stage
FROM r-base:4.4.1 as r-build
# Install necessary system dependencies
RUN apt-get update && apt-get install -y \
software-properties-common \
dirmngr \
gnupg \
apt-transport-https \
ca-certificates \
lsb-release \
wget \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
libxt-dev
# Install R packages
RUN Rscript -e "install.packages('forecast', dependencies=TRUE)"
RUN Rscript -e "install.packages('lubridate')"
RUN Rscript -e "install.packages('googleCloudStorageR')"
# Stage 2: Build the final image
FROM ubuntu:latest as final_stage
# Copy the installed R libraries from the previous stage
COPY --from=r-build /usr/local/lib/R/site-library /usr/local/lib/R/site-library
# Set non-interactive frontend for apt-get
ENV DEBIAN_FRONTEND=noninteractive
ARG ENV=test
# Install necessary system dependencies
RUN apt-get update && apt-get install -y \
install r-base \
build-essential \
python3-dev \
libffi-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
libcurl4-openssl-dev \
zlib1g-dev \
libjpeg-dev \
libpng-dev \
r-base \
systemd \
libstdc++6 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /home/app
# Copy over requirements.txt and upgrade pip and setuptools before installing dependencies
COPY requirements.txt .
RUN python3 -m pip install --upgrade pip setuptools
RUN python3 -m pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY config/config_$ENV.py ./config/config.py
COPY run.py .
COPY startup_docker.sh .
COPY setup.sh .
COPY app ./app
COPY app/credentials.json credentials.json
# Ensure scripts have execution permissions
RUN chmod +x /home/app/setup.sh /home/app/startup_docker.sh
# Run the setup script (this is where R packages might be installed)
RUN ./setup.sh
# Set the entrypoint to the startup script
CMD ["python3", "/home/app/run.py"]
这是错误
The following packages have unmet dependencies:
r-base : Depends: r-base-core (>= 4.4.1-1.2204.0) but it is not going to be installed
Depends: r-recommended (= 4.4.1-1.2204.0) but it is not going to be installed
Recommends: r-base-html but it is not going to be installed
Recommends: r-doc-html but it is not going to be installed
E: Unable to correct problems, you have held broken packages.