Skip to content

Commit

Permalink
feat: added a basic builder service
Browse files Browse the repository at this point in the history
  • Loading branch information
Pulkitxm committed Oct 7, 2024
1 parent f7353fc commit 2cc99c6
Show file tree
Hide file tree
Showing 25 changed files with 870 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

cd core && npx tsc -b && npm run format && npm run build
cd core && npm run format && npx tsc -b && npm run build
cd ../docker-builder npm run format && npm run build
8 changes: 8 additions & 0 deletions core/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.next
.cache
package-lock.json
public
node_modules
next-env.d.ts
next.config.ts
yarn.lock
10 changes: 10 additions & 0 deletions core/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bracketSpacing": true,
"endOfLine": "lf",
"printWidth": 80,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "all",
"plugins": ["prettier-plugin-tailwindcss"]
}
2 changes: 1 addition & 1 deletion core/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function RootLayout({
}) {
return (
<html lang="en" suppressHydrationWarning>
<body className="w-screen h-screen overflow-auto">
<body className="h-screen w-screen overflow-auto">
<AppWrapper>
<Navbar />
{children}
Expand Down
2 changes: 1 addition & 1 deletion core/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default async function Page() {
return (
<div className="w-screen h-screen flex items-center justify-center text-white"></div>
<div className="flex h-screen w-screen items-center justify-center text-white"></div>
);
}
4 changes: 2 additions & 2 deletions core/components/LoginWithGithub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export default function LoginWithGithub() {

return (
<Button
className="w-full bg-[#24292e] hover:bg-[#2f363d] text-white"
className="w-full bg-[#24292e] text-white hover:bg-[#2f363d]"
onClick={onSignin}
>
<GithubIcon className="w-4 h-4 mr-2" />
<GithubIcon className="mr-2 h-4 w-4" />
Login with GitHub
</Button>
);
Expand Down
2 changes: 1 addition & 1 deletion core/components/Navbar/AuthButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const logout = () => {
export default function AuthButtons() {
const { data: session } = useSession();
return (
<div className="flex frr">
<div className="frr flex">
{session ? (
<div>
<UserDetails session={session} logout={logout} />
Expand Down
16 changes: 8 additions & 8 deletions core/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export default function Navbar() {
};

return (
<nav className="bg-background shadow-sm fixed top-0 left-0 right-0 z-50 border-b border-gray-400">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex justify-between h-16">
<nav className="fixed left-0 right-0 top-0 z-50 border-b border-gray-400 bg-background shadow-sm">
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div className="flex h-16 justify-between">
<div className="flex items-center">
<Link href="/" className="flex-shrink-0 flex items-center">
<Link href="/" className="flex flex-shrink-0 items-center">
<svg
className="h-8 w-8 text-primary"
fill="none"
Expand All @@ -51,7 +51,7 @@ export default function Navbar() {
{items.map((item, index) => (
<Link
href={item.href}
className="px-3 py-2 rounded-md text-sm font-medium text-foreground hover:bg-accent hover:text-accent-foreground"
className="rounded-md px-3 py-2 text-sm font-medium text-foreground hover:bg-accent hover:text-accent-foreground"
key={index}
>
{item.name}
Expand All @@ -66,7 +66,7 @@ export default function Navbar() {
<ThemeToggle />
<button
onClick={toggleMenu}
className="inline-flex items-center justify-center p-2 ml-2 rounded-md text-foreground hover:bg-accent hover:text-accent-foreground focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary"
className="ml-2 inline-flex items-center justify-center rounded-md p-2 text-foreground hover:bg-accent hover:text-accent-foreground focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary"
>
<span className="sr-only">Open main menu</span>
{isMenuOpen ? (
Expand All @@ -80,12 +80,12 @@ export default function Navbar() {
</div>
{isMenuOpen && (
<div className="sm:hidden">
<div className="px-2 pt-2 pb-3 space-y-1">
<div className="space-y-1 px-2 pb-3 pt-2">
{items.map((item, index) => (
<Link
href={item.href}
key={index}
className="block px-3 py-2 rounded-md text-base font-medium text-foreground hover:bg-accent hover:text-accent-foreground"
className="block rounded-md px-3 py-2 text-base font-medium text-foreground hover:bg-accent hover:text-accent-foreground"
>
{item.name}
</Link>
Expand Down
2 changes: 1 addition & 1 deletion core/components/ProtectRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default async function ProtectRoute() {

if (!session) {
return (
<div className="w-full h-full flex items-center justify-center text-white">
<div className="flex h-full w-full items-center justify-center text-white">
<Card className="w-[350px]">
<CardHeader>
<CardTitle>Unauthorized Access</CardTitle>
Expand Down
80 changes: 80 additions & 0 deletions core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"postcss": "^8",
"prisma": "^5.20.0",
"tailwindcss": "^3.4.1",
"typescript": "^5"
"typescript": "^5",
"prettier-plugin-tailwindcss": "^0.6.6"
}
}
}
5 changes: 5 additions & 0 deletions docker-builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
output*/
tsconfig.tsbuildinfo
node_modules/
.env
dist/
38 changes: 38 additions & 0 deletions docker-builder/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Ignore node_modules
node_modules

# Ignore build output
dist
build

# Ignore coverage reports
coverage

# Ignore environment files
.env
.env.local
.env.*.local

# Ignore log files
*.log

# Ignore TypeScript declaration files
*.d.ts

# Ignore temporary files
tmp
temp

# Ignore IDE and editor config files
.vscode
.idea
*.sublime-workspace
*.sublime-project

# Ignore all test files
**/*.spec.ts
**/*.test.ts

# Ignore other non-source files
*.tsbuildinfo
output/
9 changes: 9 additions & 0 deletions docker-builder/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bracketSpacing": true,
"endOfLine": "lf",
"printWidth": 80,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "all"
}
12 changes: 12 additions & 0 deletions docker-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:latest

WORKDIR /app

COPY package*.json .

RUN npm install

COPY src/ ./src/
COPY tsconfig.json ./tsconfig.json

CMD ["npm", "start"]
74 changes: 74 additions & 0 deletions docker-builder/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
IMAGE_NAME=pulkitxm/vercel-builder-test
CONTAINER_NAME=test-vercel-builder
DOCKERFILE_PATH=Dockerfile
ENV_FILE=.env
DESTINATION_DIR=output
BUILD_FOLDER=build

help:
@echo "Makefile commands:"
@echo " build - Build Docker image"
@echo " run - Run Docker container"
@echo " stop - Stop Docker container"
@echo " clean - Remove Docker container and image"
@echo " logs - View container logs"
@echo " shell - Open shell inside running container"
@echo " check - Check if Docker container is running"

build:
@echo "Building Docker image..."
docker build -t $(IMAGE_NAME) -f $(DOCKERFILE_PATH) .

buildf:
@echo "Building Docker image..."
docker build -t $(IMAGE_NAME) --no-cache -f $(DOCKERFILE_PATH) .
@echo ""

run: stop
@echo "Running Docker container..."
docker run --env-file $(ENV_FILE) --name $(CONTAINER_NAME) $(IMAGE_NAME)
@echo ""

stop:
@echo "Stopping Docker container..."
-docker stop $(CONTAINER_NAME)
-docker rm $(CONTAINER_NAME)
@echo ""

reset:
@echo "Removing Docker container..."
-docker rm $(CONTAINER_NAME)
@echo ""

@echo "Removing Docker image..."
-docker rmi $(IMAGE_NAME)
@echo ""

clean: stop
@echo "Removing Docker image..."
rm -rf build dist project DESTINATION_DIR
@echo ""

logs:
@echo "Showing logs..."
docker logs -f $(CONTAINER_NAME)
@echo ""

shell:
@echo "Opening shell inside running container..."
docker exec -it $(CONTAINER_NAME) sh
@echo ""

copy:
@echo "Copying build artifacts to $(DESTINATION_DIR)..."
docker cp $(CONTAINER_NAME):'/app/$(BUILD_FOLDER)' '$(DESTINATION_DIR)'
@echo ""

serve:
@echo "Serving build artifacts..."
serve -s $(DESTINATION_DIR)
@echo ""

check:
@echo "Checking if Docker container is running..."
docker inspect --format '{{ .State.Running }}' $(CONTAINER_NAME) > /dev/null 2>&1
Loading

0 comments on commit 2cc99c6

Please sign in to comment.