Skip to content

Commit e833ff6

Browse files
authored
Merge pull request #44 from pixelcorp-nl/fix-readme
Update readme
2 parents 6f09184 + 77e9d55 commit e833ff6

File tree

6 files changed

+47
-38
lines changed

6 files changed

+47
-38
lines changed

.github/workflows/test.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@ name: Tests
33
on:
44
pull_request:
55

6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
610
jobs:
711
test:
812
runs-on: ubuntu-latest
913
timeout-minutes: 10
1014

1115
steps:
1216
- name: Checkout code
13-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1418

15-
- uses: docker-practice/actions-setup-docker@master
19+
- name: Setup Docker buildx
20+
uses: docker/setup-buildx-action@v3.8.0
1621

1722
- name: Install pnpm
18-
uses: pnpm/action-setup@v2
23+
uses: pnpm/action-setup@v4
1924
with:
2025
version: latest
2126

@@ -34,10 +39,14 @@ jobs:
3439
secrets: ${{ toJSON(secrets) }}
3540

3641
- name: Setup .env file
37-
run: env >> frontend/.env
42+
run: cp frontend/.env-example frontend/.env
3843

3944
- name: Start services
4045
run: make start-detached
4146

47+
- name: Wait for services to start
48+
timeout-minutes: 2
49+
run: make wait-for-healthcheck
50+
4251
- name: Run tests
4352
run: (cd frontend && npm test)

Makefile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Start dependencies run frontend and backend seperately
22
start-deps:
3-
docker compose up --remove-orphans --build --detach redis postgres
3+
docker compose up --remove-orphans --build --detach canvas-redis canvas-postgres
44

55
# Starts all containers
66
start:
@@ -13,7 +13,7 @@ start-detached:
1313
# Wait for services to start
1414
wait-for-healthcheck: $(eval SHELL:=/bin/bash)
1515
while [ 1 ]; do \
16-
STATUS=$$(docker inspect -f {{.State.Health.Status}} frontend); \
16+
STATUS=$$(docker inspect -f {{.State.Health.Status}} canvas-frontend); \
1717
echo "$$STATUS"; \
1818
[[ "$$STATUS" = "unhealthy" ]] && sleep 1 && docker compose logs && exit 1; \
1919
[[ "$$STATUS" = "healthy" ]] && exit 0; \
@@ -25,20 +25,20 @@ down:
2525
docker compose down --remove-orphans --timeout 4
2626

2727
nuke-postgres:
28-
docker compose down --remove-orphans --timeout 4 postgres
29-
rm -rf frontend/postgres-db
30-
docker compose up --remove-orphans --build --detach postgres
28+
docker compose down --remove-orphans --timeout 4 canvas-postgres
29+
rm -rf frontend/postgres-db postgres-db
30+
docker compose up --remove-orphans --build --detach canvas-postgres
3131

3232
nuke-redis:
33-
docker compose down --remove-orphans --timeout 4 redis
34-
rm -rf frontend/redis-db
35-
docker compose up --remove-orphans --build --detach redis
36-
37-
nuke-all:
38-
docker compose down --remove-orphans --timeout 4
39-
rm -rf frontend/postgres-db
40-
rm -rf frontend/redis-db
41-
docker compose up --remove-orphans --build --detach redis postgres
33+
docker compose down --remove-orphans --timeout 4 canvas-redis
34+
rm -rf frontend/redis-db redis-db
35+
docker compose up --remove-orphans --build --detach canvas-redis
36+
37+
nuke-db:
38+
docker compose down --remove-orphans --timeout 4 canvas-redis canvas-postgres
39+
rm -rf frontend/postgres-db postgres-db
40+
rm -rf frontend/redis-db redis-db
41+
docker compose up --remove-orphans --build --detach canvas-redis canvas-postgres
4242

4343
# Run tests
4444
test:

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Pixels introduces students to the exciting world of programming by enabling them
1919

2020
## Prerequisites
2121

