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

Baseline for Master #12

Merged
merged 45 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
257a99f
Working on Github Actions.
abhik-wil Dec 31, 2024
401a0d2
Working on Deployment.
abhik-wil Jan 3, 2025
2c706b5
Merge branch 'ONDC-Official:master' into master
abhik-wil Jan 3, 2025
163ecbe
Fix: Github Actions.
abhik-wil Jan 3, 2025
c68410c
Merge branch 'master' of github.com:abhik-wil/deeplink-resolver-server
abhik-wil Jan 3, 2025
ef3a1e4
Fixed username.
abhik-wil Jan 3, 2025
68e9112
Working on deployment.
abhik-wil Jan 3, 2025
490c32e
Update clone-and-setup.yml
abhik-wil Jan 3, 2025
99db722
Update clone-and-setup.yml
abhik-wil Jan 3, 2025
21740d9
Update clone-and-setup.yml
abhik-wil Jan 3, 2025
0b80181
sanity commit.
abhik-wil Jan 3, 2025
e965288
snaity commit.
abhik-wil Jan 3, 2025
3a28e32
s.
abhik-wil Jan 3, 2025
2c81c4a
sc.
abhik-wil Jan 3, 2025
136a005
logging.
abhik-wil Jan 3, 2025
4b373fe
Update app-deployment.yml
abhik-wil Jan 3, 2025
8d4ec04
Update app-deployment.yml
abhik-wil Jan 3, 2025
fd4adf9
Update db-operations.yml
abhik-wil Jan 3, 2025
53fd13f
Update db-operations.yml
abhik-wil Jan 3, 2025
a0ee0a4
Update db-operations.yml
abhik-wil Jan 3, 2025
a4ec0f7
Update db-operations.yml
abhik-wil Jan 3, 2025
32a51d7
Update db-operations.yml
abhik-wil Jan 3, 2025
e9a09f1
Removing unused classes.
abhik-wil Jan 3, 2025
ff1744b
Merge branch 'master' of github.com:abhik-wil/deeplink-resolver-server
abhik-wil Jan 3, 2025
4e50cb5
Update db-operations.yml
abhik-wil Jan 3, 2025
3235bcf
Update db-operations.yml
abhik-wil Jan 3, 2025
f2496cd
Update app-deployment.yml
abhik-wil Jan 3, 2025
8918ed5
Update app-deployment.yml
abhik-wil Jan 3, 2025
db358d3
Working on deployment.
abhik-wil Jan 3, 2025
3ada068
Update db-operations.yml
abhik-wil Jan 3, 2025
00c636c
Update db-operations.yml
abhik-wil Jan 3, 2025
dc111df
Update package.json
abhik-wil Jan 3, 2025
d6e5692
Working on Deployment migration runner.
abhik-wil Jan 5, 2025
0a6b066
merging master into local.
abhik-wil Jan 5, 2025
556fa24
Fixing docker network.
abhik-wil Jan 5, 2025
e5eaf5a
sc
abhik-wil Jan 5, 2025
b04da0b
Working on UI fixes.
abhik-wil Jan 6, 2025
c8e7e56
Working on QR Download and schema changes.
abhik-wil Jan 6, 2025
d93f7d2
Working on decoupling action from formData.
abhik-wil Jan 6, 2025
69acf93
Minor changes.
abhik-wil Jan 6, 2025
2f53c5e
Merge branch 'master' of github.com:ONDC-Official/deeplink-resolver-s…
abhik-wil Jan 6, 2025
4ec9f57
Logging the migrations.
abhik-wil Jan 7, 2025
1c73edc
Debugging.
abhik-wil Jan 7, 2025
f4ac96a
changing env name.
abhik-wil Jan 7, 2025
4465473
Update app-deployment.yml
abhik-wil Jan 7, 2025
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
47 changes: 47 additions & 0 deletions .github/workflows/app-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: App Deployment
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
deploy-app:
runs-on: ubuntu-latest
steps:
- name: Deploy Generator App
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PEM }}
port: 22
script: |
echo "STARTING Deployment"
[ -d "deeplink-resolver-server" ] && sudo rm -rf "deeplink-resolver-server"
sudo git clone https://github.com/abhik-wil/deeplink-resolver-server.git
cd deeplink-resolver-server/deeplink-generator


