Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker container for repro-book #35

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .docker/repro-book/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM lnnrtwttkhn/quarto-docker:latest

ENV RENV_CONFIG_AUTOLOADER_ENABLED FALSE
ENV RENV_AUTOLOAD_ENABLED FALSE

ENV RENV_VERSION v1.0.11
RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"

COPY renv.lock renv.lock

RUN mkdir -p renv
COPY .Rprofile .Rprofile
COPY renv/activate.R renv/activate.R
COPY renv/settings.json renv/settings.json

RUN R -e "renv::restore()"
45 changes: 45 additions & 0 deletions .github/workflows/docker-repro-book.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Push Docker Image for Repro Book

on:
push:
paths:
- 'renv.lock'
- '.docker/repro-book/Dockerfile'
- '.github/workflows/docker-repro-book.yml'
workflow_dispatch: # allows manual trigger

jobs:
build:
runs-on: ubuntu-latest

env:
IMAGE_NAME: lnnrtwttkhn/repro-book

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Ensure the full history is fetched so the commit hash is available

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Get short commit hash
id: vars
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Build Docker image
run: |
docker build -f .docker/repro-book/Dockerfile -t $IMAGE_NAME:${{ steps.vars.outputs.hash }} .

- name: Push Docker image
run: |
docker push $IMAGE_NAME:${{ steps.vars.outputs.hash }}
docker tag $IMAGE_NAME:${{ steps.vars.outputs.hash }} $IMAGE_NAME:latest
docker push $IMAGE_NAME:latest
46 changes: 46 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Render and Deploy Quarto Site

on:
push:
branches:
- main
- docker
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write

env:
IMAGE_NAME: lnnrtwttkhn/repro-book

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Pull Quarto Docker image
run: |
docker pull $IMAGE_NAME:latest

- name: Render Quarto website
run: |
docker run --rm -v ${{ github.workspace }}:/workspace $IMAGE_NAME:latest \
quarto render /workspace

- name: Deploy to GitHub Pages
if: ${{ success() }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_book
publish_branch: gh-pages
allow_empty_commit: true
keep_files: true
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
IMAGES_URL=https://cloud.uni-hamburg.de/s/pzEHT5DF3PzFdLH/download
IMAGES_ARCHIVE=repro-book-images.zip
IMAGES_DIR=images/
DOCKER_NAME=lnnrtwttkhn/repro-book

all: render

Expand Down Expand Up @@ -28,4 +29,20 @@ images:

.PHONY: clean
clean:
rm -rf $(IMAGES_DIR)* _book/
rm -rf $(IMAGES_DIR)* _book/

.PHONY: docker-build
docker-build:
docker build --platform linux/amd64 -f .docker/repro-book/Dockerfile -t $(DOCKER_NAME):latest .

.PHONY: docker-push
docker-push:
docker push $(DOCKER_NAME):latest

.PHONY: docker-run
docker-run:
docker run --rm -it -v $(CURDIR):/workspace $(DOCKER_NAME):latest

.PHONY: docker-render
docker-render:
docker run --rm -v $(CURDIR):/workspace $(DOCKER_NAME):latest quarto render /workspace
Loading