-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (57 loc) · 2.06 KB
/
Copy pathDockerfile
File metadata and controls
77 lines (57 loc) · 2.06 KB
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
# Frontend Dockerfile - Multi-stage build for Next.js SSR
FROM node:22-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build arguments for configurable API URL
ARG NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-/}
# Set environment for building
ENV NEXT_PUBLIC_USE_MOCK_WALLET=false
ENV NEXT_PUBLIC_DEFAULT_NETWORK=testnet
ENV NEXT_PUBLIC_HATHOR_NODE_URL_TESTNET=https://node1.india.testnet.hathor.network/v1a
ENV NEXT_PUBLIC_HATHOR_NODE_URL_MAINNET=https://node1.mainnet.hathor.network/v1a
ENV NEXT_PUBLIC_CONTRACT_IDS_TESTNET='["00000000361ec0406d90a5bb4c6c7330af5792178b86cfc353afd4e50a62b741"]'
ENV NEXT_PUBLIC_CONTRACT_IDS_MAINNET='["000003e0baf17eee5a25aa0ccf36eb331a05818c87bc1c316f54485aa974c485"]'
ENV NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=8264fff563181da658ce64ee80e80458
# Set environment for production build
ENV NEXT_TELEMETRY_DISABLED=1
# Build the application
RUN npm run build
# Production stage
FROM node:22-alpine AS runner
# Install curl for health checks and other utilities
RUN apk add --no-cache curl
# Set working directory
WORKDIR /app
# Build arguments for runtime configuration
ARG NEXT_PUBLIC_API_URL
# Set environment
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-/}
# Copy built application
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# Copy public directory (includes hathor-modules.json.gz)
COPY --from=builder /app/public ./public
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -G nodejs && \
chown -R nextjs:nodejs /app
# Switch to non-root user
USER nextjs
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/ || exit 1
# Set hostname to 0.0.0.0 to accept connections from outside the container
ENV HOSTNAME=0.0.0.0
# Start Next.js
CMD ["node", "server.js"]