turnsite test

WORKDIR /app # Install dependencies RUN apk add no-cache openssl python3 make g++ # Copy package files COPY package*.json ./ # Install all dependencies RUN npm

ibrahim
ibrahim
· 1 min read ·

 

WORKDIR /app

# Install dependencies
RUN apk add –no-cache openssl python3 make g++

# Copy package files
COPY package*.json ./

# Install all dependencies
RUN npm install

# Copy Prisma schema
COPY prisma ./prisma/

# Generate Prisma client
RUN npx prisma generate

# Copy all source files
COPY . .

# Accept build arguments and set them as environment variables for build
ARG PUBLIC_SITE_URL=http://localhost:4321
ARG PUBLIC_SITE_NAME=AstroSaaS
ARG PUBLIC_TURNSTILE_SITE_KEY

# Set them as ENV so they’re available during build
ENV PUBLIC_SITE_URL=${PUBLIC_SITE_URL}
ENV PUBLIC_SITE_NAME=${PUBLIC_SITE_NAME}
ENV PUBLIC_TURNSTILE_SITE_KEY=${PUBLIC_TURNSTILE_SITE_KEY}

# Build the Astro application (these vars are now embedded in client code)
RUN npm run build

# Clean up dev dependencies
RUN npm prune –production

# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /app

USER nodejs

EXPOSE 4321

# Runtime environment
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=4321

CMD [“node”, “./dist/server/entry.mjs”]

ibrahim

Written by ibrahim

1.2K Followers

Passionate writer sharing insights about technology, design, and innovation. Follow for more thoughtful content.