Skip to content

Commit 2ce7ab2

Browse files
committed
added github workflow for dockerhub publishing
1 parent 5d69317 commit 2ce7ab2

2 files changed

Lines changed: 70 additions & 12 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and Push to Docker Hub
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build-and-push:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
# 1. Set up Docker Buildx (required for GHA caching)
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
20+
# 2. Login to Docker Hub using Organization Secret
21+
- name: Login to Docker Hub
22+
uses: docker/login-action@v3
23+
with:
24+
username: ${{ secrets.DOCKERHUB_USERNAME }}
25+
password: ${{ secrets.DOCKERHUB_API_KEY }}
26+
27+
# 3. Extract metadata (Tags/Labels) for Docker
28+
- name: Extract metadata
29+
id: meta
30+
uses: docker/metadata-action@v5
31+
with:
32+
images: ${{ secrets.DOCKERHUB_USERNAME }}/3podr_container
33+
tags: |
34+
type=ref,event=branch
35+
type=sha,format=short
36+
latest
37+
38+
# 4. Build and Push with GHA Cache
39+
- name: Build and push
40+
uses: docker/build-push-action@v5
41+
with:
42+
context: .
43+
push: true
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}
46+
# Magic for GitHub Actions speed:
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
1-
# 1. Use r-ver for native Apple Silicon (ARM64) support
1+
# 1. Use r-ver (Works on Mac ARM64 and GitHub AMD64)
22
FROM rocker/r-ver:latest
33

4-
# 2. Install system dependencies + Pandoc (Critical for RMarkdown)
5-
RUN apt-get update && apt-get install -y \
4+
# 2. Install system dependencies + Pandoc
5+
# Added image libraries (libpng, libjpeg) and string processing (libicu)
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
67
libxml2-dev \
78
libssl-dev \
9+
libcurl4-openssl-dev \
10+
libpng-dev \
11+
libjpeg-dev \
12+
zlib1g-dev \
13+
libicu-dev \
814
pandoc \
915
&& rm -rf /var/lib/apt/lists/*
1016

1117
WORKDIR /project
1218

13-
# 3. Setup renv files
19+
# 3. FORCE BINARIES & PARALLELISM
20+
ENV RENV_CONFIG_REPOS_OVERRIDE="https://packagemanager.posit.co/cran/__linux__/jammy/latest"
21+
ENV RENV_DOWNLOAD_METHOD="libcurl"
22+
ENV RENV_PATHS_LIBRARY="renv/library"
23+
24+
# 4. Setup renv files
1425
COPY renv.lock .Rprofile ./
1526
COPY renv/activate.R renv/activate.R
16-
RUN mkdir -p renv library data
27+
# Pre-create the library folder
28+
RUN mkdir -p renv/library data
1729

18-
# 4. SPEED BOOST:
19-
# - Use 'jammy' binaries (pre-compiled for the container's Ubuntu base)
20-
# - Use all CPU cores (Ncpus) to install 200+ packages in parallel
21-
RUN R -e "options(repos = c(CRAN = 'https://packagemanager.posit.co/cran/__linux__/jammy/latest'), Ncpus = parallel::detectCores()); renv::restore()"
30+
# 5. Restore using all available CPU cores
31+
# This will now find the 'png.h' header it needs for the 'png' package
32+
RUN R -e "options(Ncpus = parallel::detectCores()); renv::restore()"
2233

23-
# 5. Copy your Rmd files and site configuration
24-
# Use a wildcard for _site.yml so it doesn't crash if the file is missing
34+
# 6. Copy project assets
2535
COPY *.Rmd ./
2636
COPY _site.ym[l] ./
2737

28-
# 6. Render the site
38+
# 7. Render
2939
CMD ["R", "-e", "rmarkdown::render_site()"]

0 commit comments

Comments
 (0)