From 0a7b0e98b268c6417b04864656b4db5c2fb7eb3e Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Sun, 19 May 2024 19:14:43 -0300 Subject: [PATCH 1/6] README and .drone.yml updates Re autonomic-cooperative/astro-payload-template#3 --- .drone.yml | 20 +++++--------------- README.md | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2558000..732a725 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,11 +4,11 @@ name: publish pipeline steps: - name: publish astro container image: plugins/docker - settings: + settings: &docker-build-settings username: 3wordchant password: from_secret: git_autonomic_zone_token_3wc - # NOTE: edit this if you want your image called something else + # NOTE: edit this if you want your image called something else repo: git.autonomic.zone/autonomic-cooperative/astro-payload-test-astro auto_tag: true registry: git.autonomic.zone @@ -16,29 +16,19 @@ steps: dockerfile: astro/Dockerfile - name: publish payload dev container image: plugins/docker - settings: - username: 3wordchant - password: - from_secret: git_autonomic_zone_token_3wc + settings: &payload-build-settings + << *docker-build-settings # NOTE: edit this if you want your image called something else repo: git.autonomic.zone/autonomic-cooperative/astro-payload-test-payload-dev - auto_tag: true - registry: git.autonomic.zone context: payload dockerfile: payload/Dockerfile target: dev - name: publish payload prod container image: plugins/docker settings: + <<: *payload-build-settings username: 3wordchant - password: - from_secret: git_autonomic_zone_token_3wc - # NOTE: edit this if you want your image called something else repo: git.autonomic.zone/autonomic-cooperative/astro-payload-test-payload - auto_tag: true - registry: git.autonomic.zone - context: payload - dockerfile: payload/Dockerfile target: prod - name: deploy stack image: git.coopcloud.tech/coop-cloud/stack-ssh-deploy:latest diff --git a/README.md b/README.md index fe142c1..f0ab7fb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,16 @@ -# How to use this template +# Paystro + +Paystro is a pre-configured setup for Astro and Payloadcms, designed to make it easy for you to start building your website. With Paystro, you'll have a complete development environment that you can run locally using Docker. This setup simplifies the testing and development of your website before deploying it to a production environment. + +## Architecture + +Paystro is a fork of [Astroad](https://github.com/mooxl/astroad). + +Unlike Astroad – where the "Astro" image is the built static site served with Nginx – Paystro's Astro image is a builder image. + +In Paystro, the Docker stack just contains Payload and a generic Nginx container. + +## How to use this template 1. Create a new Gitea repository based on this template repo (choose at least "git content") @@ -11,24 +23,29 @@ To set up deployment: including adding an SSH key as an organisational secret for the organisation this project is in (see [Autonomic internal docs](https://docz.autonomic.zone/doc/setting-up-auto-deployment-using-drone-I4j2onjaKT)) -2. Edit `.drone.yml` to define the server to host on, and the +2. Edit `.drone.yml` to set variables: + - `HOST`: hostname or IP address of the server to deploy to (e.g. + `vps.example.tld`) + - `DOMAIN`: domain name of the live site (e.g. `site.example.tld`) + - `STACK_NAME`: the Docker stack name, usually `$DOMAIN` with dots replaced + with underscores (e.g. `site_example_tld`) `STACK_NAME` / `DOMAIN` of the deployed app. -3. Generate secrets (`openssl rand -hex 32` works well) for `PAYLOAD_SECRET` and +3. Make sure that DNS records for `$DOMAIN` and `admin.$DOMAIN`, pointing to + `$HOST`, are defined. +4. Generate secrets (`openssl rand -hex 32` works well) for `PAYLOAD_SECRET` and `MONGO_PASSWORD`. Insert the personal user token for a Drone bot user (e.g. `autono-bot`) as `TOKEN`). For all of them, use something like `echo "foobar" | docker secret create paystro_swarm-demo_autonomic_zone_token_v1 -`, where `paystro_swarm-demo_autonomic_zone` is the `STACK_NAME`. -4. Activate the repo in Drone +5. Activate the repo in Drone -# Paystro +--- -Paystro is a pre-configured setup for Astro and Payloadcms, designed to make it easy for you to start building your website. With Paystro, you'll have a complete development environment that you can run locally using Docker. This setup simplifies the testing and development of your website before deploying it to a production environment. - -Paystro is a fork of [Astroad](https://github.com/mooxl/astroad). +# ${REPO_NAME} ## Prerequisites -Before getting started with Paystro, make sure you have Docker installed (and, if your Docker doesn't include `docker compose`, the separate `docker-compose` tool). +Before getting started, make sure you have Docker installed (and, if your Docker doesn't include `docker compose`, the separate `docker-compose` tool). ## Configuration @@ -44,8 +61,4 @@ The `docker-compose.yml` file includes everything you need to run the containers Whenever the repository is updated, Drone builds new Docker images for Payload and Astro, and deploys a new Docker Swarm stack to the `HOST` configured in `.drone.yml`. -Unlike Astroad – where the "Astro" image is the built static site served with Nginx – Paystro's Astro image is a builder image. - -In Paystro, the Docker stack just contains Payload and a generic Nginx container. - -Whenever changes are made to Payload content, Drone uses the Astro builder image to regenerate the static site, and publish it to the Nginx container by copying it into the Docker volume. +Whenever changes are made to Payload content on the live site, Drone uses the Astro builder image to regenerate the static site, and publish it to the Nginx container by copying it into the Docker volume. From b83ce8c97aed5c1b6ee5bab04e339d47739fdf03 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Sun, 19 May 2024 19:19:41 -0300 Subject: [PATCH 2/6] Fix YAML syntax error --- .drone.yml | 2 +- README.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 732a725..8c798a1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,7 +17,7 @@ steps: - name: publish payload dev container image: plugins/docker settings: &payload-build-settings - << *docker-build-settings + <<: *docker-build-settings # NOTE: edit this if you want your image called something else repo: git.autonomic.zone/autonomic-cooperative/astro-payload-test-payload-dev context: payload diff --git a/README.md b/README.md index f0ab7fb..20e9d56 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ To set up deployment: - `DOMAIN`: domain name of the live site (e.g. `site.example.tld`) - `STACK_NAME`: the Docker stack name, usually `$DOMAIN` with dots replaced with underscores (e.g. `site_example_tld`) - `STACK_NAME` / `DOMAIN` of the deployed app. + - `DRONE_URL`: root URL for the Drone instance (e.g. + `https://drone.example.tld`) 3. Make sure that DNS records for `$DOMAIN` and `admin.$DOMAIN`, pointing to `$HOST`, are defined. 4. Generate secrets (`openssl rand -hex 32` works well) for `PAYLOAD_SECRET` and From b8b10670f965c75c06ca780d35d4666851687fb4 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 20 May 2024 01:08:42 -0300 Subject: [PATCH 3/6] Astro build on code changes --- .drone.yml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.drone.yml b/.drone.yml index 8c798a1..2581f2c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,6 +14,13 @@ steps: registry: git.autonomic.zone context: astro dockerfile: astro/Dockerfile + trigger: &exclude-event-custom + branch: + - main + event: + exclude: + - custom + - name: publish payload dev container image: plugins/docker settings: &payload-build-settings @@ -23,6 +30,9 @@ steps: context: payload dockerfile: payload/Dockerfile target: dev + trigger: + >>: &exclude-event-custom + - name: publish payload prod container image: plugins/docker settings: @@ -30,6 +40,9 @@ steps: username: 3wordchant repo: git.autonomic.zone/autonomic-cooperative/astro-payload-test-payload target: prod + trigger: + >>: &exclude-event-custom + - name: deploy stack image: git.coopcloud.tech/coop-cloud/stack-ssh-deploy:latest settings: @@ -50,17 +63,9 @@ steps: PAYLOAD_URL: "https://admin.paystro.swarm-demo.autonomic.zone" depends_on: - publish payload prod container -trigger: - branch: - - main - event: - exclude: - - custom ---- -kind: pipeline -name: build astro + trigger: + >>: &exclude-event-custom -steps: - name: build astro content image: git.autonomic.zone/autonomic-cooperative/astro-payload-test-astro:latest environment: @@ -80,7 +85,3 @@ steps: dest: /usr/share/nginx/html/ deploy_key: from_secret: drone_ssh_swarm-demo.autonomic.zone - -trigger: - event: - - custom From e1a782ad39134f7c9fe756c40d62f563e0fa01db Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 20 May 2024 01:11:19 -0300 Subject: [PATCH 4/6] Fix YAML syntax --- .drone.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2581f2c..a5c7bb2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,7 +31,7 @@ steps: dockerfile: payload/Dockerfile target: dev trigger: - >>: &exclude-event-custom + << *exclude-event-custom - name: publish payload prod container image: plugins/docker @@ -41,7 +41,7 @@ steps: repo: git.autonomic.zone/autonomic-cooperative/astro-payload-test-payload target: prod trigger: - >>: &exclude-event-custom + << *exclude-event-custom - name: deploy stack image: git.coopcloud.tech/coop-cloud/stack-ssh-deploy:latest @@ -64,7 +64,7 @@ steps: depends_on: - publish payload prod container trigger: - >>: &exclude-event-custom + << *exclude-event-custom - name: build astro content image: git.autonomic.zone/autonomic-cooperative/astro-payload-test-astro:latest From db712ecffcdb1069067f8784ae99e7080578815c Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 20 May 2024 01:14:39 -0300 Subject: [PATCH 5/6] Add missing drone dep --- .drone.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.drone.yml b/.drone.yml index a5c7bb2..c93abe8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -74,6 +74,7 @@ steps: - cd astro - mv /base/node_modules . - yarn build + - name: copy built content to stack image: git.coopcloud.tech/coop-cloud/docker-cp-deploy:latest settings: @@ -85,3 +86,5 @@ steps: dest: /usr/share/nginx/html/ deploy_key: from_secret: drone_ssh_swarm-demo.autonomic.zone + depends_on: + - build astro content From 3aa5ec6a69ad8cd1014700e5cd97edbca2b48536 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 20 May 2024 01:17:29 -0300 Subject: [PATCH 6/6] Dependency experiment --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index c93abe8..c3d27a8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -74,6 +74,8 @@ steps: - cd astro - mv /base/node_modules . - yarn build + depends_on: + - deploy stack - name: copy built content to stack image: git.coopcloud.tech/coop-cloud/docker-cp-deploy:latest