File size: 4,019 Bytes
dcfb803
de41f57
 
 
 
a59174a
 
 
de41f57
 
dcfb803
 
de41f57
 
 
 
 
 
 
 
a59174a
de41f57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf7d3a3
 
 
 
de41f57
 
7f40cff
 
 
71df013
 
 
de41f57
 
 
 
 
 
 
 
 
 
71df013
 
de41f57
 
cf7d3a3
de41f57
 
 
 
 
 
7f40cff
 
 
 
7df66f7
de41f57
 
 
 
a59174a
de41f57
 
 
a59174a
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
82
83
84
85
86
87
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"]