diff --git a/README.md b/README.md index 1312870..22496e2 100644 --- a/README.md +++ b/README.md @@ -55,14 +55,17 @@ Checks the code for linting issues. ## ⚙️ Environment Variables -Create a `.env` file in the root directory with the following variables: +Create a `.env.local` file in the root directory with the following variables: ``` -REACT_APP_API_URL=https://back-dev.clinic-pro.ir -REACT_APP_CLIENT_ID=NWuujdYHjtAtrhrk_zoWB3w0kyf56wRCOaY36MIqvbs -REACT_APP_CLIENT_SECRET=trhrk_zoWB3w0kyf +NEXT_PUBLIC_API_URL=https://back-dev.clinic-pro.ir +NEXT_PUBLIC_CLIENT_ID=NWuujdYHjtAtrhrk_zoWB3w0kyf56wRCOaY36MIqvbs +NEXT_PUBLIC_CLIENT_SECRET=trhrk_zoWB3w0kyf +NODE_ENV=development # or production ``` +**Note:** In Next.js, environment variables that need to be accessible in the browser must be prefixed with `NEXT_PUBLIC_`. Variables without this prefix are only available on the server side. + ## 🌐 Features - ✅ Responsive design using MUI and Tailwind @@ -99,4 +102,3 @@ This project is private or under your preferred license. --- > Developed with ❤️ by the Nobat724 team. - diff --git a/docker-compose.yml b/docker-compose.yml index 7b540a6..0c1d5fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,6 @@ services: ports: - "${APP_PORT}:3000" environment: - - NODE_ENV=production - NEXT_TELEMETRY_DISABLED=1 - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} - NEXT_PUBLIC_CLIENT_ID=${NEXT_PUBLIC_CLIENT_ID} diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..2f9804a --- /dev/null +++ b/dockerfile @@ -0,0 +1,48 @@ +# Dockerfile for Next.js 14 - Optimized for Production + +# Use the official Node.js image with Alpine Linux for a smaller footprint +FROM node:22-alpine AS base + +# Set the working directory in the container +WORKDIR /app + +# Copy package.json and package-lock.json (or yarn.lock) +COPY package*.json ./ + +# Install dependencies - leveraging Docker cache +RUN npm i --force + +# Copy the rest of the application code +COPY . . + +# Build the Next.js application +RUN npm run build + +# Stage 2: Production image - smaller and leaner +FROM node:22-alpine AS runner + +# Set the working directory +WORKDIR /app + +# Set environment variables +ENV NODE_ENV $NODE_ENV +ENV NEXT_TELEMETRY_DISABLED 1 + +# Add a non-root user for security +RUN addgroup -g 1001 -S nodejs +RUN adduser -S nextjs -u 1001 + +# Copy only the necessary files from the builder stage +COPY --from=base /app/next.config.js ./ +COPY --from=base /app/public ./public +COPY --from=base --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=base --chown=nextjs:nodejs /app/.next/static ./.next/static + +# Change ownership of all copied files to the non-root user +USER nextjs + +# Expose the port Next.js listens on +EXPOSE 3000 + +# Command to start the Next.js server in production mode +CMD ["node", "server.js"] \ No newline at end of file