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

Add pre commit hook (#16) #19

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
81 changes: 41 additions & 40 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
---
name: Create container image for hasura-jwt

on:
push:
branches:
- main
push:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: hasura-jwt
REGISTRY: ghcr.io
IMAGE_NAME: hasura-jwt

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3


- name: Log in to the Container registry
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.3.0
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
tags: latest


- name: Build and push Docker image
uses: docker/build-push-action@v4.0.0
with:
context: src/
file: src/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3


- name: Log in to the Container registry
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.3.0
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
tags: latest


- name: Build and push Docker image
uses: docker/build-push-action@v4.0.0
with:
context: src/
file: src/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
49 changes: 25 additions & 24 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
---
name: Scan Image
on:
pull_request:
branches:
- main
workflow_dispatch:
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build:
name: Scan Image
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
build:
name: Scan Image
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build an image from Dockerfile
run: |
docker build -t ${{ github.sha }} -f src/Dockerfile src/
- name: Build an image from Dockerfile
run: |
docker build -t ${{ github.sha }} -f src/Dockerfile src/

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.20.0
with:
image-ref: '${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
scanners: 'vuln,secret,config'
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.20.0
with:
image-ref: ${{ github.sha }}
format: sarif
output: trivy-results.sarif
scanners: vuln,secret,config

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trivy-results.sarif
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
todo.md
hasura/hasura
hasura/hasura.exe
img/
img/
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ repos:
args: [--exclude, '**/*.patch.yaml']
files: .yml$

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.1 # or other specific tag
hooks:
- id: yamlfmt

- repo: https://github.com/tekwizely/pre-commit-golang
rev: master
hooks:
Expand Down
7 changes: 5 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Security Policy

## Supported Versions

Only the last Version have Security fixes.

## Reporting a Vulnerability
Please use the Security Tab in Github to report vulnerabilities. There are no Bounties on vulnerabilities.

Please use the Security Tab in Github to report vulnerabilities.
There are no Bounties on vulnerabilities.
82 changes: 41 additions & 41 deletions dev_docker_compose.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
version: "3.11"
---

services:
postgres:
image: postgres
restart: no
ports:
- "5432:5432"
volumes:
- hasura_ci_db_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgrespassword
postgres:
image: postgres
restart: no
ports:
- 5432:5432
volumes:
- hasura_ci_db_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgrespassword

graphql-engine:
image: hasura/graphql-engine:v2.36.1
restart: no
ports:
- "8080:8080"
depends_on:
- "postgres"
environment:
HASURA_GRAPHQL_DATABASE_URL: "postgres://postgres:postgrespassword@postgres:5432/postgres"
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_ADMIN_SECRET: "my-secret"
HASURA_GRAPHQL_JWT_SECRET: '{ "type": "HS256", "key": "this-is-a-generic-HS256-secret-key-and-you-should-really-change-it" }'
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "anonymous"
JWT_URL: 'http://hasura-jwt:3000'
graphql-engine:
image: hasura/graphql-engine:v2.36.1
restart: no
ports:
- 8080:8080
depends_on:
- postgres
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
HASURA_GRAPHQL_ENABLE_CONSOLE: 'true'
HASURA_GRAPHQL_ADMIN_SECRET: my-secret
HASURA_GRAPHQL_JWT_SECRET: '{ "type": "HS256", "key": "this-is-a-generic-HS256-secret-key-and-you-should-really-change-it" }'
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: anonymous
JWT_URL: http://hasura-jwt:3000

hasura-jwt:
build:
context: ./src
dockerfile: Dockerfile
restart: no
ports:
- "3000:3000"
environment:
JWT_KEY: 'this-is-a-generic-HS256-secret-key-and-you-should-really-change-it'
HASURA_SECRET: 'my-secret'
APP_URL: 'http://localhost:3000'
EMAIL_VERIFICATION: true
SMTP_HOST: 'mail.example.com'
SMTP_PORT: '587'
SMTP_USER: 'user@example.com'
SMTP_PASSWORD: 'user_password'
hasura-jwt:
build:
context: ./src
dockerfile: Dockerfile
restart: no
ports:
- 3000:3000
environment:
JWT_KEY: this-is-a-generic-HS256-secret-key-and-you-should-really-change-it
HASURA_SECRET: my-secret
APP_URL: http://localhost:3000
EMAIL_VERIFICATION: true
SMTP_HOST: mail.example.com
SMTP_PORT: '587'
SMTP_USER: user@example.com
SMTP_PASSWORD: user_password


volumes:
hasura_ci_db_data:
hasura_ci_db_data:
2 changes: 1 addition & 1 deletion kubernetes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ ingress:
clean:
helm uninstall hasura
kubectl delete -f hasura-jwt
$(REMOVE_HASURA)
$(REMOVE_HASURA)
24 changes: 15 additions & 9 deletions kubernetes/Readme.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# Kubernetes Deployment
# Kubernetes Deployment

## Prerequisites
- Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- On Windows, install [Docker Desktop](https://www.docker.com/products/docker-desktop) an enable Kubernetes
- On Linux, install [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/)
- Install [Helm](https://helm.sh/docs/intro/install/)

## Local development
- Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- On Windows, install
[Docker Desktop](https://www.docker.com/products/docker-desktop)
an enable Kubernetes
- On Linux, install [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/)
- Install [Helm](https://helm.sh/docs/intro/install/)

## Local development

Set the following records in your `etc/hosts`:
```

```text
127.0.0.1 hasura.docker.internal
127.0.0.1 nginx.local
127.0.0.1 hasura-jwt.docker.internal
```


## Deploy to Kubernetes
Use `make ingress` to install nginx ingress on your Cluster. If you don't already have it.

Use `make ingress` to install nginx ingress on your Cluster.
If you don't already have it.

Use `make all` to create this app.

## Uninstall

Use `make clean` to delete the app from the Kubernetes Cluster.
79 changes: 40 additions & 39 deletions kubernetes/hasura-jwt/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hasura-jwt-deployment
name: hasura-jwt-deployment
spec:
replicas: 1
selector:
matchLabels:
app: hasura-jwt
template:
metadata:
labels:
app: hasura-jwt
spec:
containers:
- name: hasura-jwt-container
image: ghcr.io/53845714nf/hasura-jwt/hasura-jwt:latest
ports:
- containerPort: 3000
env:
- name: HASURA_URL
value: http://hasura-graphql-engine:8080/v1/graphql
- name: JWT_KEY
value: "this-is-a-generic-HS256-secret-key-and-you-should-really-change-it"
- name: HASURA_SECRET
value: "my-secret"
- name: EMAIL_VERIFICATION
value: "True"
- name: APP_URL
value: "https://hasura-jwt.docker.internal"
- name: SMTP_HOST
value: mail.example.com
- name: SMTP_USER
value: user@example.com
- name: SMTP_PASSWORD
value: user_password
resources:
limits:
cpu: "0.5"
memory: "512Mi"
requests:
cpu: "0.25"
memory: "256Mi"
replicas: 1
selector:
matchLabels:
app: hasura-jwt
template:
metadata:
labels:
app: hasura-jwt
spec:
containers:
- name: hasura-jwt-container
image: ghcr.io/53845714nf/hasura-jwt/hasura-jwt:latest
ports:
- containerPort: 3000
env:
- name: HASURA_URL
value: http://hasura-graphql-engine:8080/v1/graphql
- name: JWT_KEY
value: this-is-a-generic-HS256-secret-key-and-you-should-really-change-it
- name: HASURA_SECRET
value: my-secret
- name: EMAIL_VERIFICATION
value: 'True'
- name: APP_URL
value: https://hasura-jwt.docker.internal
- name: SMTP_HOST
value: mail.example.com
- name: SMTP_USER
value: user@example.com
- name: SMTP_PASSWORD
value: user_password
resources:
limits:
cpu: '0.5'
memory: 512Mi
requests:
cpu: '0.25'
memory: 256Mi
Loading
Loading