diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b7f91f5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +# Don't copy node_modules +node_modules + +# Ignore common folders that we do not need +.next +.github +.vscode \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a7c2e4b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM docker.io/library/node:18-alpine AS build-env + +# Disable telemetry +ENV NEXT_TELEMETRY_DISABLED 1 + +WORKDIR /app + +# Building app +COPY package*.json ./ + +# Install node modules +# Note: We also install dev deps as TypeScript may be needed +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"] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6701984..82a4ad3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "eslint-config-next": "13.4.16", "prettier": "^3.0.1", "prettier-plugin-tailwindcss": "^0.5.2", - "sharp": "^0.32.0" + "sharp": "0.32.6" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -8714,9 +8714,9 @@ "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" }, "node_modules/sharp": { - "version": "0.32.4", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.32.4.tgz", - "integrity": "sha512-exUnZewqVZC6UXqXuQ8fyJJv0M968feBi04jb9GcUHrWtkRoAKnbJt8IfwT4NJs7FskArbJ14JAFGVuooszoGg==", + "version": "0.32.6", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.32.6.tgz", + "integrity": "sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -16578,9 +16578,9 @@ "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" }, "sharp": { - "version": "0.32.4", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.32.4.tgz", - "integrity": "sha512-exUnZewqVZC6UXqXuQ8fyJJv0M968feBi04jb9GcUHrWtkRoAKnbJt8IfwT4NJs7FskArbJ14JAFGVuooszoGg==", + "version": "0.32.6", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.32.6.tgz", + "integrity": "sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==", "dev": true, "requires": { "color": "^4.2.3", diff --git a/package.json b/package.json index 1e4ce45..d104452 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "remark-gfm": "^3.0.1", + "sharp": "0.32.6", "stripe": "14.9.0", "tailwindcss": "^3.3.3", "typescript": "5.1.6" @@ -43,7 +44,6 @@ "eslint": "8.45.0", "eslint-config-next": "13.4.16", "prettier": "^3.0.1", - "prettier-plugin-tailwindcss": "^0.5.2", - "sharp": "^0.32.0" + "prettier-plugin-tailwindcss": "^0.5.2" } -} +} \ No newline at end of file