From eef91cf9053f292ccb0327f73479576ee706b698 Mon Sep 17 00:00:00 2001 From: Amruth Pillai Date: Sun, 5 Nov 2023 13:17:14 +0100 Subject: [PATCH] ci(v4.0.0-alpha): :rocket: running the first ci worflow --- .dockerignore | 4 +- .github/ISSUE_TEMPLATE/bug-report.yml | 86 ++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.yml | 23 ++++ .github/workflows/publish-docker-image.yml | 3 + .vscode/settings.json | 9 +- compose-dev.yml => tools/compose/dev.yml | 4 + compose.yml => tools/compose/simple.yml | 10 +- tools/compose/traefik.yml | 123 +++++++++++++++++++++ tools/nginx/app_nginx.conf | 36 ------ tools/nginx/chrome_nginx.conf | 36 ------ 10 files changed, 251 insertions(+), 83 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yml rename compose-dev.yml => tools/compose/dev.yml (86%) rename compose.yml => tools/compose/simple.yml (88%) create mode 100644 tools/compose/traefik.yml delete mode 100644 tools/nginx/app_nginx.conf delete mode 100644 tools/nginx/chrome_nginx.conf diff --git a/.dockerignore b/.dockerignore index a3a76b5f..4c4c08b9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,4 +17,6 @@ dist Dockerfile node_modules Thumbs.db -tmp \ No newline at end of file +tmp +tools/compose/* +tools/scripts/* \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000..4ff3d95c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,86 @@ +name: 🐞 Bug Report + +description: Create a bug report to help improve Reactive Resume + +title: "[Bug] " +labels: [Bug, Needs Triage] +assignees: "AmruthPillai" + +body: + - type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search to see if an issue already exists for the bug you encountered. + options: + - label: Yes, I have searched the existing issues and none of them match my problem. + required: true + + - type: dropdown + id: variant + attributes: + label: Product Variant + description: What variant of Reactive Resume are you using? + options: + - Cloud (http://rxresu.me) + - Self-Hosted + validations: + required: true + + - type: textarea + attributes: + label: Current Behavior + description: A concise description of what you're experiencing. + validations: + required: true + + - type: textarea + attributes: + label: Expected Behavior + description: A concise description of what you expected to happen. + validations: + required: false + + - type: textarea + attributes: + label: Steps To Reproduce + description: Detailed steps to reproduce the behavior, so that it can be easily diagnosed. + placeholder: | + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: false + + - type: dropdown + id: browsers + attributes: + label: What browsers are you seeing the problem on? + multiple: true + options: + - Firefox + - Chrome + - Safari + - Microsoft Edge + validations: + required: false + + - type: dropdown + id: template + attributes: + label: What template are you using? + multiple: false + options: + - Rhyhorn + validations: + required: false + + - type: textarea + attributes: + label: Anything else? + description: | + Links? References? Anything that will give us more context about the issue you are encountering! + + Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 00000000..6660d188 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,23 @@ +name: ✨ Feature Request + +description: Suggest an feature or idea that you would like to see in Reactive Resume + +title: "[Feature] <title>" +labels: [Feature, Needs Triage] +assignees: "AmruthPillai" + +body: + - type: checkboxes + attributes: + label: Is there an existing issue for this feature? + description: Please search to see if an issue already exists for the feature you requested. + options: + - label: Yes, I have searched the existing issues and it doesn't exist. + required: true + + - type: textarea + attributes: + label: Feature Description + description: A concise description of what feature you would like to see in Reactive Resume. + validations: + required: true diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml index 8e7cb80f..c97cbbda 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish-docker-image.yml @@ -1,6 +1,9 @@ name: Publish Docker Image on: + push: + branches: + - v4 workflow_dispatch: env: diff --git a/.vscode/settings.json b/.vscode/settings.json index 11346747..26f6b71b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,9 @@ { "typescript.tsdk": "node_modules/typescript/lib", - "files.associations": { - "compose-dev.yml": "dockercompose", - ".github/workflows/*.yml": "github-actions-workflow" - }, "yaml.schemas": { - "https://json.schemastore.org/github-workflow.json": "file:///Users/amruth/Projects/Reactive-Resume/.github/workflows/publish-docker-image.yml" + "https://json.schemastore.org/github-workflow.json": ".github/workflows/*.yml", + "https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json": [ + "tools/compose/*" + ] } } diff --git a/compose-dev.yml b/tools/compose/dev.yml similarity index 86% rename from compose-dev.yml rename to tools/compose/dev.yml index 1d23888e..c7a8103c 100644 --- a/compose-dev.yml +++ b/tools/compose/dev.yml @@ -1,5 +1,9 @@ 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: diff --git a/compose.yml b/tools/compose/simple.yml similarity index 88% rename from compose.yml rename to tools/compose/simple.yml index 3534c3f2..5512bac4 100644 --- a/compose.yml +++ b/tools/compose/simple.yml @@ -1,5 +1,9 @@ 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: @@ -46,11 +50,7 @@ services: command: redis-server --requirepass password app: - build: - context: . - dockerfile: Dockerfile - args: - - NX_CLOUD_ACCESS_TOKEN=${NX_CLOUD_ACCESS_TOKEN} + image: amruthpillai/reactive-resume restart: unless-stopped ports: - 3000:3000 diff --git a/tools/compose/traefik.yml b/tools/compose/traefik.yml new file mode 100644 index 00000000..c0791d7c --- /dev/null +++ b/tools/compose/traefik.yml @@ -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: diff --git a/tools/nginx/app_nginx.conf b/tools/nginx/app_nginx.conf deleted file mode 100644 index 6a0ef8fb..00000000 --- a/tools/nginx/app_nginx.conf +++ /dev/null @@ -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; - } - } -} \ No newline at end of file diff --git a/tools/nginx/chrome_nginx.conf b/tools/nginx/chrome_nginx.conf deleted file mode 100644 index e1039d1c..00000000 --- a/tools/nginx/chrome_nginx.conf +++ /dev/null @@ -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; - } - } -} \ No newline at end of file