Skip to content

Commit

Permalink
Merge pull request #26 from alec-pinson/workflow
Browse files Browse the repository at this point in the history
Setup workflow for building & publishing docker image
  • Loading branch information
alec-pinson authored Nov 18, 2021
2 parents 0c26905 + 9bf6088 commit 0f4b2f7
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 4 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Runs on PR or Release and only if Dockerfile exists and not docs being updated
name: docker build & publish

on:
push:
branches:
- 'master'
tags:
paths-ignore:
- 'docs/**'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Check Dockerfile exists
id: dockerfile
uses: andstor/file-existence-action@v1
with:
files: "Dockerfile"
-
name: Set up QEMU
if: steps.Dockerfile.outputs.files_exists == 'true'
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: arm
-
name: Set up Docker Buildx
if: steps.Dockerfile.outputs.files_exists == 'true'
uses: docker/setup-buildx-action@v1
-
name: Docker meta
if: steps.Dockerfile.outputs.files_exists == 'true'
id: meta
uses: docker/metadata-action@v3
with:
images: theyosh/terrariumpi
-
name: Login to DockerHub
if: steps.Dockerfile.outputs.files_exists == 'true'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
if: steps.Dockerfile.outputs.files_exists == 'true'
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/arm/v7
cache-from: type=gha
cache-to: type=gha,mode=max
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ RUN sed -i 's/cryptography/cryptography==3.4.6/g' requirements.txt && \
echo "numpy" >> requirements.txt && \
pip install -r requirements.txt
WORKDIR /TerrariumPI
COPY .git .git
RUN git submodule init && \
git submodule update && \
rm -rf .git
# we previously copied .git and then did git submodule init and submodule update, however as .git dir changes all the time it invalidates docker cache
RUN mkdir 3rdparty && cd 3rdparty && \
git clone https://github.com/SequentMicrosystems/4relay-rpi.git && git -C "4relay-rpi" checkout "09a44bfbde18791750534ba204e1dfc7506a7eb2" && \
git clone https://github.com/PiSupply/Bright-Pi.git && git -C "Bright-Pi" checkout "eccfbbb1221c4966cd337126bedcbb8bb03c3c71" && \
git clone https://github.com/ageir/chirp-rpi.git && git -C "chirp-rpi" checkout "6e411d6c382d5e43ee1fd269ec4de6a316893407" && \
git clone https://github.com/perryflynn/energenie-connect0r.git && git -C "energenie-connect0r" checkout "12ca24ab9d60cf4ede331de9a6817c3d64227ea0" && \
git clone https://github.com/SequentMicrosystems/relay8-rpi.git && git -C "relay8-rpi" checkout "5083730e415ee91fa4785e228f02a36e8bbaa717"
RUN mkdir -p static/assets/plguins && cd static/assets/plguins && \
git clone https://github.com/fancyapps/fancybox.git && git -C "fancybox" checkout "eea1345256ded510ed9fae1e415aec2a7bb9620d" && \
git clone https://github.com/mapshakers/leaflet-icon-pulse.git && git -C "leaflet-icon-pulse" checkout "f57da1e45f6d00f340f429a75a39324cad141061" && \
git clone https://github.com/ebrelsford/Leaflet.loading.git && git -C "Leaflet.loading" checkout "7b22aff19a5a8fa9534fb2dcd48e06c6dc84b2ed"

# remove git dir from code copy to help keep image smaller
FROM python:3.8.0 as remove_git_dir
Expand Down

0 comments on commit 0f4b2f7

Please sign in to comment.