Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

Add docker file

Khuram Niazc376127541e3
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..cd13caf
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,5 @@
+node_modules
+npm-debug.log
+.next
+.vscode
+.git
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..cc74d57
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,89 @@
+# Use the official Node.js 18 image as the base image
+FROM node:18-alpine AS base
+
+# Install dependencies only when needed
+FROM base AS deps
+
+# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
+RUN apk add --no-cache libc6-compat
+# Set the working directory
+WORKDIR /app
+
+# Install dependencies based on the preferred package manager
+COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
+RUN \
+ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
+ elif [ -f package-lock.json ]; then npm ci; \
+ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
+ else echo "Lockfile not found." && exit 1; \
+ fi
+
+# Rebuild the source code only when needed
+FROM base AS builder
+WORKDIR /app
+COPY --from=deps /app/node_modules ./node_modules
+COPY . .
+
+# COPY ./prisma prisma/
+# COPY ./src src
+
+# Next.js collects completely anonymous telemetry data about general usage.
+# Learn more here: https://nextjs.org/telemetry
+ENV NEXT_TELEMETRY_DISABLED 1
+ENV DATABASE_URL=file:/data/dev.db
+
+# Generate Prisma client
+RUN npx prisma generate
+
+RUN \
+ if [ -f yarn.lock ]; then yarn run build; \
+ elif [ -f package-lock.json ]; then npm run build; \
+ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
+ else echo "Lockfile not found." && exit 1; \
+ fi
+
+# Production image, copy all the files and run next
+FROM base AS runner
+WORKDIR /app
+
+ENV NODE_ENV production
+# Uncomment the following line in case you want to disable telemetry during runtime.
+ENV NEXT_TELEMETRY_DISABLED 1
+# Set environment variables
+ENV NODE_ENV=production
+ENV DATABASE_URL=file:./data/dev.db
+ENV USER_PASSWORD=password123
+# Refer to readme to generate auth secret
+ENV AUTH_SECRET=Cft42eLmgapfLoot7ByiCL9ToNfbqZ4xaaMuOJsbm+9u
+ENV NEXTAUTH_URL: http://localhost:3000
+ENV AUTH_TRUST_HOST: http://localhost:3000
+
+RUN addgroup --system --gid 1001 nodejs && \
+ adduser --system --uid 1001 nextjs
+
+# COPY --from=builder /app/public ./public
+
+# Set the correct permission for prerender cache
+RUN mkdir .next
+RUN chown nextjs:nodejs .next
+
+# Add the wait script to ensure the database is ready before running migrations
+ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /wait
+RUN chmod +x /wait
+
+# Automatically leverage output traces to reduce image size
+# https://nextjs.org/docs/advanced-features/output-file-tracing
+# COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
+# COPY --from=builder --chown=nextjs:nodejs /app/.next/docstatic ./.next/static
+COPY --from=builder --chown=nextjs:nodejs /app /app
+
+# Run the wait script, then run migrations and seed the database
+USER nextjs
+
+EXPOSE 3000
+
+ENV PORT 3000
+
+# Start the jobsync application
+CMD /wait && npx prisma migrate deploy && npx prisma generate && npm run seed && npm start
diff --git a/README.md b/README.md
index c403366..4f63aef 100644
--- a/README.md
+++ b/README.md
@@ -34,3 +34,29 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next
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.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
+
+## Generate auth secret
+
+### For npm
+
+```sh
+ npm exec auth secret
+```
+OR
+```sh
+ npx auth secret
+```
+
+### Using the openssl command available on Linux and Mac OS X:
+
+```sh
+ openssl rand -base64 33
+```
+
+These methods will generate a random string that you can use as your AUTH_SECRET. Make sure to set this in your environment variables:
+
+For example, add it to your .env local file:
+
+```sh
+AUTH_SECRET="your_generated_secret"
+```
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..9f1f98f
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,21 @@
+services:
+ app:
+ container_name: jobsync_app
+ build:
+ context: .
+ dockerfile: Dockerfile
+ image: jobsync_app_image
+ ports:
+ - "3000:3000"
+ environment:
+ NODE_ENV: production
+ DATABASE_URL: file:/data/dev.db
+ # Change your initial username and password here
+ USER_EMAIL: [email protected]
+ USER_PASSWORD: password123
+ # Refer to readme to generate auth secret
+ AUTH_SECRET: Cft42eLmgapfLoot7ByiCL9ToNfbqZ4xaaMuOJsbm+9u
+ NEXTAUTH_URL: http://localhost:3000
+ AUTH_TRUST_HOST: http://localhost:3000
+ volumes:
+ - ./jobsyncdb/data:/data
diff --git a/package.json b/package.json
index 0572ab8..abc4e8d 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
- "seed": "node ./scripts/seed.js"
+ "seed": "node ./prisma/seed.js"
},
"dependencies": {
"@hookform/resolvers": "^3.4.2",
diff --git a/scripts/seed.js b/prisma/seed.js
similarity index 79%
rename from scripts/seed.js
rename to prisma/seed.js
index 74c1502..444e970 100644
--- a/scripts/seed.js
+++ b/prisma/seed.js
@@ -8,18 +8,24 @@ const prisma = new PrismaClient();
async function seedUser() {
try {
const password = await bcrypt.hash("password123", 10);
-
- const user1 = await prisma.user.upsert({
- where: { email: "[email protected]" },
- update: {},
- create: {
- email: "[email protected]",
- name: "Admin",
- password,
+ const email = "[email protected]";
+ // Check if the user already exists
+ const existingUser = await prisma.user.findUnique({
+ where: {
+ email,
},
});
-
- console.log("Seeded user: ", { user1 });
+ console.log("User already exists: ", { email });
+ if (!existingUser) {
+ await prisma.user.create({
+ data: {
+ email,
+ name: "Admin",
+ password,
+ },
+ });
+ console.log("Seeded user: ", { email });
+ }
} catch (error) {
console.error("Error seeding user: ", error);
throw error;