Compare commits

...

10 Commits

Author SHA1 Message Date
toqvist 318db9322f Update readme 2024-04-05 09:45:04 +02:00
3wc 9d3e600eae Fix depends_on 2024-04-04 12:00:57 -03:00
3wc 2184c11448 Add docker stack auto-deployment to lumbung server 2024-04-04 11:59:14 -03:00
3wc a57206f8b2 Set nginx mime types 2024-04-04 11:50:41 -03:00
3wc 35afa4a755 Make docker entrypoint executable 2024-04-04 11:39:11 -03:00
3wc a1f3187bc7 Move entrypoint to right location 😳 2024-04-04 11:31:48 -03:00
3wc a5cac66c3f Further entrypoint tweak 2024-04-04 11:30:34 -03:00
3wc 509b6b5e8b Add docker entrypoint for loading secrets 2024-04-04 11:29:05 -03:00
3wc 7f508fc04b Switch to ruangrupa org for image publishing 2024-04-04 10:49:40 -03:00
toqvist 974cee1cf4 Disable pre-ssg getPosts 2024-04-04 15:24:43 +02:00
8 changed files with 168 additions and 8 deletions

View File

@ -8,7 +8,7 @@ steps:
username: 3wordchant
password:
from_secret: git_autonomic_zone_token_3wc
repo: git.autonomic.zone/autonomic-cooperative/lumbung-kios-astro
repo: git.autonomic.zone/ruangrupa/lumbung-kios-astro
auto_tag: true
registry: git.autonomic.zone
context: astro
@ -20,12 +20,28 @@ steps:
username: 3wordchant
password:
from_secret: git_autonomic_zone_token_3wc
repo: git.autonomic.zone/autonomic-cooperative/lumbung-kios-payload
repo: git.autonomic.zone/ruangrupa/lumbung-kios-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
settings:
stack: kios_lumbung_space
host: lumbung.space
deploy_key:
from_secret: drone_ssh_lumbung.space
environment:
DOMAIN: kios.lumbung.space
STACK_NAME: kios_lumbung_space
SECRET_PAYLOAD_SECRET_VERSION: v1
SECRET_TOKEN_VERSION: v1
SECRET_MONGO_PASSWORD_VERSION: v1
depends_on:
- publish astro container
- publish payload container
trigger:
branch:
- main

View File

@ -2,6 +2,26 @@
Astroad is a pre-configured setup for Astro and Payloadcms, designed to make it easy for you to start building your website. With Astroad, 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.
## Important notes
### Adding dependencies
1. When adding a dedpendency to astro or payload, you must regenerate the yarn.lock file for the dev server toinstall the dependencies.
2. Regenerate the lock file:
`cd astro` or `cd payload`
`rm yarn.lock`
`yarn install`
3. Restart dev server `yarn dev`
## Dev server getting stuck
Sometimes the dev script gets stuck, for an unknown reason:
```
[+] Running 3/0
✔ Container astroad-mongo Running 0.0s
✔ Container astroad-payload Running 0.0s
✔ Container astroad-astro Running
```
Running `yarn stop` and then `yarn dev` should resolve the issue.
## Prerequisites
Before getting started with Astroad, make sure you have the necessary software installed:

View File

@ -3,6 +3,7 @@ events {
}
http {
include mime.types;
gzip on;
gzip_vary on;
gzip_proxied any;
@ -32,4 +33,4 @@ http {
error_page 404 /error_page.html;
}
}
}

View File

