Skip to content

Commit 1adc829

Browse files
committed
add repo base
1 parent 9bc5682 commit 1adc829

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+33902
-0
lines changed

samples/repo-base/.dockerignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Default .dockerignore file for Defang
2+
**/__pycache__
3+
**/.direnv
4+
**/.DS_Store
5+
**/.envrc
6+
**/.git
7+
**/.github
8+
**/.idea
9+
**/.next
10+
**/.vscode
11+
**/compose.*.yaml
12+
**/compose.*.yml
13+
**/compose.yaml
14+
**/compose.yml
15+
**/docker-compose.*.yaml
16+
**/docker-compose.*.yml
17+
**/docker-compose.yaml
18+
**/docker-compose.yml
19+
**/node_modules
20+
**/Thumbs.db
21+
Dockerfile
22+
*.Dockerfile
23+
# Ignore our own binary, but only in the root to avoid ignoring subfolders
24+
defang
25+
defang.exe
26+
# Ignore our project-level state
27+
.defang*

samples/repo-base/.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
42+
43+
.mastra

samples/repo-base/Dockerfile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# syntax=docker.io/docker/dockerfile:1
2+
3+
FROM node:20-alpine AS base
4+
5+
# Step 1. Rebuild the source code only when needed
6+
FROM base AS builder
7+
8+
WORKDIR /app
9+
10+
# Install dependencies based on the preferred package manager
11+
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
12+
# Omit --production flag for TypeScript devDependencies
13+
RUN \
14+
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
15+
elif [ -f package-lock.json ]; then npm ci; \
16+
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i; \
17+
# Allow install without lockfile, so example works even without Node.js installed locally
18+
else echo "Warning: Lockfile not found. It is recommended to commit lockfiles to version control." && yarn install; \
19+
fi
20+
21+
22+
COPY src ./src
23+
COPY public ./public
24+
COPY next.config.ts .
25+
COPY tsconfig.json .
26+
27+
# Environment variables must be present at build time
28+
# https://github.com/vercel/next.js/discussions/14030
29+
# ARG ENV_VARIABLE
30+
# ENV ENV_VARIABLE=${ENV_VARIABLE}
31+
# ARG NEXT_PUBLIC_ENV_VARIABLE
32+
# ENV NEXT_PUBLIC_ENV_VARIABLE=${NEXT_PUBLIC_ENV_VARIABLE}
33+
34+
# Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry
35+
# Uncomment the following line to disable telemetry at build time
36+
# ENV NEXT_TELEMETRY_DISABLED 1
37+
38+
# Build Next.js based on the preferred package manager
39+
RUN \
40+
if [ -f yarn.lock ]; then yarn build; \
41+
elif [ -f package-lock.json ]; then npm run build; \
42+
elif [ -f pnpm-lock.yaml ]; then pnpm build; \
43+
else npm run build; \
44+
fi
45+
46+
# Note: It is not necessary to add an intermediate step that does a full copy of `node_modules` here
47+
48+
# Step 2. Production image, copy all the files and run next
49+
FROM base AS runner
50+
51+
WORKDIR /app
52+
53+
# Don't run production as root
54+
RUN addgroup --system --gid 1001 nodejs
55+
RUN adduser --system --uid 1001 nextjs
56+
USER nextjs
57+
58+
COPY --from=builder /app/public ./public
59+
60+
# Automatically leverage output traces to reduce image size
61+
# https://nextjs.org/docs/advanced-features/output-file-tracing
62+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
63+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
64+
65+
# Environment variables must be redefined at run time
66+
# ARG ENV_VARIABLE
67+
# ENV ENV_VARIABLE=${ENV_VARIABLE}
68+
# ARG NEXT_PUBLIC_ENV_VARIABLE
69+
# ENV NEXT_PUBLIC_ENV_VARIABLE=${NEXT_PUBLIC_ENV_VARIABLE}
70+
71+
# Uncomment the following line to disable telemetry at run time
72+
# ENV NEXT_TELEMETRY_DISABLED 1
73+
74+
# Note: Don't expose ports here, Compose will handle that for us
75+
76+
CMD ["node", "server.js"]

samples/repo-base/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

samples/repo-base/components.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.ts",
8+
"css": "src/app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
},
20+
"iconLibrary": "lucide"
21+
}

samples/repo-base/compose.dev.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
app:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
environment:
7+
DB_URL: postgres://postgres:password@database:5432/postgres
8+
GOOGLE_GENERATIVE_AI_API_KEY: xxx
9+
GITHUB_TOKEN: xxx
10+
volumes:
11+
- ./next-app/src:/app/src
12+
- ./next-app/public:/app/public
13+
restart: always
14+
ports:
15+
- 3000:3000
16+
17+
database:
18+
image: postgres:16
19+
environment:
20+
POSTGRES_PASSWORD: password
21+
POSTGRES_DB: postgres
22+
POSTGRES_USER: postgres
23+
ports:
24+
- target: 5432
25+
published: 5432
26+
mode: host
27+
volumes:
28+
- postgres:/var/lib/postgresql/data
29+
30+
volumes:
31+
postgres: {}

samples/repo-base/compose.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
services:
2+
app:
3+
build:
4+
context: .
5+
environment:
6+
- DB_URL=postgres://postgres:${POSTGRES_PASSWORD}@database123defang:5432/postgres?sslmode=false
7+
- GOOGLE_GENERATIVE_AI_API_KEY
8+
- GITHUB_TOKEN
9+
restart: unless-stopped
10+
ports:
11+
- mode: ingress
12+
target: 8080
13+
published: 8080
14+
healthcheck:
15+
test: ["CMD", "curl", "-f", "http://localhost:8080"]
16+
depends_on:
17+
- database123defang
18+
19+
database123defang:
20+
image: postgres:16
21+
x-defang-postgres: true
22+
restart: always
23+
environment:
24+
- POSTGRES_PASSWORD
25+
- POSTGRES_DB=postgres
26+
- POSTGRES_USER=postgres
27+
ports:
28+
- mode: host
29+
target: 5432
30+
healthcheck:
31+
test: ["CMD-SHELL", "pg_isready -h localhost -U postgres -d postgres"]
32+
interval: 5s
33+
timeout: 5s
34+
retries: 10
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import "dotenv/config";
2+
import { defineConfig } from "drizzle-kit";
3+
4+
export default defineConfig({
5+
out: "./drizzle",
6+
dialect: "postgresql",
7+
dbCredentials: {
8+
url: process.env.DB_URL!,
9+
},
10+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { dirname } from "path";
2+
import { fileURLToPath } from "url";
3+
import { FlatCompat } from "@eslint/eslintrc";
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = dirname(__filename);
7+
8+
const compat = new FlatCompat({
9+
baseDirectory: __dirname,
10+
});
11+
12+
const eslintConfig = [
13+
...compat.extends("next/core-web-vitals", "next/typescript"),
14+
];
15+
16+
export default eslintConfig;

samples/repo-base/memory-vector.db

Whitespace-only changes.

0 commit comments

Comments
 (0)