From d2cb5780bfdbebc3637b221c6ad45abdd3c56ff7 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 10:28:20 +0100 Subject: [PATCH 01/14] chore: ignore lock files, sort --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fac5512..1c65597 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.lock .env -/public/ /content/ +/public/ From 3a15d4f7d49c4985e36cce7f1ee5706d9866db10 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 11:02:44 +0100 Subject: [PATCH 02/14] feat: CI/CD setup --- .drone.yml | 27 +++++++++++++++++++++++++++ Dockerfile | 11 ----------- Dockerfile.hugo | 7 +++++++ README.md | 2 ++ compose.yml | 8 ++++++++ makefile | 6 +++++- 6 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 .drone.yml delete mode 100644 Dockerfile create mode 100644 Dockerfile.hugo diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..3afe587 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,27 @@ +--- +kind: pipeline +name: continuous deployment +steps: + - name: build image + image: plugins/docker + settings: + username: + from_secret: docker_reg_username + password: + from_secret: docker_reg_passwd + repo: decentral1se/beta.lumbung.space + tags: latest + + - name: deploy stack + image: decentral1se/stack-ssh-deploy:latest + settings: + stack: beta_lumbung_space + host: lumbung.space + deploy_key: + from_secret: drone_ssh_lumbung.space +trigger: + branch: + - main + event: + exclude: + - pull_request diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 898ced1..0000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM klakegg/hugo:alpine - -RUN apk add --no-cache curl git - -EXPOSE 1313 - -COPY . /src/ - -ENTRYPOINT ["/bin/bash"] - -CMD ["-c", "hugo server --appendPort='false' --bind 0.0.0.0 --baseUrl='https://beta.lumbung.space' --port='1313' -F"] diff --git a/Dockerfile.hugo b/Dockerfile.hugo new file mode 100644 index 0000000..08a7553 --- /dev/null +++ b/Dockerfile.hugo @@ -0,0 +1,7 @@ +FROM klakegg/hugo:alpine + +RUN apk add --no-cache curl git + +EXPOSE 1313 + +COPY . /src/ diff --git a/README.md b/README.md index a953080..a66754f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # living room +[![Build Status](https://drone.autonomic.zone/api/badges/ruangrupa/living-room/status.svg?ref=refs/heads/main)](https://drone.autonomic.zone/ruangrupa/living-room) + > A new attempt to bring together the ideas of the "splash" page, "portal" page > and a comfortable digital "living room" experience for lumbung[dot]space. > This is a work in progress. The end goal of this is to have a new design and diff --git a/compose.yml b/compose.yml index ed0b86f..a3e7be3 100644 --- a/compose.yml +++ b/compose.yml @@ -14,6 +14,14 @@ services: start_period: 15s volumes: - content:/src/content + command: | + server + --appendPort='false' + --bind 0.0.0.0 + --baseUrl='https://beta.lumbung.space' + --port='1313' + --buildFuture + --watch deploy: update_config: failure_action: rollback diff --git a/makefile b/makefile index 6f5a0d8..b85c228 100644 --- a/makefile +++ b/makefile @@ -9,4 +9,8 @@ gen: lumbunglib-cal && \ OUTPUT_DIR=content/video lumbunglib-vid -.PHONY: serve +push-hugo: + @docker build -t decentral1se/beta.lumbung.space -f Dockerfile.hugo . && \ + docker push decentral1se/beta.lumbung.space + +.PHONY: serve gen push-hugo From 5f35faddcb496c163b04f688974b6a4f9277be03 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 11:42:06 +0100 Subject: [PATCH 03/14] fix: point to new dockerfile --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 3afe587..752e4c8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,6 +9,7 @@ steps: from_secret: docker_reg_username password: from_secret: docker_reg_passwd + dockerfile: Dockerfile.hugo repo: decentral1se/beta.lumbung.space tags: latest From ce3e8640082cc34690a01c04709916022d832884 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 12:06:04 +0100 Subject: [PATCH 04/14] fix: ignore also when docker building --- .dockerignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..84ef319 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +/content/ +/public/ From d92732109f1f0f904e6794e3075fe7487611329e Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 12:53:04 +0100 Subject: [PATCH 05/14] feat: add content generation See https://git.autonomic.zone/ruangrupa/living-room/issues/17. --- .drone.yml | 16 +++++++++++++++- Dockerfile.scripts | 11 +++++++++++ compose.yml | 35 +++++++++++++++++++++++++++++++++++ makefile | 4 ++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.scripts diff --git a/.drone.yml b/.drone.yml index 752e4c8..dc82c3a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,7 +2,7 @@ kind: pipeline name: continuous deployment steps: - - name: build image + - name: push hugo image image: plugins/docker settings: username: @@ -13,6 +13,17 @@ steps: repo: decentral1se/beta.lumbung.space tags: latest + - name: push scripts image + image: plugins/docker + settings: + username: + from_secret: docker_reg_username + password: + from_secret: docker_reg_passwd + dockerfile: Dockerfile.scripts + repo: decentral1se/beta.lumbung.space-scripts + tags: latest + - name: deploy stack image: decentral1se/stack-ssh-deploy:latest settings: @@ -20,6 +31,9 @@ steps: host: lumbung.space deploy_key: from_secret: drone_ssh_lumbung.space + depends_on: + - push hugo image + - push scripts image trigger: branch: - main diff --git a/Dockerfile.scripts b/Dockerfile.scripts new file mode 100644 index 0000000..36c5da8 --- /dev/null +++ b/Dockerfile.scripts @@ -0,0 +1,11 @@ +FROM python:3.9.9-alpine + +RUN apk add --no-cache git bash + +WORKDIR /src/ + +RUN git clone https://git.autonomic.zone/ruangrupa/lumbunglib /src/ + +RUN pip install -U setuptools pip + +RUN pip install . diff --git a/compose.yml b/compose.yml index a3e7be3..ae0e431 100644 --- a/compose.yml +++ b/compose.yml @@ -33,6 +33,41 @@ services: - "traefik.http.services.coop-cloud-site.loadbalancer.server.port=1313" - "traefik.http.routers.coop-cloud-site.tls.certresolver=production" + peertube: + image: decentral1se/beta.lumbung.space-scripts:latest + volumes: + - content:/src/content + environment: + OUTPUT_DIR: /src/content/video + command: | + bash -c " + while true + do + echo 'generating peertube posts...' + lumbunglib-vid + echo 'going to sleep for 5 minutes...' + sleep 300 + done + " + + calendar: + image: decentral1se/beta.lumbung.space-scripts:latest + volumes: + - content:/src/content + environment: + OUTPUT_DIR: /src/content/video + CALENDAR_URL: "https://cloud.lumbung.space/remote.php/dav/public-calendars/WbnHM8YdCkKT6bcT?export" + command: | + bash -c " + while true + do + echo 'generating calendar posts...' + lumbunglib-cal + echo 'going to sleep for 5 minutes...' + sleep 300 + done + " + volumes: content: diff --git a/makefile b/makefile index b85c228..aa59b6e 100644 --- a/makefile +++ b/makefile @@ -13,4 +13,8 @@ push-hugo: @docker build -t decentral1se/beta.lumbung.space -f Dockerfile.hugo . && \ docker push decentral1se/beta.lumbung.space +push-scripts: + @docker build -t decentral1se/beta.lumbung.space-scripts -f Dockerfile.scripts . && \ + docker push decentral1se/beta.lumbung.space-scripts + .PHONY: serve gen push-hugo From 4850c14e37b8338fa17d9e9fcb15c2f96f3eaf6e Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 13:00:42 +0100 Subject: [PATCH 06/14] docs: explain setup --- README.md | 28 +++++++++++++++++++++++++--- makefile | 5 ++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a66754f..e119fb1 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,23 @@ > This is a work in progress. The end goal of this is to have a new design and > implementation for [`lumbung.space`](https://lumbung.space) for January 2022. -## Hacking +## FAQ -[Install Hugo](https://gohugo.io/getting-started/installing/). +### How does the CI/CD work? + +[`.drone.yml`](./.drone.yml) builds the [`Dockerfile.hugo`](./Dockerfile.hugo) +and the [`Dockerfile.scripts`](./Dockerfile.scripts) and then deploys the +[`compose.yml`](./compose.yml) stack using `docker stack deploy`. + +### How often is the content regenerated? + +See the `sleep ...` statements in the [`compose.yml`](./compose.yml). + +## Hacking ### Generate the site -`hugo serve --watch` +[Install Hugo](https://gohugo.io/getting-started/installing/) and `hugo serve --watch` ### Generate `lumbung[dot]space` posts @@ -33,3 +43,15 @@ lumbunglib-vid ``` Afterwards, you can automatically run it with `make gen`. + +### Manually deploying new images + +- `docker login -u decentral1se -p $(logins/dockerhub/decentral1se)` +- `make push-hugo` +- `make push-scripts` + +### Manually deploy the site + +(requires `lumbung.space` docker context) + +- `make deploy` diff --git a/makefile b/makefile index aa59b6e..b548575 100644 --- a/makefile +++ b/makefile @@ -17,4 +17,7 @@ push-scripts: @docker build -t decentral1se/beta.lumbung.space-scripts -f Dockerfile.scripts . && \ docker push decentral1se/beta.lumbung.space-scripts -.PHONY: serve gen push-hugo +deploy: + @DOCKER_CONTEXT=lumbung.space docker stack deploy -c compose.yml beta_lumbung_space + +.PHONY: serve gen push-hugo push-scripts deploy From ad3c1a7476816af16b658399b8ee7f1f5033eb75 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 13:01:40 +0100 Subject: [PATCH 07/14] docs: better explained --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index e119fb1..4446592 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,7 @@ ### How does the CI/CD work? -[`.drone.yml`](./.drone.yml) builds the [`Dockerfile.hugo`](./Dockerfile.hugo) -and the [`Dockerfile.scripts`](./Dockerfile.scripts) and then deploys the -[`compose.yml`](./compose.yml) stack using `docker stack deploy`. +The [`.drone.yml`](./.drone.yml) triggers a build on [drone.autonomic.zone](https://drone.autonomic.zone/ruangrupa/living-room) the [`Dockerfile.hugo`](./Dockerfile.hugo) and the [`Dockerfile.scripts`](./Dockerfile.scripts) and then deploys the [`compose.yml`](./compose.yml) stack using `docker stack deploy`. ### How often is the content regenerated? From da9a56e0dd3ddb1c076fec5a12a8d59143cdef7b Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 13:02:20 +0100 Subject: [PATCH 08/14] docs: wording [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4446592..46d2183 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ### How does the CI/CD work? -The [`.drone.yml`](./.drone.yml) triggers a build on [drone.autonomic.zone](https://drone.autonomic.zone/ruangrupa/living-room) the [`Dockerfile.hugo`](./Dockerfile.hugo) and the [`Dockerfile.scripts`](./Dockerfile.scripts) and then deploys the [`compose.yml`](./compose.yml) stack using `docker stack deploy`. +The [`.drone.yml`](./.drone.yml) triggers a build on [drone.autonomic.zone](https://drone.autonomic.zone/ruangrupa/living-room) of the [`Dockerfile.hugo`](./Dockerfile.hugo) and the [`Dockerfile.scripts`](./Dockerfile.scripts) and then deploys the [`compose.yml`](./compose.yml) stack using `docker stack deploy`. ### How often is the content regenerated? From 696e5634f16e322bdce21208f29efe5d15118b99 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 13:06:27 +0100 Subject: [PATCH 09/14] docs: logs for generation [ci skip] --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 46d2183..083627c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,15 @@ The [`.drone.yml`](./.drone.yml) triggers a build on [drone.autonomic.zone](http See the `sleep ...` statements in the [`compose.yml`](./compose.yml). +### How do I see if content generation is working? + +(requires `lumbung.space` docker context) + +- `docker service logs -f beta_lumbung_space_peertube` +- `docker service logs -f beta_lumbung_space_calendar` + +Where `beta_lumbung_space_` and you see the service name in the [`compose.yml`](./compose.yml). + ## Hacking ### Generate the site From 595eee3bc07481371264547277c1559ffec98dca Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 13:48:54 +0100 Subject: [PATCH 10/14] feat: include feed generation See https://git.autonomic.zone/ruangrupa/living-room/issues/20. --- README.md | 8 ++++++++ compose.yml | 25 +++++++++++++++++++++++++ feeds_list.txt | 1 + makefile | 5 +++-- 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 feeds_list.txt diff --git a/README.md b/README.md index 083627c..f5d3fab 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ See the `sleep ...` statements in the [`compose.yml`](./compose.yml). - `docker service logs -f beta_lumbung_space_peertube` - `docker service logs -f beta_lumbung_space_calendar` +- `docker service logs -f beta_lumbung_space_feed` Where `beta_lumbung_space_` and you see the service name in the [`compose.yml`](./compose.yml). @@ -47,6 +48,9 @@ lumbunglib-cal export OUTPUT_DIR=content/video lumbunglib-vid + +export OUTPUT_DIR=content/feed +lumbunglib-feed # reads ./feeds_list.txt ``` Afterwards, you can automatically run it with `make gen`. @@ -62,3 +66,7 @@ Afterwards, you can automatically run it with `make gen`. (requires `lumbung.space` docker context) - `make deploy` + +### Deploy a new `feeds_list.txt` + +- Increment the `_v` (e.g. `v1` -> `v2`) in [`compose.yml`](./compose.yml) `configs` to avoid any deployment error diff --git a/compose.yml b/compose.yml index ae0e431..919d9c5 100644 --- a/compose.yml +++ b/compose.yml @@ -68,9 +68,34 @@ services: done " + feed: + image: decentral1se/beta.lumbung.space-scripts:latest + volumes: + - content:/src/content + configs: + - source: feeds_list + target: /src/feeds_list.txt + environment: + OUTPUT_DIR: /src/content/feed + command: | + bash -c " + while true + do + echo 'generating feed posts...' + lumbunglib-feed + echo 'going to sleep for 5 minutes...' + sleep 300 + done + " + volumes: content: networks: proxy: external: true + +configs: + feeds_list: + name: beta_lumbung_space_feeds_list_v1 + file: feeds_list.txt diff --git a/feeds_list.txt b/feeds_list.txt new file mode 100644 index 0000000..47cafed --- /dev/null +++ b/feeds_list.txt @@ -0,0 +1 @@ +https://artivismo.org/feed/ diff --git a/makefile b/makefile index b548575..389c749 100644 --- a/makefile +++ b/makefile @@ -7,14 +7,15 @@ gen: @CALENDAR_URL="https://cloud.lumbung.space/remote.php/dav/public-calendars/WbnHM8YdCkKT6bcT?export"; \ OUTPUT_DIR=content/calendar; \ lumbunglib-cal && \ - OUTPUT_DIR=content/video lumbunglib-vid + OUTPUT_DIR=content/video lumbunglib-vid && \ + OUTPUT_DIR=content/feed lumbunglib-feed push-hugo: @docker build -t decentral1se/beta.lumbung.space -f Dockerfile.hugo . && \ docker push decentral1se/beta.lumbung.space push-scripts: - @docker build -t decentral1se/beta.lumbung.space-scripts -f Dockerfile.scripts . && \ + @docker build --no-cache -t decentral1se/beta.lumbung.space-scripts -f Dockerfile.scripts . && \ docker push decentral1se/beta.lumbung.space-scripts deploy: From 60ecda18d66800a004e10331b9387706627830c7 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 13:50:35 +0100 Subject: [PATCH 11/14] docs: point to new install [ci skip] --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f5d3fab..0415743 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ lumbunglib-feed # reads ./feeds_list.txt Afterwards, you can automatically run it with `make gen`. +After a `git pull`, you may need to run `pip install git+https://git.autonomic.zone/ruangrupa/lumbunglib` again. + ### Manually deploying new images - `docker login -u decentral1se -p $(logins/dockerhub/decentral1se)` From 3dcd2cd2ee846c33086cfa21bfa4b791e1e05af9 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 14:14:05 +0100 Subject: [PATCH 12/14] docs: how to add feed [ci skip] --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0415743..5af4d5b 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ See the `sleep ...` statements in the [`compose.yml`](./compose.yml). Where `beta_lumbung_space_` and you see the service name in the [`compose.yml`](./compose.yml). +### How do I add a feed? + +Add your RSS feed URL to [`feeds_list.txt`](./feeds_list.txt) and don't forget [this deploy step](https://git.autonomic.zone/ruangrupa/living-room#deploy-a-new-feeds_list-txt). + ## Hacking ### Generate the site @@ -71,4 +75,4 @@ After a `git pull`, you may need to run `pip install git+https://git.autonomic.z ### Deploy a new `feeds_list.txt` -- Increment the `_v` (e.g. `v1` -> `v2`) in [`compose.yml`](./compose.yml) `configs` to avoid any deployment error +Increment the `_v` (e.g. `v1` -> `v2`) in [`compose.yml`](./compose.yml) `configs` to avoid any deployment error. From 707cb8c8a1dbe0ef9147c921fba6173daf0efd6c Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 14:29:41 +0100 Subject: [PATCH 13/14] fix: deploy to correct folder --- compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yml b/compose.yml index 919d9c5..8bc161a 100644 --- a/compose.yml +++ b/compose.yml @@ -55,7 +55,7 @@ services: volumes: - content:/src/content environment: - OUTPUT_DIR: /src/content/video + OUTPUT_DIR: /src/content/calendar CALENDAR_URL: "https://cloud.lumbung.space/remote.php/dav/public-calendars/WbnHM8YdCkKT6bcT?export" command: | bash -c " From 7ac941a8410393eb42eae3bb925091e67cad2d94 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Wed, 5 Jan 2022 14:32:33 +0100 Subject: [PATCH 14/14] docs: how to wipe --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 5af4d5b..c73cb80 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ Where `beta_lumbung_space_` and you see the service name in the [` Add your RSS feed URL to [`feeds_list.txt`](./feeds_list.txt) and don't forget [this deploy step](https://git.autonomic.zone/ruangrupa/living-room#deploy-a-new-feeds_list-txt). +### How do I wipe all the generated content? + +(requires `lumbung.space` docker context) + +`docker exec -it $(docker container ls -q -f name=beta_lumbung_space_app) bash -c "rm -rf /src/content/*"` + ## Hacking ### Generate the site