Created
August 2, 2023 10:58
-
-
Save nabakdev/219416ccce318af2ffc9038e9ca54b86 to your computer and use it in GitHub Desktop.
Dockerized Nuxt.js with Chainguard distroless
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original template is from next.js example https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile | |
#syntax=docker/dockerfile:1.4 | |
FROM node:18-alpine AS base | |
# Install dependencies only when needed | |
FROM base AS deps | |
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | |
RUN apk add --no-cache libc6-compat | |
WORKDIR /app | |
# Install dependencies based on the preferred package manager | |
COPY --link package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | |
RUN \ | |
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | |
elif [ -f package-lock.json ]; then npm ci; \ | |
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ | |
else echo "Lockfile not found." && exit 1; \ | |
fi | |
# Rebuild the source code only when needed | |
FROM base AS builder | |
WORKDIR /app | |
COPY --from=deps --link /app/node_modules ./node_modules | |
COPY --link . . | |
RUN yarn build | |
# If using npm comment out above and use below instead | |
# RUN npm run build | |
FROM cgr.dev/chainguard/node:latest AS runner | |
WORKDIR /app | |
ENV HOST=0.0.0.0 \ | |
NODE_ENV="production" \ | |
NUXT_PUBLIC_SITE_URL="" \ | |
NUXT_PUBLIC_SITE_NAME=TopUp \ | |
NUXT_PUBLIC_SITE_DESCRIPTION="" \ | |
NITRO_PORT="3000" | |
COPY --from=builder --link /app/.output ./.output | |
EXPOSE $NITRO_PORT | |
CMD [".output/server/index.mjs"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment