Skip to content

Commit 28b2432

Browse files
committed
trying to consolidate docker build workflows
1 parent badf46f commit 28b2432

4 files changed

Lines changed: 532 additions & 499 deletions

File tree

.github/workflows/ci.yml

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
name: CI
1+
name: Docker Stack SIPNET
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- develop
8-
tags:
9-
- "v*.*.*"
104
pull_request:
11-
merge_group:
12-
issue_comment:
13-
types:
14-
- created
155
workflow_dispatch:
16-
17-
env:
18-
R_LIBS_USER: /usr/local/lib/R/site-library
19-
LC_ALL: en_US.UTF-8
20-
NCPUS: 2
21-
PGHOST: postgres
22-
CI: true
6+
schedule:
7+
- cron: '30 4 * * 4'
238

249
jobs:
25-
test:
26-
if: github.event_name != 'issue_comment' || startsWith(github.event.comment.body, '/build')
27-
strategy:
28-
fail-fast: false
29-
matrix:
30-
R:
31-
- "4.4"
32-
- "4.2"
33-
uses: ./.github/workflows/test.yml
34-
with:
35-
R-version: ${{ matrix.R }}
36-
secrets: inherit
10+
sipnet:
11+
name: sipnet
12+
runs-on: ubuntu-latest
13+
env:
14+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
15+
steps:
16+
- name: Free Disk Space (Ubuntu)
17+
uses: jlumbroso/free-disk-space@main
18+
with:
19+
tool-cache: false
20+
android: true
21+
dotnet: true
22+
haskell: true
23+
large-packages: true
24+
docker-images: false
25+
swap-storage: true
3726

38-
check:
39-
if: github.event_name != 'issue_comment' || startsWith(github.event.comment.body, '/build')
40-
strategy:
41-
fail-fast: false
42-
matrix:
43-
package: [check_base, check_modules, check_models]
44-
R:
45-
- "4.4"
46-
- "4.2"
47-
uses: ./.github/workflows/check.yml
48-
with:
49-
R-version: ${{ matrix.R }}
50-
make-grouping: ${{ matrix.package }}
51-
secrets: inherit
27+
- name: Checkout source code
28+
uses: actions/checkout@v4
5229

53-
sipnet:
54-
if: github.event_name != 'issue_comment' || startsWith(github.event.comment.body, '/build')
55-
strategy:
56-
fail-fast: false
57-
matrix:
58-
R:
59-
- "4.4"
60-
- "4.2"
61-
uses: ./.github/workflows/sipnet.yml
62-
with:
63-
R-version: ${{ matrix.R }}
64-
secrets: inherit
30+
- name: Set up Docker Compose
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get -y install docker-compose
34+
35+
- name: Prepare override
36+
run: |
37+
cp docker-compose.dev.yml docker-compose.override.yml
38+
sed -i'' '/R_library/d' docker-compose.override.yml
39+
40+
- name: Initialize data volumes
41+
run: |
42+
cp docker/env.example .env
43+
echo "COMPOSE_PROJECT_NAME=pecan" >> .env
44+
echo "PECAN_VERSION=develop" >> .env
45+
echo "UID=$(id -u)" >> .env
46+
echo "GID=$(id -g)" >> .env
47+
docker compose up --wait -d postgres
48+
docker run --rm --network pecan_pecan pecan/db:ci
49+
docker run --rm --network pecan_pecan --volume pecan_pecan:/data --env FQDN=docker pecan/data:develop
50+
docker run --rm --network pecan_pecan --volume pecan_pecan:/data pecan/data:develop chown -R "$(id -u):$(id -g)" /data
51+
docker image rm pecan/db:ci pecan/data:develop || true
52+
53+
- name: Start required services
54+
run: |
55+
docker compose up --wait -d sipnet executor monitor rabbitmq
56+
57+
- name: List running containers
58+
run: |
59+
sleep 50
60+
docker ps
61+
62+
- name: Run SIPNET workflow
63+
run: |
64+
docker compose exec --workdir /pecan/tests executor R CMD ../web/workflow.R --settings docker-ghaction.sipnet.xml
Lines changed: 48 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,64 @@
1-
name: build-image
1+
name: Docker Stack SIPNET
22

