Skip to content

Commit cc41e3e

Browse files
committed
update github actions workflow
1 parent dd44b66 commit cc41e3e

4 files changed

Lines changed: 148 additions & 95 deletions

File tree

.Rprofile

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/build-test-sign-image.yaml

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,55 @@ jobs:
4242
username: ${{ github.actor }}
4343
password: ${{ secrets.GITHUB_TOKEN }}
4444

45-
- name: Log in to Azure Container Registry
45+
# Log in to Azure CR with token that can pull the base image (ARACHNE_DOCKER_REGISTRY_TOKEN).
46+
- name: Log in to Azure CR (pull base image)
47+
uses: docker/login-action@v3
48+
with:
49+
registry: executionengine.azurecr.io
50+
username: github-actions-push
51+
password: ${{ secrets.ARACHNE_DOCKER_REGISTRY_TOKEN }}
52+
53+
# Try to pull base image; only build if pull fails (e.g. first run or base not yet published).
54+
- name: Try pull base image
55+
id: pull_base
56+
run: |
57+
BASE_IMAGE="executionengine.azurecr.io/${{ steps.image.outputs.name }}-base:latest"
58+
if docker pull "$BASE_IMAGE"; then
59+
docker tag "$BASE_IMAGE" examplestudy-base:latest
60+
echo "need_build=false" >> $GITHUB_OUTPUT
61+
else
62+
echo "need_build=true" >> $GITHUB_OUTPUT
63+
fi
64+
65+
# Build base image only when it could not be pulled.
66+
- name: Build base image (CI / local load)
67+
if: steps.pull_base.outputs.need_build == 'true'
68+
run: |
69+
docker buildx build \
70+
--load \
71+
--file ./Dockerfile.base \
72+
--tag examplestudy-base:latest \
73+
--cache-from type=gha \
74+
--cache-to type=gha,mode=max \
75+
--platform linux/amd64 \
76+
.
77+
78+
# Re-login to Azure CR with token that can push (for release step).
79+
- name: Log in to Azure Container Registry (push)
4680
uses: docker/login-action@v3
4781
with:
4882
registry: executionengine.azurecr.io
4983
username: github-actions-push
5084
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
5185

86+
# When we built the base locally, push it so future runs can pull it.
87+
- name: Push base image to Azure CR
88+
if: steps.pull_base.outputs.need_build == 'true'
89+
run: |
90+
BASE_REPO="executionengine.azurecr.io/${{ steps.image.outputs.name }}-base:latest"
91+
docker tag examplestudy-base:latest "$BASE_REPO"
92+
docker push "$BASE_REPO"
93+
5294
# Produces tags + labels (commit SHA, semver if you use tags, etc.)
5395
- name: Docker metadata
5496
id: meta
@@ -63,17 +105,17 @@ jobs:
63105
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
64106
org.opencontainers.image.revision=${{ github.sha }}
65107
66-
# 1) CI build (LOAD locally) so we can run tests inside the image.
67-
# Attestations (sbom/provenance) require pushing, so we do that only after tests pass.
68-
# Build is run with --progress=plain and teed to build.log for artifact upload on failure.
69-
- name: Build (CI / local load)
108+
# 1b) Build study image (LOAD) so we can run tests inside it.
109+
# Attestations (sbom/provenance) require pushing, so we do that only after tests pass.
110+
- name: Build study image (CI / local load)
70111
id: build_ci
71112
run: |
72113
set -o pipefail
73114
docker buildx build \
74115
--progress=plain \
75116
--load \
76117
--file ./Dockerfile \
118+
--build-arg BASE_IMAGE=examplestudy-base:latest \
77119
--tag ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:ci-${{ github.sha }} \
78120
--label "org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}" \
79121
--label "org.opencontainers.image.revision=${{ github.sha }}" \
@@ -118,6 +160,7 @@ jobs:
118160
with:
119161
context: .
120162
file: ./Dockerfile
163+
build-args: BASE_IMAGE=examplestudy-base:latest
121164
platforms: linux/amd64
122165
push: true
123166
tags: |

