diff --git a/Dockerfile b/Dockerfile index ee2c543..494dd4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,3 +63,29 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ # Start the application with startup script CMD ["/app/start.sh"] + +# Prebuilt runtime stage (used locally): copies prebuilt dist and server-dist from context +FROM node:22-alpine AS production-prebuilt + +RUN npm install -g pnpm ts-node && apk add --no-cache su-exec curl +WORKDIR /app + +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +RUN pnpm install --frozen-lockfile --prod + +# Copy prebuilt artifacts from repository +COPY dist ./dist +COPY server-dist ./server-dist +COPY public ./public +COPY start.sh ./start.sh + +RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001 \ + && chmod +x /app/start.sh \ + && chown -R nextjs:nodejs /app \ + && chown root:root /app/.storage 2>/dev/null || true + +EXPOSE 3000 +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })" || exit 1 + +CMD ["/app/start.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index efa8928..7dc8128 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,8 @@ services: stargirlnails: - build: . + build: + context: . + target: production-prebuilt ports: - "3000:3000" env_file: