Production build at container run time
All checks were successful
Build Production Image / Build Production Image (push) Successful in 58s
All checks were successful
Build Production Image / Build Production Image (push) Successful in 58s
This commit is contained in:
parent
d98da909ae
commit
e666588cc3
@ -2,6 +2,7 @@
|
||||
node_modules
|
||||
|
||||
# Ignore common folders that we do not need
|
||||
.git
|
||||
.next
|
||||
.github
|
||||
.vscode
|
23
Dockerfile
23
Dockerfile
@ -1,6 +1,7 @@
|
||||
FROM docker.io/library/node:18-alpine AS build-env
|
||||
|
||||
# Disable telemetry
|
||||
ENV NODE_ENV production
|
||||
ENV PORT 3000
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
WORKDIR /app
|
||||
@ -15,23 +16,5 @@ RUN npm install
|
||||
# Copy files. Use dockerignore to avoid copying node_modules
|
||||
COPY . .
|
||||
|
||||
# Build
|
||||
RUN npm run build
|
||||
|
||||
# Running the app
|
||||
FROM gcr.io/distroless/nodejs:18 AS runner
|
||||
WORKDIR /app
|
||||
|
||||
# Mark as prod, disable telemetry, set port
|
||||
ENV NODE_ENV production
|
||||
ENV PORT 3000
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
# Copy from build
|
||||
COPY --from=build-env /app/next.config.mjs ./
|
||||
COPY --from=build-env /app/public ./public
|
||||
COPY --from=build-env /app/.next ./.next
|
||||
COPY --from=build-env /app/node_modules ./node_modules
|
||||
|
||||
# Run app command
|
||||
CMD ["./node_modules/next/dist/bin/next", "start"]
|
||||
CMD ["/bin/ash", "/app/entrypoint.sh"]
|
7
entrypoint.sh
Executable file
7
entrypoint.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The build step hard-codes variables from the environment into HTML, so it must
|
||||
# be done with the correct .env.local for runtime.
|
||||
|
||||
./node_modules/next/dist/bin/next build
|
||||
./node_modules/next/dist/bin/next start
|
Loading…
Reference in New Issue
Block a user