Skip to content

Commit

Permalink
chore: Add Docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Dec 20, 2023
1 parent d5fb6d5 commit efef4a6
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
^vscode-.*build$
^\.aviator/config\.yml$
^windows$
^Dockerfile$
^docker-compose\.yml$
58 changes: 58 additions & 0 deletions .github/workflows/ghcr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Create and publish a Docker image

on:
push:
branches:
- main
schedule:
- cron: "0 1 * * *"
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

- name: Log in to the Container registry
uses: docker/login-action@1f401f745bf57e30b3a2800ad308a87d2ebdf14b
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/setup-buildx-action@3762d454f382a89982d79f33e1ff246835322c4d

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@62339db73c56dd749060f65a6ebb93a6e056b755
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@fdf7f43ecf7c1a5c7afe936410233728a8c2d9c2
with:
context: .
cache-from: ${{ github.event_name != 'schedule' && 'type=gha' || '' }}
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ghcr.io/cynkra/rig-ubuntu:main

RUN apt-get update && apt-get install -y gnupg lsb-release time postgresql-client

RUN mkdir -p /root/workspace

COPY DESCRIPTION /root/workspace

RUN R -q -e 'pak::pak()'
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See .github/CONTRIBUTING.md for details.

version: '3'
volumes:
postgres-socket:
driver: local

services:
# https://geshan.com.np/blog/2021/12/docker-postgres/
# https://community.home-assistant.io/t/timescaledb-postgres-using-a-unix-socket-in-docker-compose-as-ha-database/247136/2
postgres:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: root
volumes:
- postgres-socket:/var/run/postgresql
ports:
- "5432:5432"

workspace:
container_name: workspace
image: ghcr.io/r-dbi/RPostgres:main
platform: linux/amd64
environment:
TESTTHAT_CPUS: 4
volumes:
- ${PWD}:/root/workspace
- postgres-socket:/var/run/postgresql

0 comments on commit efef4a6

Please sign in to comment.