Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Feb 4, 2025
2 parents 9df5ca4 + 5bb30d9 commit 60ea760
Show file tree
Hide file tree
Showing 241 changed files with 11,502 additions and 18,682 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.git
.github
node_modules
npm-debug.log
docker-compose.yml
Dockerfile
.dockerignore
.gitignore
**/data
.env
105 changes: 0 additions & 105 deletions .github/workflows/ci.yml

This file was deleted.

169 changes: 169 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
name: node

on:
push:
branches:
- "master"
pull_request:
branches:
- "master"

jobs:
test:
runs-on: ubuntu-latest

services:
redis:
image: redis:6
ports:
- 6379:6379

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build test image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
target: dev
context: .
load: true
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/blot
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/blot,mode=max
tags: ghcr.io/${{ github.repository_owner }}/blot:test-${{ github.sha }}

- name: Run tests
env:
BLOT_STRIPE_KEY: ${{ secrets.BLOT_STRIPE_KEY }}
BLOT_STRIPE_SECRET: ${{ secrets.BLOT_STRIPE_SECRET }}
BLOT_STRIPE_PRODUCT: ${{ secrets.BLOT_STRIPE_PRODUCT }}
run: |
docker run --rm \
--network name=${{ job.services.redis.network }} \
-e BLOT_REDIS_HOST=redis \
-e BLOT_STRIPE_KEY=$BLOT_STRIPE_KEY \
-e BLOT_STRIPE_SECRET=$BLOT_STRIPE_SECRET \
-e BLOT_STRIPE_PRODUCT=$BLOT_STRIPE_PRODUCT \
-v ${{ github.workspace }}/app:/usr/src/app/app \
-v ${{ github.workspace }}/scripts:/usr/src/app/scripts \
-v ${{ github.workspace }}/config:/usr/src/app/config \
-v ${{ github.workspace }}/notes:/usr/src/app/notes \
-v ${{ github.workspace }}/todo.txt:/usr/src/app/todo.txt \
-v ${{ github.workspace }}/.git:/usr/src/app/.git \
-v ${{ github.workspace }}/tests:/usr/src/app/tests \
ghcr.io/${{ github.repository_owner }}/blot:test-${{ github.sha }} \
sh -c "node /usr/src/app/app/documentation/build/index.js --no-watch --skip-zip && node tests && npx depcheck --ignores=depcheck,nyc,nodemon,blessed-contrib,fontkit,text-to-svg --skip-missing"
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build production image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
target: prod
context: .
push: true
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/blot
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/blot,mode=max
tags: ghcr.io/${{ github.repository_owner }}/blot:${{ github.sha }}

- name: Verify built-in health check
env:
IMAGE: ghcr.io/${{ github.repository_owner }}/blot:${{ github.sha }}
run: |
docker network create test_network
# Start a Redis container
redis_container_id=$(docker run -d --name test_redis --network test_network redis:latest)
# Ensure Redis started successfully
if [ -z "$redis_container_id" ]; then
echo "Failed to start the Redis container. Exiting..."
exit 1
fi
echo "Waiting for Redis ($redis_container_id) to become ready..."
timeout=30
interval=2
elapsed=0
while ! docker exec $redis_container_id redis-cli ping | grep -q PONG; do
if [ $elapsed -ge $timeout ]; then
echo "Redis did not become ready within $timeout seconds. Exiting..."
docker stop $redis_container_id
docker rm $redis_container_id
exit 1
fi
sleep $interval
elapsed=$((elapsed + interval))
done
echo "Redis is ready."
# Start the app container with Redis environment variables
container_id=$(docker run -d --network test_network --env BLOT_REDIS_HOST=test_redis -p 8080:8080 $IMAGE)
# Ensure the app container started successfully
if [ -z "$container_id" ]; then
echo "Failed to start the app container. Exiting..."
docker stop $redis_container_id
docker rm $redis_container_id
exit 1
fi
echo "Waiting for the app container ($container_id) to pass the built-in health check..."
# Wait for the app container's health status to become "healthy"
timeout=60
interval=5
elapsed=0
while [ "$(docker inspect --format='{{json .State.Health.Status}}' $container_id)" != '"healthy"' ]; do
if [ $elapsed -ge $timeout ]; then
echo "Health check failed: app container did not become healthy within $timeout seconds."
echo "Final log contents:"
docker exec $container_id cat /usr/src/app/data/logs/docker/app.log
docker stop $container_id
docker rm $container_id
docker stop $redis_container_id
docker rm $redis_container_id
exit 1
fi
sleep $interval
elapsed=$((elapsed + interval))
done
echo "App container passed the health check."
# Clean up
docker stop $container_id
docker rm $container_id
docker stop $redis_container_id
docker rm $redis_container_id
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Proxy tests
name: openresty

on:
push:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: 16.14.0
node-version: 21.7.3

- name: Load dependencies
uses: actions/cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [16.14.0]
node-version: [21.7.3]
pandoc-version: [3.1.1]
redis-version: [6.2.6]

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*.log

data
app/views-built

# Eventually merge into one 'data' folder
blogs/*
Expand Down
Loading

0 comments on commit 60ea760

Please sign in to comment.