|
| 1 | +# Dockerfile for @schemavaults/example-nextjs-resource-server |
| 2 | + |
| 3 | +ARG BUN_VERSION |
| 4 | +ARG NODEJS_VERSION |
| 5 | + |
| 6 | +FROM oven/bun:${BUN_VERSION} AS bunbase |
| 7 | +FROM node:${NODEJS_VERSION} AS nodejsbase |
| 8 | + |
| 9 | +FROM bunbase AS deps |
| 10 | + |
| 11 | +WORKDIR /schemavaults/auth |
| 12 | + |
| 13 | +### Monorepo Root Package Details ### |
| 14 | +COPY --chown=bun:bun package.json package.json |
| 15 | +COPY --chown=bun:bun bun.lock bun.lock |
| 16 | +COPY --chown=bun:bun turbo.json turbo.json |
| 17 | + |
| 18 | +# Copy helper script for removing "./auth-server" from 'workspaces' definitions. we only need packages and tests. |
| 19 | +COPY scripts/remove-auth-server-from-workspaces-definition.sh scripts/remove-auth-server-from-workspaces-definition.sh |
| 20 | + |
| 21 | +# Set permissions for the helper script |
| 22 | +RUN chmod +x scripts/remove-auth-server-from-workspaces-definition.sh |
| 23 | +RUN /bin/bash ./scripts/remove-auth-server-from-workspaces-definition.sh |
| 24 | + |
| 25 | +### Example Resource Server Config Files ### |
| 26 | +COPY --chown=bun:bun tests/example-nextjs-resource-server/package.json tests/example-nextjs-resource-server/package.json |
| 27 | +COPY --chown=bun:bun tests/example-nextjs-resource-server/postcss.config.js tests/example-nextjs-resource-server/postcss.config.js |
| 28 | +COPY --chown=bun:bun tests/example-nextjs-resource-server/tailwind.config.ts tests/example-nextjs-resource-server/tailwind.config.ts |
| 29 | +COPY --chown=bun:bun tests/example-nextjs-resource-server/next.config.ts tests/example-nextjs-resource-server/next.config.ts |
| 30 | +COPY --chown=bun:bun tests/example-nextjs-resource-server/tsconfig.json tests/example-nextjs-resource-server/tsconfig.json |
| 31 | + |
| 32 | +### Supporting Auth Packages (Config Files) ### |
| 33 | + |
| 34 | +# @schemavaults/app-definitions |
| 35 | +COPY --chown=bun:bun packages/app-definitions/package.json packages/app-definitions/package.json |
| 36 | +COPY --chown=bun:bun packages/app-definitions/tsconfig.json packages/app-definitions/tsconfig.json |
| 37 | +COPY --chown=bun:bun packages/app-definitions/eslint.config.cjs packages/app-definitions/eslint.config.cjs |
| 38 | + |
| 39 | +# @schemavaults/auth-client-sdk |
| 40 | +COPY --chown=bun:bun packages/auth-client-sdk/package.json packages/auth-client-sdk/package.json |
| 41 | +COPY --chown=bun:bun packages/auth-client-sdk/tsconfig.json packages/auth-client-sdk/tsconfig.json |
| 42 | +COPY --chown=bun:bun packages/auth-client-sdk/eslint.config.cjs packages/auth-client-sdk/eslint.config.cjs |
| 43 | +COPY --chown=bun:bun packages/auth-client-sdk/generate-version.sh packages/auth-client-sdk/generate-version.sh |
| 44 | +COPY --chown=bun:bun packages/auth-client-sdk/turbo.json packages/auth-client-sdk/turbo.json |
| 45 | + |
| 46 | +# @schemavaults/auth-common |
| 47 | +COPY --chown=bun:bun packages/auth-common/package.json packages/auth-common/package.json |
| 48 | +COPY --chown=bun:bun packages/auth-common/tsconfig.json packages/auth-common/tsconfig.json |
| 49 | +COPY --chown=bun:bun packages/auth-common/eslint.config.cjs packages/auth-common/eslint.config.cjs |
| 50 | + |
| 51 | +# @schemavaults/auth-react-provider |
| 52 | +COPY --chown=bun:bun packages/auth-react-provider/package.json packages/auth-react-provider/package.json |
| 53 | +COPY --chown=bun:bun packages/auth-react-provider/tsconfig.json packages/auth-react-provider/tsconfig.json |
| 54 | +COPY --chown=bun:bun packages/auth-react-provider/eslint.config.cjs packages/auth-react-provider/eslint.config.cjs |
| 55 | + |
| 56 | +# @schemavaults/auth-resource-server-codegen-templates |
| 57 | +COPY --chown=bun:bun packages/auth-resource-server-codegen-templates/package.json packages/auth-resource-server-codegen-templates/package.json |
| 58 | +COPY --chown=bun:bun packages/auth-resource-server-codegen-templates/tsconfig.json packages/auth-resource-server-codegen-templates/tsconfig.json |
| 59 | +COPY --chown=bun:bun packages/auth-resource-server-codegen-templates/eslint.config.cjs packages/auth-resource-server-codegen-templates/eslint.config.cjs |
| 60 | + |
| 61 | +# @schemavaults/auth-server-sdk |
| 62 | +COPY --chown=bun:bun packages/auth-server-sdk/package.json packages/auth-server-sdk/package.json |
| 63 | +COPY --chown=bun:bun packages/auth-server-sdk/tsconfig.json packages/auth-server-sdk/tsconfig.json |
| 64 | +COPY --chown=bun:bun packages/auth-server-sdk/eslint.config.cjs packages/auth-server-sdk/eslint.config.cjs |
| 65 | +COPY --chown=bun:bun packages/auth-server-sdk/copy-codegen-templates.sh packages/auth-server-sdk/copy-codegen-templates.sh |
| 66 | +COPY --chown=bun:bun packages/auth-server-sdk/prepare-cli.sh packages/auth-server-sdk/prepare-cli.sh |
| 67 | + |
| 68 | +# @schemavaults/jwt |
| 69 | +COPY --chown=bun:bun packages/jwt/package.json packages/jwt/package.json |
| 70 | +COPY --chown=bun:bun packages/jwt/tsconfig.json packages/jwt/tsconfig.json |
| 71 | +COPY --chown=bun:bun packages/jwt/eslint.config.cjs packages/jwt/eslint.config.cjs |
| 72 | + |
| 73 | +### Install packages |
| 74 | +RUN bun install |
| 75 | + |
| 76 | +FROM deps AS development |
| 77 | + |
| 78 | +### Command to launch development environment |
| 79 | +# You'll want to ensure that src/ directories are mounted |
| 80 | +WORKDIR /schemavaults/auth |
| 81 | +CMD [ "bun", "run", "dev", "--filter", "@schemavaults/example-nextjs-resource-server" ] |
| 82 | + |
| 83 | +FROM deps AS source |
| 84 | + |
| 85 | +WORKDIR /schemavaults/auth |
| 86 | + |
| 87 | +### Example Resource Server (Source Code) ### |
| 88 | + |
| 89 | +COPY --chown=bun:bun tests/example-nextjs-resource-server/src/ tests/example-nextjs-resource-server/src/ |
| 90 | +COPY --chown=bun:bun tests/example-nextjs-resource-server/public/ tests/example-nextjs-resource-server/public/ |
| 91 | + |
| 92 | +### Supporting Auth Packages (Source Code) ### |
| 93 | + |
| 94 | +# @schemavaults/app-definitions |
| 95 | +COPY --chown=bun:bun packages/app-definitions/src/ packages/app-definitions/src/ |
| 96 | + |
| 97 | +# @schemavaults/auth-client-sdk |
| 98 | +COPY --chown=bun:bun packages/auth-client-sdk/src/ packages/auth-client-sdk/src/ |
| 99 | + |
| 100 | +# @schemavaults/auth-common |
| 101 | +COPY --chown=bun:bun packages/auth-common/src/ packages/auth-common/src/ |
| 102 | + |
| 103 | +# @schemavaults/auth-react-provider |
| 104 | +COPY --chown=bun:bun packages/auth-react-provider/src/ packages/auth-react-provider/src/ |
| 105 | + |
| 106 | +# @schemavaults/auth-resource-server-codegen-templates |
| 107 | +COPY --chown=bun:bun packages/auth-resource-server-codegen-templates/src/ packages/auth-resource-server-codegen-templates/src/ |
| 108 | + |
| 109 | +# @schemavaults/auth-server-sdk |
| 110 | +COPY --chown=bun:bun packages/auth-server-sdk/src/ packages/auth-server-sdk/src/ |
| 111 | + |
| 112 | +# @schemavaults/jwt |
| 113 | +COPY --chown=bun:bun packages/jwt/src/ packages/jwt/src/ |
| 114 | + |
| 115 | +### Build final server code ### |
| 116 | +FROM source AS build |
| 117 | + |
| 118 | +WORKDIR /schemavaults/auth |
| 119 | + |
| 120 | +# Build server |
| 121 | +ENV NEXT_STANDALONE_DOCKER_BUILD true |
| 122 | +ENV NEXT_TELEMETRY_DISABLED 1 |
| 123 | +RUN bun run build --filter @schemavaults/example-nextjs-resource-server |
| 124 | + |
| 125 | +FROM nodejsbase AS production |
| 126 | + |
| 127 | +WORKDIR /schemavaults/auth |
| 128 | + |
| 129 | +COPY --from=build --chown=nodejs:nodejs /schemavaults/auth/example-nextjs-resource-server/package.json tests/example-nextjs-resource-server/package.json |
| 130 | +COPY --from=build --chown=nodejs:nodejs /schemavaults/auth/example-nextjs-resource-server/.next/standalone/ tests/example-nextjs-resource-server/.next/standalone/ |
| 131 | +COPY --from=build --chown=nodejs:nodejs /schemavaults/auth/example-nextjs-resource-server/.next/static/ tests/example-nextjs-resource-server/.next/standalone/tests/example-nextjs-resource-server/.next/static/ |
| 132 | +COPY --from=build --chown=nodejs:nodejs /schemavaults/auth/example-nextjs-resource-server/public/ tests/example-nextjs-resource-server/.next/standalone/tests/example-nextjs-resource-server/public/ |
| 133 | + |
| 134 | +WORKDIR /schemavaults/auth/tests/example-nextjs-resource-server |
| 135 | + |
| 136 | +EXPOSE 80 |
| 137 | +ENV PORT 80 |
| 138 | +ENV HOSTNAME 0.0.0.0 |
| 139 | + |
| 140 | +ENV NEXT_TELEMETRY_DISABLED 1 |
| 141 | +ENV NEXT_STANDALONE_DOCKER_BUILD true |
| 142 | + |
| 143 | +CMD [ "node", "./.next/standalone/tests/example-nextjs-resource-server/server.js" ] |
0 commit comments