echo "STARTING Deployment"
sudo touch .env
# Create backend .env file
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" | sudo tee .env
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" | sudo tee -a .env
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" | sudo tee -a .env
echo "POSTGRES_DB=${{ secrets.POSTGRES_DB }}" | sudo tee -a .env
echo "ACCESS_TOKEN_REPO=${{ secrets.ACCESS_TOKEN_REPO }}" | sudo tee -a .env
echo "OWNER_NAME_REPO=${{ secrets.OWNER_NAME_REPO }}" | sudo tee -a .env
echo "STORAGE_REPO_NAME=${{ secrets.STORAGE_REPO_NAME }}" | sudo tee -a .env

echo "STARTING build"
sudo cp docker-compose.dev.yml docker-compose.yml
sudo docker compose up ondc_deep_link_app -d --build
sudo docker system prune -f


echo "BUILD Complete; Restarting Nginx"
sudo systemctl restart nginx
echo "Deployment COMPLETE"

29 changes: 29 additions & 0 deletions .github/workflows/db-operations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Database Operations
on:
workflow_dispatch:

jobs:
db-reset-and-migrate:
runs-on: ubuntu-latest
steps:
- name: Execute Generator DB Operations
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PEM }}
port: 22
script: |
cd deeplink-resolver-server/deeplink-generator

echo "DB Teardown and Restart"
sudo docker compose down ondc_deep_link_db
sudo docker compose up -d ondc_deep_link_db

sleep 10

sudo docker build -t migrations-runner -f Dockerfile.migration .
sudo docker run --rm \
--network deeplink-generator_default \
migrations-runner

2 changes: 2 additions & 0 deletions deeplink-generator/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
docker-compose.yml

10 changes: 10 additions & 0 deletions deeplink-generator/Dockerfile.migration
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:22-alpine

WORKDIR /app

COPY package*.json ./
COPY . .

RUN npm install

CMD ["sh", "-c", "npx prisma generate && npx prisma migrate deploy && node seeding/seed.js"]
25 changes: 25 additions & 0 deletions deeplink-generator/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
ondc_deep_link_app:
build: .
ports:
- "8080:3000"
env_file:
- ./.env
depends_on:
- ondc_deep_link_db

ondc_deep_link_db:
image: postgres
restart: always
# set shared memory limit when using docker-compose
shm_size: 128mb
# or set shared memory limit when deploy via swarm stack
#volumes:
# - type: tmpfs
# target: /dev/shm
# tmpfs:
# size: 134217728 # 128*2^20 bytes = 128Mb
ports:
- "5432:5432"
env_file:
- ./.env
9 changes: 7 additions & 2 deletions deeplink-generator/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
output: "standalone"
/* config options here */
output: "standalone",
images: {
remotePatterns: [
{ protocol: "https", hostname: "raw.githubusercontent.com" },
],
},
};

export default nextConfig;
25 changes: 9 additions & 16 deletions deeplink-generator/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,24 @@

http {
upstream nextjs_upstream {
server host.docker.internal:8080;
server localhost:8080;
}

server {
listen 80;
listen [::]:80;
server_name _;
server_name deeplink.resolver.ondc.org;

location / {
proxy_pass http://nextjs_upstream;
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_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
listen [::]:443 ssl;
server_name _;

ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;

ssl_certificate /etc/letsencrypt/live/deeplink.resolver.ondc.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/deeplink.resolver.ondc.org/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

Expand All @@ -49,3 +38,7 @@ http {
}
}
}

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
Loading