@ -1,8 +1,9 @@
---
import BaseLayout from "@/layouts/BaseLayout.astro";
import { getPosts } from "@/utils/payload";
//import { getPosts } from "@/utils/payload";
//const posts = await getPosts();
import '../styles/global.css'
const posts = await getPosts();
---
<BaseLayout title="Astroad">
@ -22,7 +23,7 @@ const posts = await getPosts();
</p>
<h2 class="mt-6 font-bold text-2xl">Posts</h2>
<div class="flex gap-4 mt-3 flex-wrap">
{
<!-- {
posts.length > 0 ? (
posts.map((post) => (
<a href={`/posts/${post.id}/`}>
@ -39,7 +40,7 @@ const posts = await getPosts();
) : (
<p>Add Posts in Payloadcms</p>
)
}
} -->
</div>
</main>
</BaseLayout>

88
compose.yml Normal file
View File

@ -0,0 +1,88 @@
---
version: "3.8"
services:
app:
image: git.autonomic.zone/ruangrupa/lumbung-kios-astro:latest
environment:
- PAYLOAD_URL=kios_lumbung_space_app
secrets:
- mongo_password
- payload_secret
networks:
- proxy
- internal
deploy:
update_config:
failure_action: rollback
order: start-first
labels:
- "traefik.enable=true"
- "traefik.http.services.${STACK_NAME}-astro.loadbalancer.server.port=80"
- "traefik.http.routers.${STACK_NAME}-astro.rule=Host(`${DOMAIN}`)"
- "traefik.http.routers.${STACK_NAME}-astro.entrypoints=web-secure"
- "traefik.http.routers.${STACK_NAME}-astro.tls.certresolver=production"
payload:
image: git.autonomic.zone/ruangrupa/lumbung-kios-payload:latest
environment:
- "NAME=kios"
- "PAYLOAD_URL=${STACK_NAME}-payload"
- "PAYLOAD_PORT=3001"
- "PAYLOAD_SECRET_FILE=/run/secrets/payload_secret"
- "MONGODB_USER=mongo"
- "MONGODB_HOST=${STACK_NAME}_mongo"
- "MONGODB_PORT=27017"
- "MONGODB_PASSWORD_FILE=/run/secrets/mongo_password"
- "TOKEN=${TOKEN}"
secrets:
- mongo_password
- payload_secret
networks:
- proxy
- internal
deploy:
update_config:
failure_action: rollback
order: start-first
labels:
- "traefik.enable=true"
- "traefik.http.services.${STACK_NAME}-payload.loadbalancer.server.port=3001"
# FIXME switch to /admin probably using PathPrefix
- "traefik.http.routers.${STACK_NAME}-payload.rule=Host(`admin.${DOMAIN}`)"
- "traefik.http.routers.${STACK_NAME}-payload.entrypoints=web-secure"
- "traefik.http.routers.${STACK_NAME}-payload.tls.certresolver=production"
mongo:
image: mongo:6.0.5
restart: unless-stopped
volumes:
- mongo:/data/db
command:
- --storageEngine=wiredTiger
environment:
- "MONGO_INITDB_ROOT_USERNAME=mongo"
- "MONGO_INITDB_ROOT_PASSWORD_FILE=/run/secrets/mongo_password"
secrets:
- mongo_password
networks:
- internal
networks:
proxy:
external: true
internal:
secrets:
payload_secret:
external: true
name: ${STACK_NAME}_payload_secret_${SECRET_PAYLOAD_SECRET_VERSION}
token:
external: true
name: ${STACK_NAME}_token_${SECRET_TOKEN_VERSION}
mongo_password:
external: true
name: ${STACK_NAME}_mongo_password_${SECRET_MONGO_PASSWORD_VERSION}
volumes:
mongo:

View File

@ -26,4 +26,6 @@ COPY --from=build /build/tsconfig.json ./tsconfig.json
COPY --from=build /build/dist ./dist
COPY --from=build /build/build ./build
EXPOSE 3000
CMD ["yarn", "serve"]
COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["yarn", "serve"]

32
payload/docker-entrypoint.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
set -eu
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
file_env "TOKEN"
file_env "MONGODB_PASSWORD"
file_env "PAYLOAD_SECRET"
export MONGODB_URI="mongodb://$MONGODB_USER:$MONGODB_PASSWORD@$MONGODB_HOST:$MONGODB_PORT"
"$@"