Skip to content

Commit

Permalink
Finalize web dockerfile v2
Browse files Browse the repository at this point in the history
  • Loading branch information
paescuj committed Jul 30, 2023
1 parent f91b77a commit 8bfc95d
Show file tree
Hide file tree
Showing 7 changed files with 692 additions and 1,035 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
**/.gitignore
**/.DS_Store
**/.dockerignore
**/Dockerfile
**/node_modules/
**/.next/
web/public/__ENV.js
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"eslint-plugin-import": "2.27.5",
"eslint-plugin-simple-import-sort": "10.0.0",
"prettier": "3.0.0"
}
},
"packageManager": "[email protected]"
}
1,626 changes: 638 additions & 988 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions web/.dockerignore

This file was deleted.

6 changes: 5 additions & 1 deletion web/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
env: {
// Enables browser globals like window and document
browser: true,
},
extends: ['next', 'next/core-web-vitals'],
parserOptions: {
babelOptions: {
presets: [require.resolve('next/babel')],
},
},
rules: {
// Enabled through Next.js
'import/no-anonymous-default-export': [
Expand Down
31 changes: 17 additions & 14 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# syntax=docker/dockerfile:1.4

### Builder
FROM node:18-alpine AS builder

RUN npm install -g pnpm

WORKDIR /builder

COPY pnpm-lock.yaml .
RUN corepack enable

COPY package.json pnpm-lock.yaml .
RUN pnpm fetch --prod

COPY package.json pnpm-workspace.yaml .
COPY pnpm-workspace.yaml .
COPY web web
RUN pnpm install -r --offline --prod \
&& pnpm --filter web add sharp
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1
RUN pnpm install --recursive --offline --prod

ENV NEXT_TELEMETRY_DISABLED=1
RUN pnpm --filter web run build

### Production
Expand All @@ -24,13 +24,16 @@ RUN addgroup -g 1001 app \
USER app
WORKDIR /home/app

COPY --from=builder --chown=app:app /builder/web/public public
# Automatically leverage output traces to reduce image size
COPY --from=builder --chown=app:app /builder/web/public web/public
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=app:app /builder/web/.next/standalone ./
COPY --from=builder --chown=app:app /builder/web/.next/static ./.next/static
COPY --from=builder --chown=app:app /builder/web/.next/standalone .
COPY --from=builder --chown=app:app /builder/web/.next/static web/.next/static

USER root
RUN npm install --global @beam-australia/react-env@$(node -e 'console.log(require("./web/package.json").dependencies["@beam-australia/react-env"])')
USER app

ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1
EXPOSE 3000
CMD ["node", "server.js"]
CMD react-env --prefix NEXT_PUBLIC --path web/.env.production --dest web/public && node web/server.js
46 changes: 22 additions & 24 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,50 @@
"private": true,
"scripts": {
"dev": "react-env --prefix NEXT_PUBLIC --path .env.development -- next dev",
"build": "next build",
"start": "react-env --prefix NEXT_PUBLIC --path .env.production -- next start",
"lint": "eslint . --ignore-path .gitignore",
"lint:fix": "pnpm run lint --fix"
"build": "next build"
},
"dependencies": {
"@beam-australia/react-env": "3.1.1",
"@chakra-ui/react": "2.4.9",
"@directus/sdk": "10.3.1",
"@dnd-kit/core": "6.0.7",
"@chakra-ui/layout": "2.3.0",
"@chakra-ui/react": "2.8.0",
"@directus/sdk": "10.3.5",
"@dnd-kit/core": "6.0.8",
"@dnd-kit/sortable": "7.0.2",
"@dnd-kit/utilities": "3.2.1",
"@emotion/react": "11.10.5",
"@emotion/styled": "11.10.5",
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@fontsource/quicksand": "4.5.12",
"@react-page/editor": "5.4.1",
"@react-page/plugins-slate": "5.4.1",
"@react-page/editor": "5.4.4",
"@react-page/plugins-slate": "5.4.4",
"@tippyjs/react": "4.2.6",
"animate.css": "4.1.1",
"chakra-react-select": "4.4.3",
"date-fns": "2.29.3",
"framer-motion": "9.0.2",
"iconoir-react": "6.2.1",
"chakra-react-select": "4.7.0",
"date-fns": "2.30.0",
"framer-motion": "9.1.7",
"iconoir-react": "6.10.0",
"language-icons": "0.3.0",
"lodash.isequal": "4.5.0",
"next": "13.1.6",
"next": "13.4.12",
"object-path": "0.11.8",
"object-traversal": "1.0.1",
"omgopass": "3.2.1",
"pullstate": "1.25.0",
"quick-score": "0.2.0",
"react": "18.2.0",
"react-big-calendar": "1.6.4",
"react-datepicker": "4.10.0",
"react-big-calendar": "1.8.1",
"react-datepicker": "4.16.0",
"react-dom": "18.2.0",
"react-flip-toolkit": "7.0.17",
"react-hook-form": "7.43.1",
"react-intl": "6.2.8",
"react-flip-toolkit": "7.1.0",
"react-hook-form": "7.45.2",
"react-intl": "6.4.4",
"react-measure": "2.5.2",
"react-pdf": "6.2.2",
"swiper": "9.0.4",
"swiper": "9.4.1",
"tippy.js": "^6.3.7"
},
"devDependencies": {
"@types/react": "18.0.28",
"eslint-config-next": "13.1.6",
"@types/react": "18.2.17",
"eslint-config-next": "13.4.12",
"eslint-import-resolver-alias": "1.1.2"
}
}

0 comments on commit 8bfc95d

Please sign in to comment.