Skip to content

Commit 0efc204

Browse files
committed
perf: added caching for Docker images to GitHub action
1 parent 70f2c7f commit 0efc204

File tree

1 file changed

+65
-55
lines changed

1 file changed

+65
-55
lines changed

.github/workflows/ci.yml

+65-55
Original file line numberDiff line numberDiff line change
@@ -156,62 +156,72 @@ jobs:
156156
echo "::set-output name=netpyneVersion::${NETPYNE_VERSION}"
157157
echo "::set-output name=brian2Version::${BRIAN2_VERSION}"
158158
159-
- name: Build Docker images
160-
run: |
161-
REVISION=$(git rev-parse HEAD)
162-
CREATED=$(date --rfc-3339=seconds | sed 's/ /T/')
163-
164-
if [ -z "${{ github.event.inputs.simulator }}" ] || [ "${{ github.event.inputs.simulator }}" == "pyneuroml" ]; then
165-
docker build \
166-
--label org.opencontainers.image.source=https://github.com/${{ github.repository }} \
167-
--label org.opencontainers.image.revision=${REVISION} \
168-
--label org.opencontainers.image.created=${CREATED} \
169-
--build-arg VERSION=${{ steps.get-version-number.outputs.version }} \
170-
--build-arg SIMULATOR_VERSION=${{ steps.get-docker-image-tag.outputs.pyneuromlVersion }} \
171-
--tag ghcr.io/biosimulators/biosimulators_pyneuroml/pyneuroml:${{ steps.get-docker-image-tag.outputs.pyneuromlVersion }} \
172-
--tag ghcr.io/biosimulators/biosimulators_pyneuroml/pyneuroml:latest \
173-
-f Dockerfile-pyneuroml \
174-
.
175-
fi
159+
echo "::set-output name=revision::${REVISION}"
160+
echo "::set-output name=created::${CREATED}"
176161
177-
if [ -z "${{ github.event.inputs.simulator }}" ] || [ "${{ github.event.inputs.simulator }}" == "neuron" ]; then
178-
docker build \
179-
--label org.opencontainers.image.source=https://github.com/${{ github.repository }} \
180-
--label org.opencontainers.image.revision=${REVISION} \
181-
--label org.opencontainers.image.created=${CREATED} \
182-
--build-arg VERSION=${{ steps.get-version-number.outputs.version }} \
183-
--build-arg SIMULATOR_VERSION=${{ steps.get-docker-image-tag.outputs.neuronVersion }} \
184-
--tag ghcr.io/biosimulators/biosimulators_pyneuroml/neuron:${{ steps.get-docker-image-tag.outputs.neuronVersion }} \
185-
--tag ghcr.io/biosimulators/biosimulators_pyneuroml/neuron:latest \
186-
-f Dockerfile-neuron \
187-
.
188-
fi
189-
190-
if [ -z "${{ github.event.inputs.simulator }}" ] || [ "${{ github.event.inputs.simulator }}" == "netpyne" ]; then
191-
docker build \
192-
--label org.opencontainers.image.source=https://github.com/${{ github.repository }} \
193-
--label org.opencontainers.image.revision=${REVISION} \
194-
--label org.opencontainers.image.created=${CREATED} \
195-
--build-arg VERSION=${{ steps.get-version-number.outputs.version }} \
196-
--build-arg SIMULATOR_VERSION=${{ steps.get-docker-image-tag.outputs.netpyneVersion }} \
197-
--tag ghcr.io/biosimulators/biosimulators_pyneuroml/netpyne:${{ steps.get-docker-image-tag.outputs.netpyneVersion }} \
198-
--tag ghcr.io/biosimulators/biosimulators_pyneuroml/netpyne:latest \
199-
-f Dockerfile-netpyne \
200-
.
201-
fi
202-
203-
if [ -z "${{ github.event.inputs.simulator }}" ] || [ "${{ github.event.inputs.simulator }}" == "brian2" ]; then
204-
docker build \
205-
--label org.opencontainers.image.source=https://github.com/${{ github.repository }} \
206-
--label org.opencontainers.image.revision=${REVISION} \
207-
--label org.opencontainers.image.created=${CREATED} \
208-
--build-arg VERSION=${{ steps.get-version-number.outputs.version }} \
209-
--build-arg SIMULATOR_VERSION=${{ steps.get-docker-image-tag.outputs.brian2Version }} \
210-
--tag ghcr.io/biosimulators/biosimulators_pyneuroml/brian2:${{ steps.get-docker-image-tag.outputs.brian2Version }} \
211-
--tag ghcr.io/biosimulators/biosimulators_pyneuroml/brian2:latest \
212-
-f Dockerfile-brian2 \
213-
.
214-
fi
162+
- name: Build pyNeuroML Docker image
163+
uses: whoan/docker-build-with-cache-action@v5
164+
if: github.event.inputs.simulator || github.event.inputs.simulator == 'pyneuroml'
165+
with:
166+
dockerfile: Dockerfile-pyneuroml
167+
build_extra_args: "--compress=true --label org.opencontainers.image.revision=${{steps.get-docker-image-tag.outputs.revision}} --label org.opencontainers.image.created=${{steps.get-docker-image-tag.outputs.created}}"
168+
registry: ghcr.io
169+
image_name: biosimulators/biosimulators_pyneuroml/pyneuroml
170+
image_tag: ${{ github.sha }}
171+
push_image_and_stages: true
172+
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
173+
password: "${{ secrets.DOCKER_REGISTRY_TOKEN }}"
174+
175+
- name: Build NEURON Docker image
176+
uses: whoan/docker-build-with-cache-action@v5
177+
if: github.event.inputs.simulator || github.event.inputs.simulator == 'neuron'
178+
with:
179+
dockerfile: Dockerfile-neuron
180+
build_extra_args: "--compress=true --label org.opencontainers.image.revision=${{steps.get-docker-image-tag.outputs.revision}} --label org.opencontainers.image.created=${{steps.get-docker-image-tag.outputs.created}}"
181+
registry: ghcr.io
182+
image_name: biosimulators/biosimulators_pyneuroml/neuron
183+
image_tag: ${{ github.sha }}
184+
push_image_and_stages: true
185+
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
186+
password: "${{ secrets.DOCKER_REGISTRY_TOKEN }}"
187+
188+
- name: Build NetPyNe Docker image
189+
uses: whoan/docker-build-with-cache-action@v5
190+
if: github.event.inputs.simulator || github.event.inputs.simulator == 'netpyne'
191+
with:
192+
dockerfile: Dockerfile-netpyne
193+
build_extra_args: "--compress=true --label org.opencontainers.image.revision=${{steps.get-docker-image-tag.outputs.revision}} --label org.opencontainers.image.created=${{steps.get-docker-image-tag.outputs.created}}"
194+
registry: ghcr.io
195+
image_name: biosimulators/biosimulators_pyneuroml/netpyne
196+
image_tag: ${{ github.sha }}
197+
push_image_and_stages: true
198+
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
199+
password: "${{ secrets.DOCKER_REGISTRY_TOKEN }}"
200+
201+
- name: Build Brian 2 Docker image
202+
uses: whoan/docker-build-with-cache-action@v5
203+
if: github.event.inputs.simulator || github.event.inputs.simulator == 'brian2'
204+
with:
205+
dockerfile: Dockerfile-brian2
206+
build_extra_args: "--compress=true --label org.opencontainers.image.revision=${{steps.get-docker-image-tag.outputs.revision}} --label org.opencontainers.image.created=${{steps.get-docker-image-tag.outputs.created}}"
207+
registry: ghcr.io
208+
image_name: biosimulators/biosimulators_pyneuroml/brian2
209+
image_tag: ${{ github.sha }}
210+
push_image_and_stages: true
211+
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
212+
password: "${{ secrets.DOCKER_REGISTRY_TOKEN }}"
213+
214+
- name: Label Docker images
215+
run: |
216+
docker image label ghcr.io/biosimulators/biosimulators_pyneuroml/pyneuroml:${{ github.sha }} ghcr.io/biosimulators/biosimulators_pyneuroml/pyneuroml:${{ steps.get-docker-image-tag.outputs.pyneuromlVersion }}
217+
docker image label ghcr.io/biosimulators/biosimulators_pyneuroml/neuron:${{ github.sha }} ghcr.io/biosimulators/biosimulators_pyneuroml/neuron:${{ steps.get-docker-image-tag.outputs.neuronVersion }}
218+
docker image label ghcr.io/biosimulators/biosimulators_pyneuroml/netpyne:${{ github.sha }} ghcr.io/biosimulators/biosimulators_pyneuroml/netpyne:${{ steps.get-docker-image-tag.outputs.netpyneVersion }}
219+
docker image label ghcr.io/biosimulators/biosimulators_pyneuroml/brian2:${{ github.sha }} ghcr.io/biosimulators/biosimulators_pyneuroml/brian2:${{ steps.get-docker-image-tag.outputs.brian2Version }}
220+
221+
docker image label ghcr.io/biosimulators/biosimulators_pyneuroml/pyneuroml:${{ github.sha }} ghcr.io/biosimulators/biosimulators_pyneuroml/pyneuroml:latest
222+
docker image label ghcr.io/biosimulators/biosimulators_pyneuroml/neuron:${{ github.sha }} ghcr.io/biosimulators/biosimulators_pyneuroml/neuron:latest
223+
docker image label ghcr.io/biosimulators/biosimulators_pyneuroml/netpyne:${{ github.sha }} ghcr.io/biosimulators/biosimulators_pyneuroml/netpyne:latest
224+
docker image label ghcr.io/biosimulators/biosimulators_pyneuroml/brian2:${{ github.sha }} ghcr.io/biosimulators/biosimulators_pyneuroml/brian2:latest
215225
216226
#############################################
217227
## Test and upload coverage report to Codecov

0 commit comments

Comments
 (0)