asa-api / Dockerfile
cjerzak's picture
add files
7f40cff
FROM rocker/r2u:24.04
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Etc/UTC \
PORT=7860 \
ASA_PROXY=socks5h://127.0.0.1:9050 \
TOR_CONTROL_PORT=9051 \
ASA_TOR_CONTROL_COOKIE=/tmp/tor/control.authcookie \
RETICULATE_MINICONDA_PATH=/opt/conda \
RETICULATE_CONDA=/opt/conda/bin/conda \
RETICULATE_PYTHON=/opt/conda/envs/asa_env/bin/python \
LD_LIBRARY_PATH=/opt/conda/envs/asa_env/lib:/opt/conda/lib:${LD_LIBRARY_PATH} \
PATH=/opt/conda/bin:${PATH} \
R_REMOTES_NO_ERRORS_FROM_WARNINGS=true
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
wget \
git \
tor \
bzip2 \
build-essential \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
libgit2-dev \
zlib1g-dev \
libicu-dev \
libbz2-dev \
liblzma-dev \
libreadline-dev \
libsqlite3-dev \
libffi-dev \
libpng-dev \
libjpeg-dev \
libtiff5-dev \
libharfbuzz-dev \
libfribidi-dev \
r-cran-plumber \
r-cran-jsonlite \
r-cran-reticulate \
r-cran-remotes \
&& rm -rf /var/lib/apt/lists/*
ARG DOCKERFILE_REV=2026-03-10-openssl-hotfix-1
ARG ASA_CONDA_PYTHON_VERSION=3.12.3
ARG ASA_CONDA_OPENSSL_VERSION=3.0.13
RUN echo "asa-api docker revision: ${DOCKERFILE_REV}"; \
set -eux; \
arch="$(uname -m)"; \
case "$arch" in \
x86_64) installer="Miniconda3-latest-Linux-x86_64.sh" ;; \
aarch64|arm64) installer="Miniconda3-latest-Linux-aarch64.sh" ;; \
*) echo "Unsupported architecture: $arch"; exit 1 ;; \
esac; \
curl -fsSL "https://repo.anaconda.com/miniconda/${installer}" -o /tmp/miniconda.sh; \
bash /tmp/miniconda.sh -b -p /opt/conda; \
rm -f /tmp/miniconda.sh; \
/opt/conda/bin/conda config --set always_yes yes --set changeps1 no; \
/opt/conda/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main; \
/opt/conda/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r; \
/opt/conda/bin/conda update -n base -c defaults conda
RUN R -q -e "gate <- c('remotes','plumber','jsonlite','reticulate'); missing <- gate[!vapply(gate, function(p) requireNamespace(p, quietly = TRUE), logical(1))]; if (length(missing)) stop(sprintf('Binary package gate failed; missing: %s', paste(missing, collapse = ', ')), call. = FALSE); cat('Binary R package gate passed:', paste(gate, collapse = ', '), '\n'); cat('R library paths:', paste(.libPaths(), collapse = ' | '), '\n'); cat('plumber version:', as.character(packageVersion('plumber')), '\n')"
ARG ASA_SOFTWARE_REPO=https://github.com/cjerzak/asa-software
ARG ASA_SOFTWARE_REF=main
RUN git clone --depth 1 --branch "${ASA_SOFTWARE_REF}" "${ASA_SOFTWARE_REPO}" /opt/asa-software \
&& R -q -e "remotes::install_local('/opt/asa-software/asa', dependencies = TRUE, upgrade = 'never')" \
&& /opt/conda/bin/conda create -n asa_env "python=${ASA_CONDA_PYTHON_VERSION}" "openssl=${ASA_CONDA_OPENSSL_VERSION}" pip setuptools \
&& R -q -e "asa::build_backend(conda_env='asa_env', python_version='3.12', force=FALSE, check_browser=FALSE, fix_browser=FALSE)" \
&& /opt/conda/bin/conda run -n asa_env python -c "import ssl, sys; print(sys.version); print(ssl.OPENSSL_VERSION)" \
&& R -q -e "reticulate::use_condaenv('asa_env', required = TRUE); cfg <- reticulate::py_config(); cat('reticulate py_config python:', cfg[['python']], '\n'); reticulate::py_run_string('import ssl, sys; print(sys.version); print(ssl.OPENSSL_VERSION)')" \
&& R -q -e "gate <- c('asa','plumber','jsonlite','reticulate'); missing <- gate[!vapply(gate, function(p) requireNamespace(p, quietly = TRUE), logical(1))]; if (length(missing)) stop(sprintf('Post-asa gate failed; missing: %s', paste(missing, collapse = ', ')), call. = FALSE); cat('Post-asa package gate passed\n')" \
&& rm -rf /opt/asa-software/.git
WORKDIR /app
COPY . /app
RUN chmod +x /app/scripts/start-with-tor.sh
EXPOSE 7860
CMD ["/app/scripts/start-with-tor.sh"]