-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathDockerfile.config
More file actions
64 lines (48 loc) · 1.75 KB
/
Dockerfile.config
File metadata and controls
64 lines (48 loc) · 1.75 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
# docker build -t ff .
# docker run -p 3000:3000 -it ff
# Build stage
FROM --platform=$BUILDPLATFORM node:24.14.0-trixie-slim AS builder
ARG TARGETPLATFORM
ARG BUILDPLATFORM
WORKDIR /gen3
# Copy dependency files first for better caching
COPY package.json package-lock.json ./
# Install ALL dependencies once (including dev deps for build)
RUN npm config set fetch-retries 5 && \
npm config set fetch-retry-mintimeout 20000 && \
npm config set fetch-retry-maxtimeout 120000 && \
npm ci && \
npm cache clean --force
# Copy necessary config files
COPY next.config.js tsconfig.json tailwind.config.js postcss.config.js ./
COPY .env.production ./
# Copy source files
COPY ./src ./src
COPY ./public ./public
COPY ./config ./config
COPY ./start_with_config.sh ./start.sh
# Build and prune
RUN npm run build:volume && \
npm prune --omit=dev;
FROM node:24.14.0-trixie-slim AS runner
WORKDIR /gen3
RUN addgroup --system --gid 1001 nextjs && \
adduser --system --uid 1001 nextjs
COPY --from=builder --chown=nextjs:nextjs /gen3/.next/standalone ./.next/standalone
COPY --from=builder --chown=nextjs:nextjs /gen3/.next/static ./.next/standalone/.next/static
COPY --from=builder --chown=nextjs:nextjs /gen3/start.sh ./start.sh
COPY --from=builder --chown=nextjs:nextjs /gen3/config ./config
COPY --from=builder --chown=nextjs:nextjs /gen3/public ./public
#VOLUME /gen3/config
#VOLUME /gen3/public
RUN mkdir -p /gen3/.next/cache/images && \
chmod -R 777 /gen3/.next/cache && \
chown -R nextjs:nextjs /gen3/.next/cache
RUN chmod +x start.sh && \
chown -R nextjs:nextjs start.sh
RUN rm -rf .next/standalone/config
RUN cd .next/standalone && \
ln -s ../../config ./config && \
ln -s ../../public ./public
USER nextjs:nextjs
CMD ["sh", "./start.sh"]