33
on:
4-
workflow_call:
5-
inputs:
6-
image-name:
7-
required: true
8-
type: string
9-
build-context:
10-
required: true
11-
type: string
12-
dockerfile:
13-
required: true
14-
type: string
15-
r-version:
16-
required: true
17-
type: string
18-
parent-image:
19-
required: false
20-
default: ''
21-
type: string
22-
model-version:
23-
required: false
24-
default: ''
25-
type: string
26-
platforms:
27-
required: false
28-
default: "linux/amd64"
29-
type: string
30-
secrets:
31-
DOCKERHUB_USERNAME:
32-
description: 'DockerHub username used to push images'
33-
required: false
34-
DOCKERHUB_PASSWORD:
35-
description: 'DockerHub password used to push images'
36-
required: false
37-
38-
env:
39-
DEFAULT_R_VERSION: "4.4"
4+
pull_request:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: '30 4 * * 4'
408

419
jobs:
42-
build:
10+
sipnet:
11+
name: sipnet
4312
runs-on: ubuntu-latest
44-
permissions:
45-
packages: write
46-
13+
env:
14+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
4715
steps:
16+
- name: Free Disk Space (Ubuntu)
17+
uses: jlumbroso/free-disk-space@main
18+
with:
19+
tool-cache: false
20+
android: true
21+
dotnet: true
22+
haskell: true
23+
large-packages: true
24+
docker-images: false
25+
swap-storage: true
4826

49-
- name: lowercase image name
50-
id: name
51-
run: |
52-
echo "image_name=$(echo ${{ inputs.image-name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
53-
echo "repository=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
27+
- name: Checkout source code
28+
uses: actions/checkout@v4
5429

