-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.simple
More file actions
81 lines (65 loc) · 2.52 KB
/
Dockerfile.simple
File metadata and controls
81 lines (65 loc) · 2.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Data Analysis Docker Environment - R Integration
# Lightweight version with Jupyter R kernel only
FROM python:3.12-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Set working directory
WORKDIR /app
# Install system dependencies including R and development tools for rpy2
RUN apt-get update && apt-get install -y \
gcc \
g++ \
gfortran \
libopenblas-dev \
liblapack-dev \
pkg-config \
curl \
git \
vim \
wget \
r-base \
r-base-dev \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
libfontconfig1-dev \
libharfbuzz-dev \
libfribidi-dev \
libfreetype6-dev \
libpng-dev \
libtiff5-dev \
libjpeg-dev \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for security
RUN useradd --create-home --shell /bin/bash analyst && \
echo "analyst:analyst" | chpasswd && \
chown -R analyst:analyst /app
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
# Install Python dependencies first (without rpy2)
RUN pip install --no-cache-dir -r requirements.txt
# Install essential R packages
RUN R -e "install.packages(c('tidyverse', 'dplyr', 'ggplot2', 'plotly', 'shiny', 'rmarkdown', 'knitr', 'devtools', 'IRkernel', 'readr', 'readxl', 'lubridate', 'stringr', 'tidyr', 'forcats', 'corrplot', 'VIM', 'mice', 'caret', 'randomForest', 'e1071', 'cluster', 'factoextra', 'fpc', 'DBI', 'RPostgreSQL', 'RSQLite', 'httr', 'jsonlite', 'xml2', 'rvest', 'reticulate'), repos='https://cloud.r-project.org/', Ncpus=4)"
# Install IRkernel for Jupyter R support
RUN R -e "IRkernel::installspec(user = FALSE)"
# Install Python-R integration packages after R is fully set up
RUN pip install --no-cache-dir rpy2 pyreadr
# Copy project files
COPY . .
# Copy R profile to analyst home directory
COPY .Rprofile /home/analyst/.Rprofile
RUN chown analyst:analyst /home/analyst/.Rprofile
# Change ownership to analyst user
RUN chown -R analyst:analyst /app
# Create necessary directories as analyst user
USER analyst
RUN mkdir -p data/raw data/processed data/external outputs/figures outputs/reports
# Switch back to root for startup
USER root
# Expose ports for Jupyter Lab
EXPOSE 8888
# Default command to start Jupyter Lab with both Python and R kernels
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root", "--NotebookApp.token=''", "--NotebookApp.password=''", "--ServerApp.allow_origin='*'", "--ServerApp.disable_check_xsrf=True"]