Skip to content

Commit

Permalink
Merge branch 'develop' into feat-api/environment-only-access
Browse files Browse the repository at this point in the history
  • Loading branch information
muntaxir4 authored Jan 4, 2025
2 parents 27c0e88 + 5276bb8 commit 7e007db
Show file tree
Hide file tree
Showing 21 changed files with 616 additions and 1,755 deletions.
78 changes: 27 additions & 51 deletions .github/workflows/deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'beta' || 'stage' }}
environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }}
name: Build and push API docker image for release

steps:
Expand All @@ -32,59 +32,35 @@ jobs:
REPOSITORY_NAME: api
run: |
# Build a docker container and push it to ACR
docker build -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6} -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest -f ./apps/web/Dockerfile .
docker build -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6} -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest -f ./apps/api/Dockerfile .
echo "Pushing image to ACR..."
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6}
echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:latest" >> $GITHUB_OUTPUT
# setup-database:
# needs: build
# name: Setup Database
# runs-on: ubuntu-latest
# environment: alpha

# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Install Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20

# - name: Install pnpm
# uses: pnpm/action-setup@v4
# with:
# version: 9.2.0
# run_install: false

# - name: Deploy migrations
# env:
# DATABASE_URL: ${{ secrets.DATABASE_URL }}
# run: pnpm db:deploy-migrations

# deploy:
# needs: [build, setup-database]
# runs-on: ubuntu-latest
# environment: alpha
# name: Deploy API docker image for release

# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.ACCESS_KEY }}
# aws-secret-access-key: ${{ secrets.SECRET_KEY }}
# aws-region: ap-south-1
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }}
name: Restart API container app
needs: build
steps:
- name: Azure Login action
uses: azure/login@v2
with:
creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }}
enable-AzPSSession: true

# - name: Force re-deploy task in service
# id: force-redeploy
# env:
# ECS_CLUSTER: ${{ vars.ECS_CLUSTER }}
# ECS_SERVICE: ${{ vars.ECS_API_SERVICE }}
# run: |
# aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment
- name: Azure CLI script
uses: azure/cli@v2
env:
API_CONTAINER: ${{ vars.API_CONTAINER }}
API_CONTAINER_RG: ${{ vars.API_CONTAINER_RG }}
ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }}
REPOSITORY_NAME: api
with:
azcliversion: latest
inlineScript: |
az containerapp update \
--name $API_CONTAINER \
--resource-group $API_CONTAINER_RG \
--image $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest
35 changes: 16 additions & 19 deletions .github/workflows/deploy-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'beta' || 'stage' }}
environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }}
name: Build and push Platform docker image for release

steps:
Expand Down Expand Up @@ -44,26 +44,23 @@ jobs:
echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:latest" >> $GITHUB_OUTPUT
# deploy:
# needs: build
# runs-on: ubuntu-latest
# environment: alpha
# name: Deploy Platform docker image for release

# environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }}
# name: Restart Platform container app
# needs: build
# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# - name: Azure Login action
# uses: azure/login@v2
# with:
# aws-access-key-id: ${{ secrets.ACCESS_KEY }}
# aws-secret-access-key: ${{ secrets.SECRET_KEY }}
# aws-region: ap-south-1
# creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }}
# enable-AzPSSession: true

# - name: Force re-deploy task in service
# id: force-redeploy
# - name: Azure CLI script
# uses: azure/cli@v2
# env:
# ECS_CLUSTER: ${{ vars.ECS_CLUSTER }}
# ECS_SERVICE: ${{ vars.ECS_PLATFORM_SERVICE }}
# run: |
# aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment
# PLATFORM_CONTAINER: ${{ vars.PLATFORM_CONTAINER }}
# PLATFORM_CONTAINER_RG: ${{ vars.PLATFORM_CONTAINER_RG }}
# with:
# azcliversion: latest
# inlineScript: |
# az container restart --name $PLATFORM_CONTAINER --resource-group $PLATFORM_CONTAINER_RG
50 changes: 26 additions & 24 deletions .github/workflows/deploy-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'beta' || 'stage' }}
environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }}
name: Build and push Web docker image for release

steps:
Expand All @@ -38,27 +38,29 @@ jobs:
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6}
echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:latest" >> $GITHUB_OUTPUT
# deploy:
# needs: build
# runs-on: ubuntu-latest
# environment: alpha
# name: Deploy Web docker image for release

# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.ACCESS_KEY }}
# aws-secret-access-key: ${{ secrets.SECRET_KEY }}
# aws-region: ap-south-1
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }}
name: Restart Web container app
needs: build
steps:
- name: Azure Login action
uses: azure/login@v2
with:
creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }}
enable-AzPSSession: true

# - name: Force re-deploy task in service
# id: force-redeploy
# env:
# ECS_CLUSTER: ${{ vars.ECS_CLUSTER }}
# ECS_SERVICE: ${{ vars.ECS_WEB_SERVICE }}
# run: |
# aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment
- name: Azure CLI script
uses: azure/cli@v2
env:
WEB_CONTAINER: ${{ vars.WEB_CONTAINER }}
WEB_CONTAINER_RG: ${{ vars.WEB_CONTAINER_RG }}
ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }}
REPOSITORY_NAME: web
with:
azcliversion: latest
inlineScript: |
az containerapp update \
--name $WEB_CONTAINER \
--resource-group $WEB_CONTAINER_RG \
--image $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest
4 changes: 3 additions & 1 deletion apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ USER node