22-
- [Node.js](https://nodejs.org/) >=18.x
22+
- [Node.js](https://github.com/nodesource/distributions) >=20.x
2323
- [pnpm](https://pnpm.io/installation) >=8.x
24-
- [Docker](https://www.docker.com/) >=23.x
24+
- [Docker](https://docs.docker.com/get-started/get-docker/) >=25.x
2525

2626
## Development
2727

@@ -35,10 +35,10 @@ cd canvas.edu
3535
2. Set up environment variables
3636
```shell
3737
cp frontend/.env-example frontend/.env
38-
# by default you don't have to change anything in the .env file
38+
# You probably don't have to change anything in the .env file, but take a look nonetheless
3939
```
4040

41-
3. Start dependencies (database, etc.)
41+
3. Start dependencies (postgres database, etc.)
4242
```sh
4343
make start-deps
4444
```
@@ -81,7 +81,7 @@ If you break the database(s), you can clear them by:
8181
# cd to the root of the project
8282
make nuke-postgres # if you want to clear the postgres database
8383
make nuke-redis # if you want to clear the redis database
84-
make nuke-all # if you want to clear both databases
84+
make nuke-db # if you want to clear both databases
8585
```
8686

8787

docker-compose.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
version: "3.7"
22
services:
3-
frontend:
4-
container_name: frontend
3+
canvas-frontend:
4+
container_name: canvas-frontend
55
restart: unless-stopped
66
build: ./frontend
77
ports:
88
- 5173:5173
99
env_file:
1010
- ./frontend/.env
1111
depends_on:
12-
- redis
13-
- postgres
12+
- canvas-redis
13+
- canvas-postgres
1414

15-
postgres:
16-
container_name: postgres
15+
canvas-postgres:
16+
container_name: canvas-postgres
1717
restart: unless-stopped
18-
image: postgres:alpine
18+
image: postgres:17.2-alpine3.21
1919
environment:
2020
POSTGRES_PASSWORD: postgres
2121
ports:
2222
- 5432:5432
2323
volumes:
2424
- ./postgres-db:/var/lib/postgresql/data
2525

26-
redis:
27-
container_name: redis
28-
image: redis:alpine
26+
canvas-redis:
27+
container_name: canvas-redis
28+
image: redis:7.4.2-alpine
2929
restart: unless-stopped
3030
volumes:
3131
- ./redis-db:/data

frontend/.env-example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
PRIVATE_REDIS_URL=redis://redis:16379
2-
PRIVATE_POSTGRES_URL=postgres://postgres:postgres@postgres:5432/postgres
1+
PRIVATE_REDIS_URL=redis://canvas-redis:6379
2+
PRIVATE_POSTGRES_URL=postgres://postgres:postgres@canvas-postgres:5432/postgres
33
PUBLIC_CANVAS_ID=42
44
PUBLIC_CANVAS_WIDTH=200
55
PUBLIC_CANVAS_HEIGHT=200

frontend/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-alpine as builder-main
1+
FROM node:18-alpine AS builder-main
22
WORKDIR /app
33

44
RUN npm i -g pnpm
@@ -12,11 +12,11 @@ RUN pnpm run build
1212
RUN pnpm prune --prod
1313

1414
# =============== MAIN ===============
15-
FROM gcr.io/distroless/nodejs:18 as main
15+
FROM node:18-alpine AS main
1616
ENV NODE_ENV=production
1717
ENV PORT=5173
1818
WORKDIR /app
19-
# HEALTHCHECK --interval=5s --timeout=5s --start-period=10s --retries=3 CMD wget -q -O - http://localhost:5173/health
19+
HEALTHCHECK --interval=5s --timeout=1s --start-period=1s --retries=3 CMD wget -q -O - http://127.0.0.1:5173/health
2020

2121
COPY --from=builder-main /app/package.json ./package.json
2222
# COPY --from=builder-main /app/node_modules ./node_modules

0 commit comments

Comments
 (0)