Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build/change structure #78

Closed
wants to merge 8 commits into from
Closed
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
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04

ENV HOME=/home/vscode

# Install dependencies
RUN sudo apt-get update
RUN curl -sS https://starship.rs/install.sh | sh -s -- --yes
RUN echo 'eval "$(starship init bash)"' >> $HOME/.bashrc
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "Playground",
"dockerComposeFile": "./docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces",
"overrideCommand": true,
"shutdownAction": "stopCompose",
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "1.22"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
}
},
"customizations": {
"vscode": {
"extensions": ["EditorConfig.EditorConfig", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "svelte.svelte-vscode", "golang.go", "Grafana.vscode-jsonnet", "redhat.vscode-yaml", "ionutvmi.path-autocomplete", "GitHub.vscode-github-actions"]
}
}
}
210 changes: 210 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile
volumes:
- ../:/workspaces:cached
command: sleep infinity
networks:
- playground

postgres:
image: docker.io/library/postgres:16-alpine
ports:
- '${DB_PORT:-5432}:5432'
volumes:
- 'postgres-data:/var/lib/postgresql/data'
environment:
POSTGRES_USER: ${DB_USERNAME:-postgres}
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
POSTGRES_DB: ${DB_DATABASE:-postgres}
healthcheck:
test:
[
'CMD',
'pg_isready',
'-q',
'-d',
'${DB_USERNAME:-postgres}',
'-U',
'${DB_PASSWORD:-postgres}',
]
retries: 3
timeout: 5s
networks:
- playground

redis:
image: docker.io/library/redis:7.2.4-alpine
ports:
- '${REDIS_PORT:-6379}:6379'
volumes:
- 'redis-data:/data'
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
retries: 3
timeout: 5s
networks:
- playground

minio:
image: docker.io/minio/minio
ports:
- '${S3_PORT:-9000}:9000'
- '${S3_CONSOLE_PORT:-8900}:8900'
volumes:
- 'minio-data:/data/minio'
environment:
MINIO_ROOT_USER: ${S3_ACCESS_KEY_ID:-miniosudo}
MINIO_ROOT_PASSWORD: ${S3_SECRET_ACCESS_KEY:-miniosudo}
command: minio server /data/minio --console-address ":8900"
healthcheck:
test: ['CMD', 'curl', '-f', 'http://127.0.0.1:9000/minio/health/live']
retries: 3
timeout: 5s
networks:
- playground

minio-client:
image: docker.io/minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
/usr/bin/mc config host add myminio http://minio:9000 ${S3_ACCESS_KEY_ID:-miniosudo} ${S3_SECRET_ACCESS_KEY:-miniosudo};
/usr/bin/mc rm -r --force myminio/local;
/usr/bin/mc mb myminio/local;
/usr/bin/mc policy set download myminio/local;
exit 0;
"
networks:
- playground

# mailhog:
# image: docker.io/mailhog/mailhog:v1.0.0
# ports:
# - '${MAILHOG_PORT:-1025}:1025'
# - '${MAILHOG_DASHBOARD_PORT:-8025}:8025'
# volumes:
# - ../config:/.config
# environment:
# - MH_AUTH_FILE="/.config/mailhog/auth"
# networks:
# - playground

mailslurper:
image: docker.io/oryd/mailslurper:latest-smtps
ports:
- '4436:4436'
- '4437:4437'
networks:
- playground

postgres-kratos:
image: docker.io/library/postgres:16-alpine
ports:
- '${DB_PORT:-5431}:5432'
volumes:
- 'kratos-postgres:/var/lib/postgresql/data'
environment:
POSTGRES_USER: ${DB_USERNAME:-postgres}
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
POSTGRES_DB: ${DB_DATABASE:-postgres}
healthcheck:
test:
[
'CMD',
'pg_isready',
'-q',
'-d',
'${DB_USERNAME:-postgres}',
'-U',
'${DB_PASSWORD:-postgres}',
]
retries: 3
timeout: 5s
networks:
- playground

kratos-migrate:
image: docker.io/oryd/kratos:v1.0.0
depends_on:
- postgres-kratos
environment:
- DSN=postgres://postgres:postgres@postgres-kratos:5432/postgres?sslmode=disable&max_conns=20&max_idle_conns=4
volumes:
- type: bind
source: ../config/kratos/email-password
target: /etc/config/kratos
command: -c /etc/config/kratos/kratos.yml migrate sql -e --yes
restart: on-failure
networks:
- playground

