-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.multistage
47 lines (40 loc) · 1.36 KB
/
Dockerfile.multistage
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
# Install dependencies only when needed
FROM node:alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# Rebuild the source code only when needed
FROM node:alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
ARG NODE_ENV=devolpement
RUN echo ${NODE_ENV}
RUN NODE_ENV=${NODE_ENV} yarn build
# Production image, copy all the files and run next
FROM node:alpine AS runner
WORKDIR /app
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./next.config.js
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/src ./src
COPY --from=builder /app/styles ./styles
COPY --from=builder /app/next-env.d.ts ./next-env.d.ts
USER nextjs
ARG PORT=3000
EXPOSE ${PORT}
# Expose (for some reason, Azure Spring Apps requires port 1025)
# EXPOSE 1025
# Parameterize env variables
ENV VIRTUAL_CUSTOMERS_URL=http://localhost:8091
ENV ORDERS_URL=http://localhost:8082
ENV ACCOUNTING_URL=http://localhost:8087
ENV OPENAI_URL=http://127.0.0.1:8000
# Start next
CMD ["yarn", "start"]