ci(v4.0.0-alpha): 🚀 running the first ci worflow

This commit is contained in:
Amruth Pillai
2023-11-05 13:17:14 +01:00
parent 2f4fc71ecb
commit eef91cf905
10 changed files with 251 additions and 83 deletions

72
tools/compose/dev.yml Normal file
View File

@ -0,0 +1,72 @@
version: "3"
# In this Docker Compose example, we only fire up the services required for local development.
# This is not advised for production use as it exposes ports to the database insecurely.
# If you're looking for a production-ready Docker Compose file, check out the `traefik.yml` file.
services:
# Database (Postgres)
postgres:
image: postgres
restart: unless-stopped
ports:
- ${POSTGRES_PORT:-5432}:5432
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${POSTGRES_DB:-postgres}
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
healthcheck:
test: ["CMD", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
# Storage (for image uploads)
minio:
image: minio/minio
restart: unless-stopped
command: server /data
ports:
- ${STORAGE_PORT:-9000}:9000
- 9001:9001 # Minio Console (Optional)
volumes:
- minio_data:/data
environment:
MINIO_ADDRESS: :9000
MINIO_CONSOLE_ADDRESS: :9001
MINIO_ROOT_USER: ${STORAGE_ACCESS_KEY:-minioadmin}
MINIO_ROOT_PASSWORD: ${STORAGE_SECRET_KEY:-minioadmin}
healthcheck:
test: ["CMD", "curl -f http://minio:9000/minio/health/live"]
start_period: 40s
interval: 30s
timeout: 10s
retries: 3
# Chrome Browser (for printing and previews)
chrome:
image: browserless/chrome
restart: unless-stopped
ports:
- ${CHROME_PORT:-8080}:3000
environment:
TOKEN: ${CHROME_TOKEN:-chrome_token}
EXIT_ON_HEALTH_FAILURE: true
PRE_REQUEST_HEALTH_CHECK: true
# Redis (for cache & server session management)
redis:
image: redis
restart: unless-stopped
command: redis-server --requirepass ${REDIS_PASSWORD:-password}
ports:
- ${REDIS_PORT:-6379}:6379
volumes:
- redis_data:/data
volumes:
minio_data:
redis_data:
postgres_data:

101
tools/compose/simple.yml Normal file
View File

@ -0,0 +1,101 @@
version: "3"
# In this Docker Compose example, it assumes that you maintain a reverse proxy externally (or chose not to).
# The only two exposed ports here are from minio (:9000) and the app itself (:3000).
# If these ports are changed, ensure that the env vars passed to the app are also changed accordingly.
services:
# Database (Postgres)
postgres:
image: postgres
restart: unless-stopped
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
healthcheck:
test: ["CMD", "pg_isready -U postgres -d postgres"]
interval: 10s
timeout: 5s
retries: 5
# Storage (for image uploads)
minio:
image: minio/minio
restart: unless-stopped
command: server /data
ports:
- 9000:9000
volumes:
- minio_data:/data
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
# Chrome Browser (for printing and previews)
chrome:
image: browserless/chrome
restart: unless-stopped
environment:
TOKEN: chrome_token
EXIT_ON_HEALTH_FAILURE: true
PRE_REQUEST_HEALTH_CHECK: true
# Redis (for cache & server session management)
redis:
image: redis
restart: unless-stopped
command: redis-server --requirepass password
app:
image: amruthpillai/reactive-resume
restart: unless-stopped
ports:
- 3000:3000
depends_on:
- postgres
- minio
- redis
- chrome
environment:
# -- Environment Variables --
PORT: 3000
NODE_ENV: production
# -- URLs --
PUBLIC_URL: http://localhost:3000
STORAGE_URL: http://localhost:9000
# -- Printer (Chrome) --
CHROME_URL: ws://chrome:3000
CHROME_TOKEN: chrome_token
# -- Database (Postgres) --
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres
# -- Auth --
ACCESS_TOKEN_SECRET: access_token_secret
REFRESH_TOKEN_SECRET: refresh_token_secret
# -- Emails --
SMTP_URL: smtp://user:pass@smtp:587 # Optional
# -- Storage (Minio) --
STORAGE_ENDPOINT: minio
STORAGE_PORT: 9000
STORAGE_REGION: us-east-1 # Optional
STORAGE_BUCKET: default
STORAGE_ACCESS_KEY: minioadmin
STORAGE_SECRET_KEY: minioadmin
# -- Cache (Redis) --
REDIS_URL: redis://default:password@redis:6379
# -- Sentry --
SENTRY_DSN: https://id.sentry.io # Optional
# -- GitHub --
GITHUB_CLIENT_ID: github_client_id
GITHUB_CLIENT_SECRET: github_client_secret
GITHUB_CALLBACK_URL: http://localhost:3000/api/auth/github/callback
# -- Google --
GOOGLE_CLIENT_ID: google_client_id
GOOGLE_CLIENT_SECRET: google_client_secret
GOOGLE_CALLBACK_URL: http://localhost:3000/api/auth/google/callback
volumes:
minio_data:
postgres_data:

123
tools/compose/traefik.yml Normal file
View File

@ -0,0 +1,123 @@
version: "3"
# In this Docker Compose example, we use Traefik to route requests to the app and storage containers.
# This example assumes you have a domain name (example.com) and a wildcard DNS record pointing to your server.
# The only exposed port here is from Traefik (80). If you choose to use SSL, check the Traefik docs for more info.
# Note: Please change `example.com` to your domain name where necessary.
services:
# Database (Postgres)
postgres:
image: postgres
restart: unless-stopped
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
healthcheck:
test: ["CMD", "pg_isready -U postgres -d postgres"]
interval: 10s
timeout: 5s
retries: 5
# Storage (for image uploads)
minio:
image: minio/minio
restart: unless-stopped
command: server /data
volumes:
- minio_data:/data
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
labels:
- traefik.enable=true
- traefik.http.routers.minio.rule=Host(`storage.example.com`)
- traefik.http.services.minio.loadbalancer.server.port=9000
# Chrome Browser (for printing and previews)
chrome:
image: browserless/chrome
restart: unless-stopped
environment:
TOKEN: chrome_token
EXIT_ON_HEALTH_FAILURE: true
PRE_REQUEST_HEALTH_CHECK: true
# Redis (for cache & server session management)
redis:
image: redis
restart: unless-stopped
command: redis-server --requirepass password
app:
build:
context: ../..
dockerfile: Dockerfile
restart: unless-stopped
ports:
- 3000:3000
depends_on:
- postgres
- minio
- redis
- chrome
environment:
# -- Environment Variables --
PORT: 3000
NODE_ENV: production
# -- URLs --
PUBLIC_URL: http://example.com
STORAGE_URL: http://storage.example.com
# -- Printer (Chrome) --
CHROME_URL: ws://chrome:3000
CHROME_TOKEN: chrome_token
# -- Database (Postgres) --
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres
# -- Auth --
ACCESS_TOKEN_SECRET: access_token_secret
REFRESH_TOKEN_SECRET: refresh_token_secret
# -- Emails --
SMTP_URL: smtp://user:pass@smtp:587 # Optional
# -- Storage (Minio) --
STORAGE_ENDPOINT: minio
STORAGE_PORT: 9000
STORAGE_REGION: us-east-1 # Optional
STORAGE_BUCKET: default
STORAGE_ACCESS_KEY: minioadmin
STORAGE_SECRET_KEY: minioadmin
# -- Cache (Redis) --
REDIS_URL: redis://default:password@redis:6379
# -- Sentry --
SENTRY_DSN: https://id.sentry.io # Optional
# -- GitHub --
GITHUB_CLIENT_ID: github_client_id
GITHUB_CLIENT_SECRET: github_client_secret
GITHUB_CALLBACK_URL: http://localhost:3000/api/auth/github/callback
# -- Google --
GOOGLE_CLIENT_ID: google_client_id
GOOGLE_CLIENT_SECRET: google_client_secret
GOOGLE_CALLBACK_URL: http://localhost:3000/api/auth/google/callback
labels:
- traefik.enable=true
- traefik.http.routers.app.rule=Host(`example.com`)
- traefik.http.services.app.loadbalancer.server.port=3000
traefik:
image: traefik
command:
- --api.insecure=true
- --providers.docker
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
ports:
- 80:80
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
volumes:
minio_data:
postgres_data:

View File

@ -1,36 +0,0 @@
events {
worker_connections 512;
}
http {
upstream app {
least_conn;
# List all of your `app` instances here to balance the load between them
server app_one:3000;
server app_two:3000;
}
server {
listen 80;
# This instructs nginx to forward the request to the next available `app` instance
# in case the current one throws an error or times out
proxy_next_upstream error timeout http_500 http_503 http_429 non_idempotent;
location / {
proxy_pass http://app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_connect_timeout 1000ms;
proxy_send_timeout 1000ms;
proxy_read_timeout 1000ms;
send_timeout 1000ms;
}
}
}

View File

@ -1,36 +0,0 @@
events {
worker_connections 512;
}
http {
upstream chrome {
least_conn;
# List all of your `chrome` instances here to balance the load between them
server chrome_one:3000;
server chrome_two:3000;
}
server {
listen 80;
# This instructs nginx to forward the request to the next available `chrome` instance
# in case the current one throws an error or times out
proxy_next_upstream error timeout http_500 http_503 http_429 non_idempotent;
location / {
proxy_pass http://chrome;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_connect_timeout 1000ms;
proxy_send_timeout 1000ms;
proxy_read_timeout 1000ms;
send_timeout 1000ms;
}
}
}