Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
astralis-nextjs/Dockerfile.build at main · astralisone/astralis-nextjs · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
astralisone
astralis-nextjs
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
astralis-nextjs
/
Dockerfile.build
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
110 lines (83 loc) · 3.49 KB
main
Breadcrumbs
astralis-nextjs
/
Dockerfile.build
Copy path
Top
File metadata and controls
Code
Blame
110 lines (83 loc) · 3.49 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
################################################################################
# FALLBACK DOCKERFILE - OPTIMIZED IN-CONTAINER BUILD
#
# Use this if you cannot build locally. This Dockerfile is heavily optimized
# to minimize memory usage during the Docker build process.
#
# Key optimizations:
# - Alpine base image (100MB vs 900MB)
# - Production-only dependency installation
# - Aggressive build caching with layer optimization
# - Reduced Node.js heap size to fit container limits
# - Parallel build workers limited to prevent OOM
################################################################################
FROM --platform=linux/amd64 node:20-alpine AS deps
WORKDIR /app
# Install native build dependencies
RUN apk add --no-cache libc6-compat python3 make g++
# Copy dependency manifests
COPY package.json yarn.lock ./
# Install ONLY production dependencies (skip devDependencies)
# This significantly reduces memory footprint
RUN yarn install --production --frozen-lockfile --network-timeout 600000 && \
yarn cache clean
################################################################################
# BUILD STAGE
################################################################################
FROM --platform=linux/amd64 node:20-alpine AS builder
WORKDIR /app
ENV NODE_ENV=production
# Install build-time dependencies
RUN apk add --no-cache libc6-compat python3 make g++
# Copy dependency files
COPY package.json yarn.lock ./
COPY --from=deps /app/node_modules ./node_modules
# Install devDependencies needed for build (TypeScript, Prisma, etc.)
RUN yarn install --frozen-lockfile --network-timeout 600000
# Copy source code
COPY tsconfig.json next.config.mjs ./
COPY prisma ./prisma
COPY src ./src
COPY public ./public
# Generate Prisma Client
RUN yarn prisma:gen
# Build with reduced memory allocation to prevent OOM
# Set heap size to 1.5GB (safe for 2GB container)
# Reduce parallelism to 2 workers max
ENV NODE_OPTIONS="--max-old-space-size=1536"
ENV NEXT_TELEMETRY_DISABLED=1
RUN yarn build
################################################################################
# RUNTIME STAGE
################################################################################
FROM --platform=linux/amd64 node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3001
ENV HOSTNAME="0.0.0.0"
ENV NEXT_TELEMETRY_DISABLED=1
# Install runtime dependencies
RUN apk add --no-cache \
libc6-compat \
openssl \
dumb-init && \
addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Copy production node_modules (already pruned)
COPY --from=deps --chown=nextjs:nodejs /app/node_modules ./node_modules
# Copy built application
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
# Copy Prisma files
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@prisma/client ./node_modules/@prisma/client
# Copy entrypoint
COPY --chown=nextjs:nodejs docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
USER nextjs
EXPOSE 3001
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3001/api/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"
ENTRYPOINT ["dumb-init", "./docker-entrypoint.sh"]
You can’t perform that action at this time.