-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.single-stage
More file actions
47 lines (39 loc) · 1.52 KB
/
Dockerfile.single-stage
File metadata and controls
47 lines (39 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# ============================================================================
# SINGLE-STAGE DOCKERFILE (BEFORE OPTIMIZATION)
# ============================================================================
# This approach has several inefficiencies:
# 1. Build tools remain in final image (bloat)
# 2. Poor layer caching - any code change invalidates package installations
# 3. Longer build times due to redundant dependency resolution
# 4. Larger final image size (~2GB+)
# ============================================================================
FROM rocker/r2u:24.04
# Configure renv cache to be inside the app directory
ENV RENV_PATHS_CACHE="/app/renv/.cache"
# Install system dependencies
RUN apt-get update && apt-get install -y \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
libfontconfig1-dev \
libharfbuzz-dev \
libfribidi-dev \
libfreetype6-dev \
libpng-dev \
libtiff5-dev \
libjpeg-dev \
pandoc \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy everything at once (poor caching)
COPY . .
# Install R packages
RUN R -e "install.packages('renv', repos = 'https://cloud.r-project.org')"
RUN R -e "renv::restore()"
# Expose port
EXPOSE 3838
# Run the application
# Note: Use --vanilla to skip .Rprofile and avoid renv activation at runtime
# The renv library path is already in R's search path
CMD ["R", "--vanilla", "-e", ".libPaths('/app/renv/library/linux-ubuntu-noble/R-4.5/x86_64-pc-linux-gnu'); shiny::runApp('/app', host = '0.0.0.0', port = 3838)"]