kratos:
image: docker.io/oryd/kratos:v1.0.0
depends_on:
- kratos-migrate
ports:
- '4433:4433' # public
- '4434:4434' # admin
restart: unless-stopped
environment:
- DSN=postgres://postgres:postgres@postgres-kratos:5432/postgres?sslmode=disable&max_conns=20&max_idle_conns=4
- LOG_LEVEL=trace
- SERVE_PUBLIC_BASE_URL=http://127.0.0.1:4455/.ory/kratos/public/
command: serve -c /etc/config/kratos/kratos.yml --dev --watch-courier
volumes:
- type: bind
source: ../config/kratos/email-password
target: /etc/config/kratos
networks:
- playground

kratos-selfservice-ui-node:
image: docker.io/oryd/kratos-selfservice-ui-node:v0.13.0-20
depends_on:
- kratos
restart: on-failure
ports:
- 4435:4435
environment:
- PORT=4435
- KRATOS_BROWSER_URL=http://127.0.0.1:4455/.ory/kratos/public
- JWKS_URL=http://oathkeeper:4456/.well-known/jwks.json
- SECURITY_MODE=jwks
- COOKIE_SECRET=playground12345
- CSRF_COOKIE_NAME=__locahost-example.com-x-csrf-token
- CSRF_COOKIE_SECRET=playground12345
- KRATOS_PUBLIC_URL=http://kratos:4433/
networks:
- playground

oathkeeper:
image: docker.io/oryd/oathkeeper:v0.40.6
depends_on:
- kratos
ports:
- 4455:4455
- 4456:4456
command:
serve proxy -c "/etc/config/oathkeeper/oathkeeper.yml"
environment:
- LOG_LEVEL=debug
restart: on-failure
networks:
- playground
volumes:
- ../config/oathkeeper:/etc/config/oathkeeper

volumes:
postgres-data:
redis-data:
minio-data:
kratos-postgres:
kratos-sqlite:
networks:
playground:
36 changes: 26 additions & 10 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,39 @@ on:
- "main"
- "development"
paths:
- "node/**"
- "backend/node/**"
- ".github/workflows/node.yml"
pull_request:
branches:
- "main"
- "development"
paths:
- "node/**"
- "backend/node/**"
- ".github/workflows/node.yml"

jobs:
build:
name: Build (Node v${{ matrix.node }})
runs-on: ubuntu-latest
services:
postgres:
image: docker.io/library/postgres:16-alpine
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
strategy:
matrix:
node: ['18', '20']
node: ['20', '21', '22']
env:
FOLDER: node
FOLDER: backend/node

steps:
- name: Checkout code
Expand All @@ -33,7 +47,7 @@ jobs:
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Set up Node
Expand All @@ -46,7 +60,7 @@ jobs:
- name: Install dependencies
run: |
cd ${{ env.FOLDER }}
pnpm i
pnpm install

- name: Run linter
run: |
Expand All @@ -58,6 +72,11 @@ jobs:
cd ${{ env.FOLDER }}
pnpm prettier

- name: Run typecheck
run: |
cd ${{ env.FOLDER }}
pnpm typecheck

- name: Run build
run: |
cd ${{ env.FOLDER }}
Expand All @@ -66,11 +85,8 @@ jobs:
- name: Run tests
run: |
cd ${{ env.FOLDER }}
cp .env.example .env
docker compose up -d
sleep 10s
cp .env.testing .env
pnpm migrate:up
pnpm seed:run
pnpm test
docker compose down -v

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@

# Dependency directories
node_modules

*.pnpm-store
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"eslint.workingDirectories": [
"./node"
"./backend/node"
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# templates

- JWT authentification (with refresh token)
- JWT authentification (with refresh token).
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions backend/node/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
APP_NAME=Playground
APP_PORT=3000
APP_URL=http://localhost:3000

DB_HOST=postgres
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE=postgres

AWS_ENDPOINT=127.0.0.1
AWS_PORT=9000
AWS_DEFAULT_REGION=ap-southeast-1
AWS_ACCESS_KEY_ID=miniosudo
AWS_SECRET_ACCESS_KEY=miniosudo

REDIS_HOST=redis
REDIS_PORT=6379
7 changes: 4 additions & 3 deletions node/.env.example → backend/node/.env.testing
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
APP_NAME=Randedid
APP_NAME=Playground
APP_PORT=3000
APP_URL=http://localhost:3000

DB_HOST=127.0.0.1
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=postgres
Expand All @@ -13,7 +14,7 @@ AWS_DEFAULT_REGION=ap-southeast-1
AWS_ACCESS_KEY_ID=miniosudo
AWS_SECRET_ACCESS_KEY=miniosudo

REDIS_HOST=127.0.0.1
REDIS_HOST=localhost
REDIS_PORT=6379

JWT_ACCESS_SECRET=jwtaccesssecret
Expand Down
File renamed without changes.
Loading
Loading