FROM node:20-alpine AS prod

RUN apk add --no-cache openssl

# Don't run production as root
USER node

Expand All @@ -42,6 +44,6 @@ COPY --chown=root:root --chmod=755 --from=build /app/node_modules /app/node_modu
COPY --chown=root:root --chmod=755 --from=build /app/apps/api/node_modules /app/apps/api/node_modules
COPY --chown=root:root --chmod=755 --from=build /app/apps/api/dist /app/apps/api/dist

EXPOSE ${API_PORT}
EXPOSE 4200

ENTRYPOINT ["node", "/app/apps/api/dist/main.js"]
1 change: 1 addition & 0 deletions apps/api/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl"]
}

datasource db {
Expand Down
4 changes: 2 additions & 2 deletions apps/platform/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ COPY --from=installer --chown=nextjs:nodejs /app/apps/platform/.next ./apps/pla
COPY --from=installer --chown=nextjs:nodejs /app/apps/platform/public ./apps/platform/public


ENV PORT=3025
ENV PORT=3000
ENV NEXT_SHARP_PATH=/app/apps/platform/.next/sharp
EXPOSE 3025
EXPOSE 3000
# keyshade-ignore
ENV HOSTNAME "0.0.0.0"

Expand Down
3 changes: 3 additions & 0 deletions apps/platform/public/svg/shared/Error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions apps/platform/public/svg/shared/Vector.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion apps/platform/public/svg/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import SettingsSVG from './settings.svg'
import ThreeDotOptionSVG from './3dotOption.svg'
import AddSVG from './add.svg'
import LoadingSVG from './loading.svg'
import MessageSVG from './message.svg'
import VectorSVG from './vector.svg'
import ErrorSVG from './Error.svg'

export {
DropdownSVG,
Expand All @@ -17,5 +20,8 @@ export {
SettingsSVG,
ThreeDotOptionSVG,
AddSVG,
LoadingSVG
LoadingSVG,
MessageSVG,
VectorSVG,
ErrorSVG
}
3 changes: 3 additions & 0 deletions apps/platform/public/svg/shared/message.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 25 additions & 12 deletions apps/platform/src/app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
DialogTrigger
} from '@/components/ui/dialog'
import ControllerInstance from '@/lib/controller-instance'
import { Textarea } from '@/components/ui/textarea'

export default function Index(): JSX.Element {
const [isSheetOpen, setIsSheetOpen] = useState<boolean>(false)
Expand Down Expand Up @@ -144,10 +145,12 @@ export default function Index(): JSX.Element {

<Dialog onOpenChange={setIsDialogOpen} open={isDialogOpen}>
<DialogTrigger>
<Button onClick={toggleDialog}>
{' '}
<AddSVG /> Create a new Project
</Button>
{isProjectEmpty ? null : (
<Button onClick={toggleDialog}>
{' '}
<AddSVG /> Create a new Project
</Button>
)}
</DialogTrigger>
<DialogContent className="h-[39.5rem] w-[28.625rem] rounded-[12px] border bg-[#1E1E1F] ">
<div className="flex h-[3.125rem] w-[25.625rem] flex-col items-start justify-center">
Expand Down Expand Up @@ -190,8 +193,8 @@ export default function Index(): JSX.Element {
>
Description
</Label>
<Input
className="col-span-3 h-[5.625rem] w-[20rem] gap-[0.25rem]"
<Textarea
className="col-span-3 h-[5.625rem] w-[20rem] resize-none gap-[0.25rem]"
id="name"
onChange={(e) => {
setNewProjectData((prev) => ({
Expand All @@ -217,7 +220,10 @@ export default function Index(): JSX.Element {
onChange={(e) => {
setNewProjectData((prev) => ({
...prev,
envName: e.target.value
environments: (prev.environments || []).map(
(env, index) =>
index === 0 ? { ...env, name: e.target.value } : env
)
}))
}}
placeholder="Your project default environment name"
Expand All @@ -232,13 +238,18 @@ export default function Index(): JSX.Element {
>
Env. Description
</Label>
<Input
className="col-span-3 h-[4.875rem] w-[20rem] "
<Textarea
className="col-span-3 h-[4.875rem] w-[20rem] resize-none"
id="envDescription"
onChange={(e) => {
setNewProjectData((prev) => ({
...prev,
envDescription: e.target.value
environments: (prev.environments || []).map(
(env, index) =>
index === 0
? { ...env, description: e.target.value }
: env
)
}))
}}
placeholder="Detailed description about your environment"
Expand All @@ -265,7 +276,7 @@ export default function Index(): JSX.Element {
}))
}}
>
<SelectTrigger className=" h-[2.25rem] w-[20rem] rounded-[0.375rem] border-[0.013rem] border-white/10 focus:border-[#3b82f6]">
<SelectTrigger className=" h-[2.25rem] w-[20rem] rounded-[0.375rem] border-[0.013rem] border-white/10 bg-white/5 focus:border-[#3b82f6]">
<SelectValue />
</SelectTrigger>
<SelectContent className="border-[0.013rem] border-white/10 bg-neutral-800 text-white ">
Expand Down Expand Up @@ -334,7 +345,9 @@ export default function Index(): JSX.Element {
<div>
Create a file and start setting up your environment and secret keys
</div>
<Button variant="secondary">Create project</Button>
<Button onClick={toggleDialog} variant="secondary">
Create project
</Button>
</div>
)}

Expand Down
Loading

0 comments on commit 7e007db

Please sign in to comment.