feat: add Supabase environment variables and optimize Docker build process
This commit is contained in:
parent
0bd850b40d
commit
9d0debb968
28
Dockerfile
28
Dockerfile
@ -1,22 +1,27 @@
|
||||
# Production-ready Dockerfile for Next.js
|
||||
FROM node:20-alpine AS builder
|
||||
# Receive build arguments passed by Coolify
|
||||
ARG NEXT_PUBLIC_SUPABASE_URL
|
||||
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||
|
||||
# Set the working directory in the container
|
||||
# Builder stage
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Set environment variables for the builder stage from build arguments
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
|
||||
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||
|
||||
# Copy package.json and package-lock.json from the 'myfavstuff' subdirectory
|
||||
COPY myfavstuff/package.json myfavstuff/package-lock.json* ./
|
||||
|
||||
# Install dependencies
|
||||
# Using npm ci for cleaner installs based on package-lock.json
|
||||
# Install dependencies including dev dependencies needed for build
|
||||
RUN npm ci
|
||||
|
||||
# Copy the rest of your app's source code from the 'myfavstuff' subdirectory
|
||||
COPY myfavstuff .
|
||||
|
||||
# Build the Next.js application
|
||||
# Debug the environment variables
|
||||
RUN echo "--- Debugging Build Environment Variables (Builder Stage) ---" && \
|
||||
echo "NEXT_PUBLIC_SUPABASE_URL: ($NEXT_PUBLIC_SUPABASE_URL)" && \
|
||||
echo "NEXT_PUBLIC_SUPABASE_ANON_KEY: ($NEXT_PUBLIC_SUPABASE_ANON_KEY)" && \
|
||||
@ -31,17 +36,18 @@ FROM node:20-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
|
||||
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||
|
||||
COPY --from=builder /app/public ./public
|
||||
# Next.js 15 uses a standalone output by default in the .next/standalone directory
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
# Look for .next output (either standalone or regular)
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT 3000
|
||||
ENV HOSTNAME 0.0.0.0
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
CMD ["npm", "start"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user