Skip to content

Commit

Permalink
Merge pull request #162 from calvinmclean/feature/demo-app
Browse files Browse the repository at this point in the history
Add build and deploy for demo application on Fly
  • Loading branch information
calvinmclean committed May 6, 2024
2 parents e17620d + 7648acd commit f151c64
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 72 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Fly Deploy
on:
push:
branches:
- main

env:
PROJECT_NAME: garden-app

jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --build-target demo --remote-only
working-directory: ./${{ env.PROJECT_NAME }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This project is a monorepo containing code for an ESP32-based microcontroller pr

**If you have any question at all, please reach out and I would love to chat about the project!**

[![Additional Docs](https://img.shields.io/badge/Use-Live_UI_Demo-2ea44f?style=for-the-badge)](https://garden-app-demo.fly.dev/)
[![Additional Docs](https://img.shields.io/badge/View-Documentation-3271a8?style=for-the-badge)](https://calvinmclean.github.io/automated-garden)

This system is designed to be flexible for all types of gardening. Here are a few examples of different possible setups:
Expand Down
29 changes: 27 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,36 @@ tasks:
desc: Build docker container
dir: ./garden-app
cmds:
- docker build . -t ghcr.io/calvinmclean/garden-app:{{.CLI_ARGS | default "latest"}}
- docker build --target {{.TARGET}} -t ghcr.io/calvinmclean/garden-app:{{.TAG}} .
vars:
TAG: '{{default "latest" .TAG}}'
TARGET: '{{default "production" .TARGET}}'

docker-build-demo:
cmds:
- task: docker-build
vars:
TAG: "demo"
TARGET: "demo"

docker-push-demo:
cmds:
- task: docker-push
vars:
TAG: "demo"
TARGET: "demo"

docker-push:
desc: Build and push docker container
dir: ./garden-app
cmds:
- task: docker-build
- docker push ghcr.io/calvinmclean/garden-app:{{.CLI_ARGS | default "latest"}}
- docker push ghcr.io/calvinmclean/garden-app:{{.TAG}}
vars:
TAG: '{{default "latest" .TAG}}'
TARGET: '{{default "production" .TARGET}}'

fly:
dir: ./garden-app
cmds:
- flyctl deploy
8 changes: 8 additions & 0 deletions garden-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ ADD . /build
WORKDIR /build
RUN go build -o garden-app .

FROM alpine:latest AS demo
RUN mkdir /app
WORKDIR /app
COPY --from=build /build/garden-app .
COPY gardens.yaml.example /app/gardens.yaml
COPY config.yaml.example /app/config.yaml
ENTRYPOINT ["/app/garden-app", "server", "--readonly"]

FROM alpine:latest AS production
RUN mkdir /app
WORKDIR /app
Expand Down
23 changes: 23 additions & 0 deletions garden-app/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# fly.toml app configuration file generated for garden-app-demo on 2024-05-05T18:49:53-07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'garden-app-demo'
primary_region = 'lax'

[build]
build-target = "demo"

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
101 changes: 31 additions & 70 deletions garden-app/gardens.yaml.example
Original file line number Diff line number Diff line change
@@ -1,72 +1,33 @@
Garden_chokmn1nhf81274ru2mg: |
{
"name": "Seed Starting",
"topic_prefix": "seed-garden",
"id": "chokmn1nhf81274ru2mg",
"max_zones": 3,
"created_at": "2023-05-27T00:14:20.324Z",
"light_schedule": {
"duration": "16h0m0s",
"start_time": "06:00:00-07:00"
}
}
WaterSchedule_chokmq1nhf81274ru2n0: |
{
"id": "chokmq1nhf81274ru2n0",
"duration": "1s",
"interval": "30s",
"start_time": "2023-05-23T15:00:00.000Z",
"name": "WaterEvery30s"
}
WaterSchedule_cii72s9nhf8f7gdpckug: |
{
"id": "cii72s9nhf8f7gdpckug",
"duration": "1h0m0s",
"interval": "480h0m0s",
"start_time": "2023-06-17T12:00:00.000Z",
"name": "WaterSchedule20Day"
}
WaterSchedule_cjbg22a8tio6of9s8o0g: |
{
"id": "cjbg22a8tio6of9s8o0g",
"duration": "30s",
"interval": "72h0m0s",
"start_time": "2023-07-25T15:00:00.000Z",
"name": "SeedlingWatering"
}
Garden_chokmn1nhf81274ru2mg: '{"name":"Indoor Seed Starting","topic_prefix":"seed-garden","id":"chokmn1nhf81274ru2mg","max_zones":3,"created_at":"2023-05-27T00:14:20.324Z","light_schedule":{"duration":"16h0m0s","start_time":"06:00:00-07:00"}}'
Garden_cos1pt0n1e43o39cs40g: '{"name":"Front Yard","topic_prefix":"front-yard","id":"cos1pt0n1e43o39cs40g","max_zones":4,"created_at":"2024-05-05T16:58:10.206246-07:00"}'
WaterSchedule_chokmq1nhf81274ru2n0: '{"id":"chokmq1nhf81274ru2n0","duration":"1s","interval":"30s","start_time":"2023-05-23T15:00:00Z","end_date":"2024-05-05T17:01:10.335976-07:00","name":"WaterEvery30s"}'
WaterSchedule_cii72s9nhf8f7gdpckug: '{"id":"cii72s9nhf8f7gdpckug","duration":"1h0m0s","interval":"480h0m0s","start_time":"2023-06-17T12:00:00Z","name":"Winter Trees","description":"Water deeply and infrequently in the winter","active_period":{"start_month":"October","end_month":"March"}}'
WaterSchedule_cjbg22a8tio6of9s8o0g: '{"id":"cjbg22a8tio6of9s8o0g","duration":"30s","interval":"24h0m0s","start_time":"2023-07-25T15:00:00Z","name":"Seedlings","description":"Water seedlings a bit every day"}'
WaterSchedule_cos1s28n1e43sc2vb4k0: '{"id":"cos1s28n1e43sc2vb4k0","duration":"1h30m0s","interval":"240h0m0s","start_time":"2023-06-17T12:00:00Z","name":"Summer Trees","description":"Water deeply every 10 days","active_period":{"start_month":"April","end_month":"September"}}'
WaterSchedule_cos1suon1e43sc2vb4kg: '{"id":"cos1suon1e43sc2vb4kg","duration":"45m0s","interval":"120h0m0s","start_time":"2006-01-02T15:04:05Z","name":"Shrubs","description":"Water shrubs every 5 days"}'
Zone_chokn19nhf81274ru2o0: |
{
"name": "Zone 1",
"id": "chokn19nhf81274ru2o0",
"garden_id": "chokmn1nhf81274ru2mg",
"position": 0,
"created_at": "2023-05-27T00:15:01.683Z",
"water_schedule_ids": [
"cjbg22a8tio6of9s8o0g"
],
"skip_count": 5
}
Zone_cij42vpnhf85d3acsgu0: |
{
"name": "Zone 2",
"id": "cij42vpnhf85d3acsgu0",
"garden_id": "chokmn1nhf81274ru2mg",
"position": 0,
"created_at": "2023-07-06T04:22:23.331Z",
"water_schedule_ids": [
"chokmq1nhf81274ru2n0"
],
"skip_count": null
}
{
"name": "Zone 1",
"id": "chokn19nhf81274ru2o0",
"garden_id": "chokmn1nhf81274ru2mg",
"position": 0,
"created_at": "2023-05-27T00:15:01.683Z",
"water_schedule_ids": [
"cjbg22a8tio6of9s8o0g"
]
}
Zone_cij42vpnhf85d3acsgu0: '{"name":"Zone 2","id":"cij42vpnhf85d3acsgu0","garden_id":"chokmn1nhf81274ru2mg","position":0,"created_at":"2023-07-06T04:22:23.331Z","end_date":"2024-05-05T17:00:29.204187-07:00","water_schedule_ids":["chokmq1nhf81274ru2n0"],"skip_count":null}'
Zone_cij436pnhf85d3acsgug: |
{
"name": "Zone 1",
"id": "cij436pnhf85d3acsgug",
"garden_id": "cihpp51nhf84tr94jtfg",
"position": 0,
"created_at": "2023-07-06T04:22:51.608Z",
"water_schedule_ids": [
"cii72s9nhf8f7gdpckug"
],
"skip_count": null
}
{
"name": "Zone 1",
"id": "cij436pnhf85d3acsgug",
"garden_id": "cihpp51nhf84tr94jtfg",
"position": 0,
"created_at": "2023-07-06T04:22:51.608Z",
"water_schedule_ids": [
"cii72s9nhf8f7gdpckug"
],
"skip_count": null
}
Zone_cos1q8gn1e43o39cs410: '{"name":"Trees","details":{"description":"This zone controls watering to two trees that are watered deeply"},"id":"cos1q8gn1e43o39cs410","garden_id":"cos1pt0n1e43o39cs40g","position":0,"created_at":"2024-05-05T16:58:49.357958-07:00","water_schedule_ids":["cos1s28n1e43sc2vb4k0","cii72s9nhf8f7gdpckug"],"skip_count":null}'
Zone_cos1qf0n1e43o39cs41g: '{"name":"Shrubs","details":{"description":"This zone has a few shrubs that need water more frequently"},"id":"cos1qf0n1e43o39cs41g","garden_id":"cos1pt0n1e43o39cs40g","position":2,"created_at":"2024-05-05T16:59:08.973836-07:00","water_schedule_ids":["cos1suon1e43sc2vb4kg"],"skip_count":null}'

0 comments on commit f151c64

Please sign in to comment.