Skip to content

Commit

Permalink
Final touches (#51)
Browse files Browse the repository at this point in the history
* fix: correct variables for terrastories offline maps

* fix: remove redundant terrastories-data volume

* chore: remove yarn on terrastories start script

* chore: copy balena services for local

* chore: cleanup and corrections

* feat: add ahau pataka

* chore: add PATAKA_WEB_PORT env, and set to 8089

* fix: stop persisting portal volume for it to update properly

* fix: only run syncthing script once

* chore: change EDT logos for balena interface

* fix: pywb init 'all' collection

* fix: scrubbed and background-less svgs for interface

* fix: corrected by AI yaml syntax for deploy-balena-image Github action

* fix: AI corrected yaml syntax

* fix: various fixes on github actions

* fix: trying to fix inputs.commit var on github action

* fix: trying to fix inputs.commit var on github action

* fix rewrite github actions for use conditions instead of complex single liner

* fix: change balena draft check from boolean to draft or release

* fix: add if expressions fully within brackets
  • Loading branch information
luandro authored Apr 9, 2023
1 parent 719cb14 commit 0016e3e
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 142 deletions.
23 changes: 16 additions & 7 deletions .github/actions/deploy-balena-image/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Create Balena Image"
description: "Pre-loads, configures, compresses and uploads a Balena device"
name: "Deploy Balena Image"
description: "Builds and pushes a Balena image to Balena Cloud"
inputs:
balena_token:
required: true
Expand All @@ -15,12 +15,14 @@ inputs:
description: "Github head ref"
release_tag:
description: "A tag to be used instead of the Github tag"
balena_draft:
required: false
balena_release_type:
description: "Is this a release a draft"
default: "draft"
balena_path:
description: "Path to read balena.yml file from"
default: "./balena.yml"
commit:
description: "Github commit"
outputs:
github_tag:
description: "Current Github tag"
Expand All @@ -45,9 +47,16 @@ runs:
ref: ${{ github.ref }}
head_ref: ${{ github.head_ref }}

- name: Balena Deploy
- name: Balena Deploy Draft
uses: Theia-Scientific/balena-cli@v1
if: success()
if: ${{(inputs.balena_release_type == 'draft') && (success())}}
with:
balena_api_token: ${{inputs.balena_token}}
balena_command: push ${{inputs.balena_fleet}} ${{inputs.balena_draft == 'true' && '--draft' || ''}} --release-tag v${{steps.yaml-data.outputs.data}}${{inputs.balena_draft && '-draft' || ''}} ${{ inputs.release_tag || steps.get-ref.outputs.tag }} ${{ inputs.commit && ('--release-tag commit $inputs.commit') || '' }}
balena_command: push ${{inputs.balena_fleet}} --draft --release-tag commit ${{inputs.commit}} --release-tag v${{steps.yaml-data.outputs.data}}-draft ${{ inputs.release_tag || steps.get-ref.outputs.tag }}

- name: Balena Deploy Release
uses: Theia-Scientific/balena-cli@v1
if: ${{(inputs.balena_release_type == 'release') && (success())}}
with:
balena_api_token: ${{inputs.balena_token}}
balena_command: push ${{inputs.balena_fleet}} --release-tag release v${{steps.yaml-data.outputs.data}}
2 changes: 1 addition & 1 deletion .github/actions/release-images/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Create release on Github"
description: "Downloads all artefacts, generates and publishes a release to Github"
description: "Downloads all artifacts, generates and publishes a release to Github"
inputs:
pre-release:
required: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/balena-pr-draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
balena_fleet: "${{ secrets.BALENA_FLEET }}${{ matrix.fleet_var }}"
github_ref: ${{ github.ref }}
github_head_ref: ${{ github.head_ref }}
balena_draft: true
balena_release_type: draft
release_tag: ${{ github.ref_name }}
commit: ${{ github.sha }}
2 changes: 1 addition & 1 deletion .github/workflows/balena-push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
balena_fleet: "${{ secrets.BALENA_FLEET }}${{ matrix.fleet_var }}"
github_ref: ${{ github.ref }}
github_head_ref: ${{ github.head_ref }}
balena_draft: true
balena_release_type: draft
release_tag: main
commit: ${{ github.sha }}
6 changes: 5 additions & 1 deletion .github/workflows/balena-tag-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
balena_fleet: "${{ secrets.BALENA_FLEET }}${{ matrix.fleet_var }}"
github_ref: ${{ github.ref }}
github_head_ref: ${{ github.head_ref }}
balena_draft: true
balena_release_type: draft

balena-build-images:
strategy:
Expand Down Expand Up @@ -79,3 +79,7 @@ jobs:
with:
pre-release: true
repo_token: "${{ secrets.PAT }}"
access_key: ${{ secrets.ACCESS_KEY}}
secret_key: ${{ secrets.SECRET_KEY }}
space_name: ${{ secrets.SPACE_NAME }}
space_region: ${{ secrets.SPACE_REGION }}
3 changes: 1 addition & 2 deletions .github/workflows/balena-tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
github_ref: ${{ github.ref }}
github_head_ref: ${{ github.head_ref }}
release_tag: release
balena_draft: false
balena_release_type: release

balena-build-images:
strategy:
Expand Down Expand Up @@ -83,7 +83,6 @@ jobs:
secret_key: ${{ secrets.SECRET_KEY }}
space_name: ${{ secrets.SPACE_NAME }}
space_region: ${{ secrets.SPACE_REGION }}
tag: ${{ needs.balena-deploy.outputs.github_tag }}

#TODO: Download and inject content into the image
# - name: Mount Image
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Delete old artifacts and clean docker'
on:
schedule:
- cron: '* 12 10-16/2 * *' # every 2 days
- cron: '33 3 * * *' # every day at 3:33

jobs:
clean-docker:
Expand Down
4 changes: 2 additions & 2 deletions balena.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Earth Defender's Toolkit Offline"
type: "sw.application"
version: 0.4.8
version: 0.4.9
description: "A low-energy device that creates an access-point serving applications, bridging them and exposing curated content offline.
Software stack and content are automatically updated while online, and can be updated offline."
assets:
Expand Down Expand Up @@ -51,7 +51,7 @@ data:
- SYNC_TILES_NAME: Map-Tiles
# Terrastories
- HOST_HOSTNAME: edt.local
- OFFLINE_MAP_URL: http://edt.local:8085/styles/terrastories-map/style.json
- OFFLINE_MAP_STYLE: http://edt.local:8085/styles/terrastories-map/style.json
- MAPBOX_ACCESS_TOKEN: "pk.eyJ1IjoibHVhbmRybyIsImEiOiJjanY2djRpdnkwOWdqM3lwZzVuaGIxa3VsIn0.jamcK2t2I1j3TXkUQFIsjQ"
- USE_LOCAL_MAP_SERVER: "true"
- RAILS_ENV: "offline"
Expand Down
20 changes: 15 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ volumes:
interface_db:
wifi_db:
fdroid:
portal:
mapeo:
crawls:
pywb-archive:
installers:
postgres_data:
mbtiles:
bundler:
terrastories-data:
terrastories-media:
terrastories-import:
pataka:
services:
# https://github.com/digidem/starter-interface
balena-interface:
Expand Down Expand Up @@ -57,8 +56,6 @@ services:
portal:
image: communityfirst/edt-offline-portal:nightly
restart: always
volumes:
- portal:/usr/src/nuxt-app
ports:
- 8080:3000
# https://hub.docker.com/r/communityfirst/mapeo-bridge
Expand Down Expand Up @@ -111,6 +108,7 @@ services:
POSTGRES_DB: terrastories
volumes:
- "postgres_data:/var/lib/postgresql/data"
restart: unless-stopped
# https://hub.docker.com/r/terrastories/terrastories
terrastories:
build: services/terrastories
Expand All @@ -124,16 +122,17 @@ services:
SECRET_KEY_BASE: "a845b372237fe58988e8fb7698b9a7b61f8cc7581dc685387ff1cb8ec5f250d57b733379d53f5c3e7b816d0bf0fdf5f7b02558c64b932903e5ec3fbe10c4b205"
volumes:
- bundler:/usr/local/bundle
- terrastories-data:/api
- terrastories-media:/media
- terrastories-import:/api/import/media
restart: unless-stopped
# https://hub.docker.com/r/maptiler/tileserver-gl
tileserver:
build: services/tileserver
ports:
- 8085:8080
volumes:
- mbtiles:/data
restart: unless-stopped
# https://hub.docker.com/r/webrecorder/pywb
pywb:
build: services/pywb
Expand All @@ -142,6 +141,7 @@ services:
volumes:
- pywb-archive:/webarchive
- crawls:/source
restart: unless-stopped
# https://hub.docker.com/_/httpd
httpd:
build: services/httpd
Expand All @@ -150,3 +150,13 @@ services:
volumes:
- installers:/usr/local/apache2/htdocs/installers
- fdroid:/usr/local/apache2/htdocs/repo
restart: unless-stopped
# https://hub.docker.com/r/communityfirst/pataka-cli
pataka:
image: communityfirst/pataka-cli:latest
network_mode: "host"
restart: unless-stopped
volumes:
- pataka:/root/.local/share/ahau-pataka
environment:
PATAKA_WEB_PORT: 8089
2 changes: 1 addition & 1 deletion docker/demo/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SYNC_INSTALLERS_NAME=INSTALLERS-edt
SYNC_TILES_ID=kfgre-slfl7
SYNC_TILES_NAME=Map-Tiles
# Terrastories
OFFLINE_MAP_URL=http://demo.earthdefenderstoolkit.com:8085/styles/terrastories-map/style.json
OFFLINE_MAP_STYLE=http://demo.earthdefenderstoolkit.com:8085/styles/terrastories-map/style.json
MAPBOX_ACCESS_TOKEN="pk.eyJ1IjoibHVhbmRybyIsImEiOiJjanY2djRpdnkwOWdqM3lwZzVuaGIxa3VsIn0.jamcK2t2I1j3TXkUQFIsjQ"
HOST_HOSTNAME=demo.earthdefenderstoolkit.com
USE_LOCAL_MAP_SERVER="true"
Expand Down
15 changes: 11 additions & 4 deletions docker/demo/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: '2.1'

volumes:
portal:
fdroid:
mapeo:
crawls:
pywb-archive:
minio-data:
installers:
pataka:
# Terrastories
postgres_data:
mbtiles:
Expand All @@ -17,10 +17,8 @@ volumes:
terrastories-import:
services:
portal:
image: communityfirst/edt-offline-portal:nightly-full
image: communityfirst/edt-offline-portal:nightly
restart: always
volumes:
- 'portal:/usr/src/nuxt-app'
ports:
- 80:3000
mapeo-bridge:
Expand Down Expand Up @@ -143,3 +141,12 @@ services:
- terrastories-media:/media
- terrastories-import:/api/import/media
restart: unless-stopped
# https://hub.docker.com/r/communityfirst/pataka-cli
pataka:
image: communityfirst/pataka-cli:latest
network_mode: "host"
restart: unless-stopped
volumes:
- pataka:/root/.local/share/ahau-pataka
environment:
PATAKA_WEB_PORT: 8089
2 changes: 1 addition & 1 deletion docker/local/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SYNC_INSTALLERS_NAME=INSTALLERS-edt
SYNC_TILES_ID=kfgre-slfl7
SYNC_TILES_NAME=Map-Tiles
# Terrastories
OFFLINE_MAP_URL=http://0.0.0.0:8085/styles/terrastories-map/style.json
OFFLINE_MAP_STYLE=http://0.0.0.0:8085/styles/terrastories-map/style.json
MAPBOX_ACCESS_TOKEN="pk.eyJ1IjoibHVhbmRybyIsImEiOiJjanY2djRpdnkwOWdqM3lwZzVuaGIxa3VsIn0.jamcK2t2I1j3TXkUQFIsjQ"
HOST_HOSTNAME=0.0.0.0
USE_LOCAL_MAP_SERVER="true"
Expand Down
Loading

0 comments on commit 0016e3e

Please sign in to comment.