-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from mrc-ide/mrc-5146-container-gh-actions
Mrc 5146 container gh actions
- Loading branch information
Showing
25 changed files
with
351 additions
and
92 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: Build-and-push | ||
|
||
env: | ||
TAG_DH: mrcide/orderly.runner | ||
TAG_GHCR: mrc-ide/orderly.runner | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
# Shorter timeout to prevent mac builders hanging for 6 hours! | ||
timeout-minutes: 30 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- id: ci-env | ||
name: Setup Environment | ||
shell: bash | ||
run: | | ||
if [ "${{github.event_name}}" = "pull_request" ]; | ||
then | ||
long_sha=${{ github.event.pull_request.head.sha }} | ||
echo "CI_BRANCH=${{ github.head_ref }}" >> $GITHUB_OUTPUT | ||
else | ||
long_sha=${GITHUB_SHA} | ||
echo "CI_BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT | ||
fi | ||
echo "CI_SHA=${long_sha:0:7}" >> $GITHUB_OUTPUT | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to GHCR (GitHub Packages) | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ env.GITHUB_PAT }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
file: ./docker/Dockerfile | ||
tags: | | ||
${{env.TAG_DH}}:${{steps.ci-env.outputs.CI_SHA}} | ||
${{env.TAG_DH}}:${{steps.ci-env.outputs.CI_BRANCH}} | ||
ghcr.io/${{env.TAG_GHCR}}:${{steps.ci-env.outputs.CI_SHA}} | ||
ghcr.io/${{env.TAG_GHCR}}:${{steps.ci-env.outputs.CI_BRANCH}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,47 @@ | ||
parse_main <- function(args = commandArgs(TRUE)) { | ||
usage <- "Usage: | ||
orderly.runner [options] <path> | ||
orderly.runner.server [options] <path> | ||
Options: | ||
--log-level=LEVEL Log-level (off, info, all) [default: info] | ||
--validate Enable json schema validation | ||
--host=HOST Host to run api on [default: 0.0.0.0] | ||
--port=PORT Port to run api on [default: 8001]" | ||
dat <- docopt::docopt(usage, args) | ||
list(log_level = dat$log_level, | ||
validate = dat$validate, | ||
port = as.integer(dat$port), | ||
path = dat$path) | ||
path = dat$path, | ||
host = dat$host) | ||
} | ||
|
||
|
||
main <- function(args = commandArgs(TRUE)) { | ||
dat <- parse_main(args) | ||
api(dat$path, dat$validate, dat$log_level)$run("0.0.0.0", port = dat$port) | ||
api_obj <- api(dat$path, dat$validate, dat$log_level) | ||
api_obj$run(host = dat$host, port = dat$port) | ||
} | ||
|
||
|
||
parse_main_worker <- function(args = commandArgs(TRUE)) { | ||
usage <- "Usage: | ||
orderly.runner.worker <path>" | ||
dat <- docopt::docopt(usage, args) | ||
list(path = dat$path) | ||
} | ||
|
||
main_worker <- function(args = commandArgs(TRUE)) { | ||
dat <- parse_main_worker(args) | ||
|
||
# assumes ORDERLY_RUNNER_QUEUE_ID is set | ||
queue <- Queue$new(dat$path) | ||
|
||
worker <- rrq::rrq_worker$new( | ||
queue$controller$queue_id, | ||
con = queue$controller$con | ||
) | ||
worker_path <- file.path(dat$path, ".packit", "workers", worker$id) | ||
fs::dir_create(worker_path) | ||
gert::git_clone(dat$path, path = worker_path) | ||
|
||
worker$loop() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env Rscript | ||
orderly.runner:::main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env Rscript | ||
orderly.runner:::main_worker() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
test-repo | ||
orderly-root-volume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
HERE=$(dirname $0) | ||
|
||
. $HERE/common | ||
|
||
docker rm -f \ | ||
$REDIS \ | ||
$SERVER \ | ||
$WORKER \ | ||
$DEBUG | ||
|
||
docker network rm $NETWORK | ||
|
||
docker volume rm $ORDERLY_VOLUME | ||
|
||
rm -rf $HERE/test-repo | ||
rm -rf $HERE/orderly-root-volume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -exu | ||
|
||
export CONTAINER_NAMESPACE=orderly.runner | ||
|
||
export NETWORK=$CONTAINER_NAMESPACE-network | ||
export REDIS=$CONTAINER_NAMESPACE-redis | ||
export DEBUG=$CONTAINER_NAMESPACE-debug | ||
export SERVER=$CONTAINER_NAMESPACE-server | ||
export WORKER=$CONTAINER_NAMESPACE-worker | ||
|
||
export ORDERLY_RUNNER_QUEUE_ID=orderly.runner.queue | ||
|
||
export ORDERLY_VOLUME=$CONTAINER_NAMESPACE-orderly-root | ||
|
||
export ORDERLY_RUNNER_IMAGE=ghcr.io/mrc-ide/orderly.runner:main | ||
|
||
export CONTAINER_ORDERLY_ROOT_PATH=/orderly-root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
HERE=$(dirname $0) | ||
|
||
. $HERE/common | ||
|
||
rm -rf $HERE/orderly-root-volume | ||
mkdir -p $HERE/orderly-root-volume | ||
|
||
docker cp $DEBUG:$CONTAINER_ORDERLY_ROOT_PATH/. $HERE/orderly-root-volume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
data <- list(a = c(1, 2)) | ||
write.csv(data, "data.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
orderly2::orderly_parameters(a = NULL) | ||
data <- list(a = a) | ||
write.csv(data, "parameters.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
set -exu | ||
HERE=$(dirname $0) | ||
ABSOLUTE_PATH=$(realpath $HERE) | ||
|
||
. $HERE/common | ||
|
||
$HERE/setup-test-repo | ||
|
||
docker network create $NETWORK | ||
|
||
docker run --rm -d \ | ||
--net=$NETWORK \ | ||
--name=$REDIS \ | ||
-p 127.0.0.1:6379:6379 \ | ||
redis | ||
|
||
docker volume create $ORDERLY_VOLUME | ||
|
||
docker run --rm -d --pull=missing \ | ||
--name=$DEBUG \ | ||
-v $ORDERLY_VOLUME:$CONTAINER_ORDERLY_ROOT_PATH \ | ||
ubuntu \ | ||
sleep infinity | ||
|
||
docker cp $ABSOLUTE_PATH/test-repo/. $DEBUG:$CONTAINER_ORDERLY_ROOT_PATH | ||
|
||
docker run --rm -d --pull=always \ | ||
--net=$NETWORK \ | ||
--name=$SERVER \ | ||
--entrypoint="/usr/local/bin/orderly.runner.server" \ | ||
--env=ORDERLY_RUNNER_QUEUE_ID=$ORDERLY_RUNNER_QUEUE_ID \ | ||
--env=REDIS_CONTAINER_NAME=$REDIS \ | ||
-p 127.0.0.1:8001:8001 \ | ||
-v $ORDERLY_VOLUME:$CONTAINER_ORDERLY_ROOT_PATH \ | ||
$ORDERLY_RUNNER_IMAGE \ | ||
$CONTAINER_ORDERLY_ROOT_PATH | ||
|
||
docker run --rm -d --pull=always \ | ||
--net=$NETWORK \ | ||
--name=$WORKER \ | ||
--entrypoint="/usr/local/bin/orderly.runner.worker" \ | ||
--env=ORDERLY_RUNNER_QUEUE_ID=$ORDERLY_RUNNER_QUEUE_ID \ | ||
--env=REDIS_CONTAINER_NAME=$REDIS \ | ||
-v $ORDERLY_VOLUME:$CONTAINER_ORDERLY_ROOT_PATH \ | ||
$ORDERLY_RUNNER_IMAGE \ | ||
$CONTAINER_ORDERLY_ROOT_PATH |
Oops, something went wrong.