Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
.devcontainer
.env
.env.example
.git
.gitignore
.github
.husky
.lintstagedrc
.nvmrc
.nx
.pnpm-store
.prettier*
**/node_modules
**/dist
npm-debug.log
docker-compose.yml
Dockerfile
.lintstagedrc
.prettier*
.env
.env.example
fly.toml
knip.json
README.md
services
9 changes: 2 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ jobs:
- name: Install dependencies
run: pnpm install --ignore-scripts

- name: Set up environment
- name: Run E2E tests
run: |
cp .env.example .env

- name: Start Docker services
run: docker compose up -d --wait

- name: Run E2E tests
run: pnpm run test:e2e
pnpm run test:e2e
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,3 @@

vite.config.*.timestamp*
vitest.config.*.timestamp*

# Generated files
apps/e2e/src/generated/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pnpm-lock.yaml
drizzle
packages/post-images/tests/fixtures
e2e/tests/src/generated
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,19 @@ COPY --parents apps/*/package.json .
COPY --parents packages/*/package.json .
RUN pnpm install

# Copy & build the app
FROM base AS e2e-proxy

# Additionally install e2e dependencies
COPY --parents e2e/mocks/package.json .
RUN pnpm install

COPY . .
RUN pnpm build:all

CMD [ "/bin/sh", "-c", "parallel --jobs 2 --line-buffer --halt now,done=1 node --experimental-strip-types {} ::: apps/api/src/index.ts apps/worker/src/index.ts" ]
CMD [ "/bin/sh", "-c", "node --watch e2e/mocks/src/index.ts" ]

FROM base AS app

# Copy the app
COPY --exclude=e2e . .

CMD [ "/bin/sh", "-c", "parallel --jobs 2 --line-buffer --halt now,done=1 node {} ::: apps/api/src/index.ts apps/worker/src/index.ts" ]
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ pnpm dev

Once it's running, you should see the API documentation hosted at `http://localhost:3000/docs/`. This can also be used to test the endpoints!

#### Testing in Docker

To test the server in its docker container, instead of running `pnpm dev`, you can build & start the docker image with:

```bash
docker compose --profile=app watch
```

## Roadmap

- Manage tasks for post image & metadata generation (initial deployment)
Expand Down
1 change: 0 additions & 1 deletion apps/e2e/.gitignore

This file was deleted.

22 changes: 0 additions & 22 deletions apps/e2e/eslint.config.mjs

This file was deleted.

35 changes: 0 additions & 35 deletions apps/e2e/project.json

This file was deleted.

47 changes: 0 additions & 47 deletions apps/e2e/src/lib/spawn-app.ts

This file was deleted.

19 changes: 0 additions & 19 deletions apps/e2e/tsconfig.json

This file was deleted.

21 changes: 0 additions & 21 deletions apps/e2e/vite.config.ts

This file was deleted.

2 changes: 2 additions & 0 deletions apps/worker/src/createWorker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Worker } from "bullmq";
import type { TasksValues } from "@playfulprogramming/bullmq";
import { redis } from "@playfulprogramming/redis";
import { env } from "@playfulprogramming/common";

export function createWorker<T extends TasksValues>(
task: T,
Expand All @@ -9,6 +10,7 @@ export function createWorker<T extends TasksValues>(
const processorFile = new URL(import.meta.resolve(processor));
const worker = new Worker(task, processorFile, {
connection: redis as never,
prefix: env.BULLMQ_PREFIX,
concurrency: 2,
removeOnComplete: { count: 1000 },
removeOnFail: { count: 5000 },
Expand Down
35 changes: 35 additions & 0 deletions docker-compose.e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
services:
app:
build: .
image: playful-programming-hoof:latest
env_file:
- .env
environment:
NODE_USE_ENV_PROXY: 1
NODE_EXTRA_CA_CERTS: /var/app/e2e/mocks/src/generated/cert.pem
HTTP_PROXY: http://proxy:3999
HTTPS_PROXY: http://proxy:3999
NO_PROXY: "localhost, 127.0.0.1"
S3_ENDPOINT: http://rustfs:9000
POSTGRES_URL: postgresql://postgres:unicorn@pgsql:5432/${E2E_POSTGRES_DATABASE}
REDIS_URL: redis://redis:6379
BULLMQ_PREFIX: ${E2E_BULLMQ_PREFIX}
volumes:
- ./e2e:/var/app/e2e:ro
networks: [shared]
ports:
- "${E2E_PORT}:3000"
Comment thread
fennifith marked this conversation as resolved.
healthcheck:
test: wget --no-verbose --tries=1 --spider http://0.0.0.0:3000 && wget --no-verbose --tries=1 --spider http://0.0.0.0:3001 || exit 1
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
start_interval: 100ms
post_start:
- command: node packages/db/scripts/migrate.ts

networks:
shared:
name: hoof_shared_network
external: true
45 changes: 26 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: playful-programming-cms
name: playful-programming-hoof

services:
pgsql:
Expand All @@ -13,23 +13,30 @@ services:
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
start_interval: 500ms
networks: [shared]
ports:
- "5432:5432"

redis:
image: redis:8.2.1-alpine3.22
volumes:
- redis_storage:/data
networks: [shared]
ports:
- "6379:6379"
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
start_interval: 500ms

rustfs:
image: rustfs/rustfs
networks: [shared]
ports:
- "9000:9000" # API Port
- "9001:9001" # Web UI Port
Expand All @@ -49,33 +56,33 @@ services:
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
start_interval: 500ms

app:
build: .
env_file:
- .env
proxy:
build:
context: .
target: e2e-proxy
image: playful-programming-hoof-e2e-proxy:latest
environment:
S3_ENDPOINT: http://rustfs:9000
POSTGRES_URL: postgresql://postgres:unicorn@pgsql:5432/postgres
REDIS_URL: redis://redis:6379
ports:
- "3000:3000"
depends_on: [pgsql, redis, rustfs]
profiles: [app]
MOCK_PROXY_PORT: 3999
volumes:
- ./e2e/mocks/src:/var/app/e2e/mocks/src:ro
networks: [shared]
healthcheck:
test: wget --no-verbose --tries=1 --spider http://0.0.0.0:3000 && wget --no-verbose --tries=1 --spider http://0.0.0.0:3001 || exit 1
test: netstat -tln | grep :3999
interval: 10s
timeout: 5s
retries: 5
develop:
watch:
- path: .
action: rebuild
post_start:
- command: node --experimental-strip-types packages/db/scripts/migrate.ts
start_period: 10s
start_interval: 100ms

volumes:
pgsql_storage: {}
pgsql_backups: {}
redis_storage: {}
rustfs_storage: {}

networks:
shared:
name: hoof_shared_network
1 change: 1 addition & 0 deletions e2e/mocks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/generated
5 changes: 5 additions & 0 deletions e2e/mocks/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.mjs";

export default [...rootConfig];
Loading
Loading