|
1 | | -name: build-image |
| 1 | +name: Docker Stack SIPNET |
2 | 2 |
|
3 | 3 | 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' |
40 | 8 |
|
41 | 9 | jobs: |
42 | | - build: |
| 10 | + sipnet: |
| 11 | + name: sipnet |
43 | 12 | runs-on: ubuntu-latest |
44 | | - permissions: |
45 | | - packages: write |
46 | | - |
| 13 | + env: |
| 14 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
47 | 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 |
48 | 26 |
|
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 |
54 | 29 |
|
55 | | - - name: set PARENT_IMAGE only if specified |
56 | | - id: parent |
57 | | - shell: bash |
| 30 | + - name: Set up Docker Compose |
58 | 31 | 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 |
63 | 34 |
|
64 | | - - name: set MODEL_VERSION only if specified |
65 | | - id: modelver |
66 | | - shell: bash |
| 35 | + - name: Prepare override |
67 | 36 | 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 |
101 | 39 |
|
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 |
107 | 41 | 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 |
113 | 52 |
|
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 |
123 | 56 |
|
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 |
130 | 61 |
|
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