diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..84ef319 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +/content/ +/public/ diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..dc82c3a --- /dev/null +++ b/.drone.yml @@ -0,0 +1,42 @@ +--- +kind: pipeline +name: continuous deployment +steps: + - name: push hugo image + image: plugins/docker + settings: + username: + from_secret: docker_reg_username + password: + from_secret: docker_reg_passwd + dockerfile: Dockerfile.hugo + 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: + stack: beta_lumbung_space + host: lumbung.space + deploy_key: + from_secret: drone_ssh_lumbung.space + depends_on: + - push hugo image + - push scripts image +trigger: + branch: + - main + event: + exclude: + - pull_request diff --git a/.gitignore b/.gitignore index 60a2de3..2f75c30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ +*.lock .env -/public/ +.venv/ /content/ -.venv/ \ No newline at end of file +/public/ 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/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/README.md b/README.md index a953080..c73cb80 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,47 @@ # 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 > 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? + +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? + +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` +- `docker service logs -f beta_lumbung_space_feed` + +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). + +### 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 -`hugo serve --watch` +[Install Hugo](https://gohugo.io/getting-started/installing/) and `hugo serve --watch` ### Generate `lumbung[dot]space` posts @@ -28,6 +58,27 @@ 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`. + +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)` +- `make push-hugo` +- `make push-scripts` + +### Manually deploy the site + +(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 ed0b86f..8bc161a 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 @@ -25,9 +33,69 @@ 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/calendar + 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 + " + + 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 6f5a0d8..389c749 100644 --- a/makefile +++ b/makefile @@ -7,6 +7,18 @@ 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 -.PHONY: serve +push-hugo: + @docker build -t decentral1se/beta.lumbung.space -f Dockerfile.hugo . && \ + docker push decentral1se/beta.lumbung.space + +push-scripts: + @docker build --no-cache -t decentral1se/beta.lumbung.space-scripts -f Dockerfile.scripts . && \ + docker push decentral1se/beta.lumbung.space-scripts + +deploy: + @DOCKER_CONTEXT=lumbung.space docker stack deploy -c compose.yml beta_lumbung_space + +.PHONY: serve gen push-hugo push-scripts deploy