Dockerfile

Lines changed: 9 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,15 @@
1-
# Ubuntu 22.04 (Jammy) · R 4.2 · Dependencies for ExampleStudy
2-
# For Snowflake ODBC use: docker build --platform linux/amd64 ...
3-
FROM rocker/rstudio:4.2
1+
# Study image: prebuilt base + repo + renv::restore().
2+
# Build in two steps:
3+
# 1) Base: docker build -f Dockerfile.base -t examplestudy-base:latest .
4+
# (Optionally push: docker push <registry>/examplestudy-base:latest)
5+
# 2) Study: docker build -t examplestudy:latest .
6+
# (Then sign and push per your CI, e.g. cosign sign, docker push)
7+
ARG BASE_IMAGE=examplestudy-base:latest
8+
FROM ${BASE_IMAGE}
49
LABEL org.opencontainers.image.maintainer="Adam Black <a.black@darwin-eu.org>"
510

6-
# Install java and rJava
7-
RUN apt-get -y update && apt-get install -y \
8-
default-jdk \
9-
r-cran-rjava \
10-
sudo \
11-
&& apt-get clean \
12-
&& rm -rf /var/lib/apt/lists/ \
13-
&& sudo R CMD javareconf
14-
15-
RUN echo 'options(repos = c(CRAN = "https://packagemanager.posit.co/cran/__linux__/jammy/2026-02-01"))' >>"${R_HOME}/etc/Rprofile.site"
16-
RUN install2.r --error rJava && rm -rf /tmp/download_packages/ /tmp/*.rds
17-
RUN install2.r --error DatabaseConnector && rm -rf /tmp/download_packages/ /tmp/*.rds
18-
ENV DATABASECONNECTOR_JAR_FOLDER="/opt/hades/jdbc_drivers"
19-
RUN R -e "DatabaseConnector::downloadJdbcDrivers('all');"
20-
21-
RUN install2.r --error Andromeda && rm -rf /tmp/download_packages/ /tmp/*.rds
22-
RUN install2.r --error RJSONIO && rm -rf /tmp/download_packages/ /tmp/*.rds
23-
RUN install2.r --error CirceR && rm -rf /tmp/download_packages/ /tmp/*.rds
24-
RUN install2.r --error SqlRender && rm -rf /tmp/download_packages/ /tmp/*.rds
25-
RUN install2.r --error renv && rm -rf /tmp/download_packages/ /tmp/*.rds
26-
27-
# Install utility R packages
28-
RUN apt-get -y update && apt-get install -y \
29-
libxml2-dev libssl-dev libcurl4-openssl-dev \
30-
&& apt-get clean \
31-
&& rm -rf /var/lib/apt/lists/
32-
33-
RUN install2.r --error openssl httr xml2 remotes && rm -rf /tmp/download_packages/ /tmp/*.rds
34-
RUN install2.r --error duckdb && rm -rf /tmp/download_packages/ /tmp/*.rds
35-
36-
# Install odbc and RPostgres drivers (unixODBC + dev headers + pkg-config for R odbc package)
37-
# CXX required: R was built without C++ compiler; odbc's configure invokes ${CXX} -E
38-
RUN apt-get -y update && apt-get install -y --install-suggests \
39-
unixodbc unixodbc-dev libpq-dev curl pkg-config build-essential \
40-
&& apt-get clean \
41-
&& rm -rf /var/lib/apt/lists/ \
42-
&& PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig \
43-
CXX=g++ \
44-
install2.r --error RPostgres duckdb odbc \
45-
&& rm -rf /tmp/download_packages/ /tmp/*.rds
46-
47-
# Install Darwin packages (and study Imports: dplyr, ggplot2, shiny, plotly)
48-
RUN install2.r --error \
49-
omopgenerics \
50-
CDMConnector \
51-
IncidencePrevalence \
52-
PatientProfiles \
53-
TreatmentPatterns \
54-
DrugExposureDiagnostics \
55-
DrugUtilisation \
56-
dplyr \
57-
ggplot2 \
58-
shiny \
59-
plotly \
60-
&& rm -rf /tmp/download_packages/ /tmp/*.rds
61-
62-
# GitHub token for installs (pass at build time: docker build --build-arg GITHUB_PAT=xxx)
63-
RUN echo "DATABASECONNECTOR_JAR_FOLDER=/opt/hades/jdbc_drivers" >> /usr/local/lib/R/etc/Renviron
64-
RUN echo "RENV_PATHS_CELLAR=/opt/renv_cellar" >> /usr/local/lib/R/etc/Renviron
65-
66-
# SQL Server odbc
67-
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc > /dev/null
68-
RUN curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
69-
RUN apt-get clean && apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17
70-
71-
# Snowflake odbc
72-
RUN curl -fsSL --output snowflake-odbc-3.1.1.x86_64.deb https://sfc-repo.snowflakecomputing.com/odbc/linux/3.1.1/snowflake-odbc-3.1.1.x86_64.deb
73-
RUN sudo dpkg -i snowflake-odbc-3.1.1.x86_64.deb
74-
75-
RUN install2.r --error here log4r testthat renv \
76-
&& rm -rf /tmp/download_packages/ /tmp/*.rds
77-
78-
RUN echo "EUNOMIA_DATA_FOLDER=/opt/eunomia_data" >> /usr/local/lib/R/etc/Renviron
79-
RUN R -e 'CDMConnector::downloadEunomiaData()'
80-
81-
# Install vim
82-
RUN apt-get -y update && apt-get install -y vim && apt-get clean && rm -rf /var/lib/apt/lists/
83-
84-
# Fix Snowflake odbc lib path
85-
RUN sed -i 's/libodbcinst.so.1/libodbcinst.so.2/g' /usr/lib/snowflake/odbc/lib/simba.snowflake.ini
86-
87-
88-
RUN mkdir /results
89-
90-
# Copy package source into image (for running study and CI tests)
91-
COPY . /code
9211
WORKDIR /code
12+
COPY . /code
9313

9414
# Install R package dependencies from renv.lock
9515
RUN R -e "renv::restore()"

Dockerfile.base

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Base image for ExampleStudy: R 4.2, Java, DB drivers, Darwin R packages, ODBC, etc.
2+
# Build and tag before building the study image, e.g.:
3+
# docker build -f Dockerfile.base -t examplestudy-base:latest .
4+
# For Snowflake ODBC use: docker build -f Dockerfile.base --platform linux/amd64 -t examplestudy-base:latest .
5+
FROM rocker/rstudio:4.2
6+
LABEL org.opencontainers.image.maintainer="Adam Black <a.black@darwin-eu.org>"
7+
8+
# Install java and rJava
9+
RUN apt-get -y update && apt-get install -y \
10+
default-jdk \
11+
r-cran-rjava \
12+
sudo \
13+
&& apt-get clean \
14+
&& rm -rf /var/lib/apt/lists/ \
15+
&& sudo R CMD javareconf
16+
17+
RUN echo 'options(repos = c(CRAN = "https://packagemanager.posit.co/cran/__linux__/jammy/2026-02-01"))' >>"${R_HOME}/etc/Rprofile.site"
18+
RUN install2.r --error rJava && rm -rf /tmp/download_packages/ /tmp/*.rds
19+
RUN install2.r --error DatabaseConnector && rm -rf /tmp/download_packages/ /tmp/*.rds
20+
ENV DATABASECONNECTOR_JAR_FOLDER="/opt/hades/jdbc_drivers"
21+
RUN R -e "DatabaseConnector::downloadJdbcDrivers('all');"
22+
23+
RUN install2.r --error Andromeda && rm -rf /tmp/download_packages/ /tmp/*.rds
24+
RUN install2.r --error RJSONIO && rm -rf /tmp/download_packages/ /tmp/*.rds
25+
RUN install2.r --error CirceR && rm -rf /tmp/download_packages/ /tmp/*.rds
26+
RUN install2.r --error SqlRender && rm -rf /tmp/download_packages/ /tmp/*.rds
27+
RUN install2.r --error renv && rm -rf /tmp/download_packages/ /tmp/*.rds
28+
29+
# Install utility R packages
30+
RUN apt-get -y update && apt-get install -y \
31+
libxml2-dev libssl-dev libcurl4-openssl-dev \
32+
&& apt-get clean \
33+
&& rm -rf /var/lib/apt/lists/
34+
35+
RUN install2.r --error openssl httr xml2 remotes && rm -rf /tmp/download_packages/ /tmp/*.rds
36+
RUN install2.r --error duckdb && rm -rf /tmp/download_packages/ /tmp/*.rds
37+
38+
# Install odbc and RPostgres drivers (unixODBC + dev headers + pkg-config for R odbc package)
39+
# CXX required: R was built without C++ compiler; odbc's configure invokes ${CXX} -E
40+
RUN apt-get -y update && apt-get install -y --install-suggests \
41+
unixodbc unixodbc-dev libpq-dev curl pkg-config build-essential \
42+
&& apt-get clean \
43+
&& rm -rf /var/lib/apt/lists/ \
44+
&& PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig \
45+
CXX=g++ \
46+
install2.r --error RPostgres duckdb odbc \
47+
&& rm -rf /tmp/download_packages/ /tmp/*.rds
48+
49+
# Install Darwin packages (and study Imports: dplyr, ggplot2, shiny, plotly)
50+
RUN install2.r --error \
51+
omopgenerics \
52+
CDMConnector \
53+
IncidencePrevalence \
54+
PatientProfiles \
55+
TreatmentPatterns \
56+
DrugExposureDiagnostics \
57+
DrugUtilisation \
58+
dplyr \
59+
ggplot2 \
60+
shiny \
61+
plotly \
62+
&& rm -rf /tmp/download_packages/ /tmp/*.rds
63+
64+
# GitHub token for installs (pass at build time: docker build --build-arg GITHUB_PAT=xxx)
65+
RUN echo "DATABASECONNECTOR_JAR_FOLDER=/opt/hades/jdbc_drivers" >> /usr/local/lib/R/etc/Renviron
66+
RUN echo "RENV_PATHS_CELLAR=/opt/renv_cellar" >> /usr/local/lib/R/etc/Renviron
67+
68+
# SQL Server odbc
69+
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc > /dev/null
70+
RUN curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
71+
RUN apt-get clean && apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17
72+
73+
# Snowflake odbc
74+
RUN curl -fsSL --output snowflake-odbc-3.1.1.x86_64.deb https://sfc-repo.snowflakecomputing.com/odbc/linux/3.1.1/snowflake-odbc-3.1.1.x86_64.deb
75+
RUN sudo dpkg -i snowflake-odbc-3.1.1.x86_64.deb
76+
77+
RUN install2.r --error here log4r testthat renv \
78+
&& rm -rf /tmp/download_packages/ /tmp/*.rds
79+
80+
RUN echo "EUNOMIA_DATA_FOLDER=/opt/eunomia_data" >> /usr/local/lib/R/etc/Renviron
81+
RUN R -e 'CDMConnector::downloadEunomiaData()'
82+
83+
# Install vim
84+
RUN apt-get -y update && apt-get install -y vim && apt-get clean && rm -rf /var/lib/apt/lists/
85+
86+
# Fix Snowflake odbc lib path
87+
RUN sed -i 's/libodbcinst.so.1/libodbcinst.so.2/g' /usr/lib/snowflake/odbc/lib/simba.snowflake.ini
88+
89+
RUN mkdir /results
90+
91+
CMD ["bash"]

0 commit comments

Comments
 (0)