55-
- name: set PARENT_IMAGE only if specified
56-
id: parent
57-
shell: bash
30+
- name: Set up Docker Compose
5831
run: |
59-
echo "PARENT_IMAGE_IF_SET=$(
60-
[[ -n '${{ inputs.parent-image }}' ]] &&
61-
echo "PARENT_IMAGE=ghcr.io/${{ steps.name.outputs.repository }}/"'${{ inputs.parent-image }}'
62-
)" >> $GITHUB_OUTPUT
32+
sudo apt-get update
33+
sudo apt-get -y install docker-compose
6334
64-
- name: set MODEL_VERSION only if specified
65-
id: modelver
66-
shell: bash
35+
- name: Prepare override
6736
run: |
68-
echo "MODEL_VERSION_IF_SET=$(
69-
[[ -n '${{ inputs.model-version }}' ]] &&
70-
echo 'MODEL_VERSION=${{ inputs.model-version }}'
71-
)" >> $GITHUB_OUTPUT
72-
73-
- uses: actions/checkout@v4
74-
75-
# create metadata for image
76-
- name: Docker meta
77-
env:
78-
check_var: ${{ secrets.DOCKERHUB_USERNAME }}
79-
is_default_R: ${{ inputs.r-version == env.DEFAULT_R_VERSION }}
80-
id: meta
81-
uses: docker/metadata-action@v5
82-
with:
83-
# list of Docker images to use as base name for tags
84-
images: |
85-
name=ghcr.io/${{ steps.name.outputs.repository }}/${{ steps.name.outputs.image_name }}
86-
name=pecan/${{ steps.name.outputs.image_name }},enable=${{ env.check_var != null }}
87-
# generate Docker tags based on the following events/attributes
88-
tags: |
89-
type=schedule
90-
type=ref,event=branch,enable=${{ env.is_default_R }}
91-
type=ref,event=branch,suffix=-R${{ inputs.r-version }}
92-
type=ref,event=pr
93-
type=semver,pattern={{version}},enable=${{ env.is_default_R }}
94-
type=semver,pattern={{major}}.{{minor}},enable=${{ env.is_default_R }}
95-
type=semver,pattern={{major}},enable=${{ env.is_default_R }}
96-
type=semver,pattern={{version}},suffix=-R${{ inputs.r-version }}
97-
98-
# setup docker build
99-
- name: Set up QEMU
100-
uses: docker/setup-qemu-action@v3
37+
cp docker-compose.dev.yml docker-compose.override.yml
38+
sed -i'' '/R_library/d' docker-compose.override.yml
10139
102-
- name: Set up Docker Buildx
103-
id: buildx
104-
uses: docker/setup-buildx-action@v3
105-
106-
- name: Inspect Builder
40+
- name: Initialize data volumes
10741
run: |
108-
echo "Name: ${{ steps.buildx.outputs.name }}"
109-
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
110-
echo "Status: ${{ steps.buildx.outputs.status }}"
111-
echo "Flags: ${{ steps.buildx.outputs.flags }}"
112-
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
42+
cp docker/env.example .env
43+
echo "COMPOSE_PROJECT_NAME=pecan" >> .env
44+
echo "PECAN_VERSION=develop" >> .env
45+
echo "UID=$(id -u)" >> .env
46+
echo "GID=$(id -g)" >> .env
47+
docker compose up --wait -d postgres
48+
docker run --rm --network pecan_pecan pecan/db:ci
49+
docker run --rm --network pecan_pecan --volume pecan_pecan:/data --env FQDN=docker pecan/data:develop
50+
docker run --rm --network pecan_pecan --volume pecan_pecan:/data pecan/data:develop chown -R "$(id -u):$(id -g)" /data
51+
docker image rm pecan/db:ci pecan/data:develop || true
11352
114-
# login to registries
115-
- name: Login to DockerHub
116-
env:
117-
check_var: ${{ secrets.DOCKERHUB_USERNAME }}
118-
if: env.check_var != null
119-
uses: docker/login-action@v3
120-
with:
121-
username: ${{ secrets.DOCKERHUB_USERNAME }}
122-
password: ${{ secrets.DOCKERHUB_PASSWORD }}
53+
- name: Start required services
54+
run: |
55+
docker compose up --wait -d sipnet executor monitor rabbitmq
12356
124-
- name: Login to GitHub Container Registry
125-
uses: docker/login-action@v3
126-
with:
127-
registry: ghcr.io
128-
username: ${{ github.repository_owner }}
129-
password: ${{ secrets.GITHUB_TOKEN }}
57+
- name: List running containers
58+
run: |
59+
sleep 50
60+
docker ps
13061
131-
# build the docker images
132-
- name: Build and push ${{ steps.name.outputs.image_name }}
133-
uses: docker/build-push-action@v6
134-
with:
135-
context: ${{ inputs.build-context }}
136-
file: ${{ inputs.dockerfile }}
137-
push: true
138-
platforms: ${{ inputs.platforms }}
139-
cache-from: type=gha
140-
cache-to: type=gha,mode=max
141-
tags: ${{ steps.meta.outputs.tags }}
142-
labels: ${{ steps.meta.outputs.labels }}
143-
build-args: |
144-
VERSION=${{ steps.meta.outputs.version }}
145-
IMAGE_VERSION=${{ steps.meta.outputs.version }}
146-
PECAN_VERSION=${{ steps.meta.outputs.version }}
147-
R_VERSION=${{ inputs.r-version }}
148-
${{ steps.parent.outputs.PARENT_IMAGE_IF_SET }}
149-
${{ steps.modelver.outputs.MODEL_VERSION_IF_SET }}
150-
GITHUB_PAT=${{ secrets.GITHUB_TOKEN }}
151-
PECAN_GIT_BRANCH=${{ github.head_ref || github.ref_name }}
152-
PECAN_GIT_CHECKSUM=${{ github.sha }}
153-
PECAN_GIT_DATE=${{ github.event.repository.updated_at }}
62+
- name: Run SIPNET workflow
63+
run: |
64+
docker compose exec --workdir /pecan/tests executor R CMD ../web/workflow.R --settings docker-ghaction.sipnet.xml

0 commit comments

Comments
 (0)