Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into feat/auth-fw…
Browse files Browse the repository at this point in the history
…d-cookies-dbauth

* 'main' of github.com:redwoodjs/redwood:
  chore: update rsc fixture (redwoodjs#9986)
  fix(server): use file extension in import, fix graphql route registering (redwoodjs#9984)
  chore(deps): update babel monorepo (redwoodjs#9983)
  fix: unpin react types (redwoodjs#9727)
  fix(docker): compose dev and prod (redwoodjs#9982)
  fix(deps): update prisma monorepo to v5.9.1 (redwoodjs#9980)
  fix(cli): use fetch instead of `yarn npm info` (redwoodjs#9975)
  fix(test): Update createServer test to use a different port to normal (redwoodjs#9977)
  fix(docker): corepack permissions fix and style updates (redwoodjs#9976)
  • Loading branch information
dac09 committed Feb 9, 2024
2 parents f15184c + 9b009b0 commit 5136537
Show file tree
Hide file tree
Showing 35 changed files with 280 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"devDependencies": {
"@redwoodjs/vite": "7.0.0-canary.966",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15"
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19"
}
}
4 changes: 2 additions & 2 deletions __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
},
"devDependencies": {
"@redwoodjs/vite": "6.0.7",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"autoprefixer": "^10.4.17",
"postcss": "^8.4.35",
"postcss-loader": "^8.1.0",
Expand Down
21 changes: 12 additions & 9 deletions docs/docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Redwood's Dockerfile
:::note The Dockerfile is experimental

Redwood's Dockerfile is the collective effort of several hard-working community members.
We've worked hard to optimize the it, but expect changes as we collaborate with users and deploy providers.
We've worked hard to optimize it, but expect changes as we collaborate with users and deploy providers.

:::

Expand Down Expand Up @@ -136,6 +136,7 @@ The important thing is that they're all here, before the `yarn install` step:

```Dockerfile
RUN mkdir -p /home/node/.yarn/berry/index
RUN mkdir -p /home/node/.cache

RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 \
--mount=type=cache,target=/home/node/.cache,uid=1000 \
Expand All @@ -146,7 +147,7 @@ This step installs all your project's dependencies—production and dev.
Since we use multi-stage builds, your production images won't pay for the dev dependencies installed in this step.
The build stages need the dev dependencies.

The `mkdir` step is a workaround for a permission error. We're working on removing it, but for now if you remove it the install step will probably fail.
The `mkdir` steps are a workaround for a permission error. We're working on removing them, but for now if you remove them the install step will probably fail.

This step is a bit more involved than the others.
It uses a [cache mount](https://docs.docker.com/build/cache/#use-your-package-manager-wisely).
Expand Down Expand Up @@ -190,10 +191,10 @@ FROM base as api_build
# ARG MY_BUILD_TIME_ENV_VAR

COPY --chown=node:node api api
RUN yarn redwood build api
RUN yarn rw build api
```

After the work we did in the base stage, building the api side amounts to copying in the api directory and running `yarn redwood build api`.
After the work we did in the base stage, building the api side amounts to copying in the api directory and running `yarn rw build api`.

### The `api_serve` stage

Expand Down Expand Up @@ -228,6 +229,7 @@ Like other `COPY` instructions, ordering these files with care enables layering

```Dockerfile
RUN mkdir -p /home/node/.yarn/berry/index
RUN mkdir -p /home/node/.cache

RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 \
--mount=type=cache,target=/home/node/.cache,uid=1000 \
Expand Down Expand Up @@ -277,10 +279,10 @@ This `web_build` builds the web side:
FROM base as web_build

COPY --chown=node:node web web
RUN yarn redwood build web --no-prerender
RUN yarn rw build web --no-prerender
```

After the work we did in the base stage, building the web side amounts to copying in the web directory and running `yarn redwood build web`.
After the work we did in the base stage, building the web side amounts to copying in the web directory and running `yarn rw build web`.

This stage is a bit of a simplification.
It foregoes Redwood's prerendering (SSG) capability.
Expand All @@ -297,7 +299,7 @@ The `web_prerender_build` stage builds the web side with prerender.
FROM api_build as web_build_with_prerender

COPY --chown=node:node web web
RUN yarn redwood build web
RUN yarn rw build web
```

Building the web side with prerendering poses a challenge.
Expand All @@ -320,6 +322,7 @@ COPY --chown=node:node web/package.json web/
COPY --chown=node:node yarn.lock .

RUN mkdir -p /home/node/.yarn/berry/index
RUN mkdir -p /home/node/.cache

RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 \
--mount=type=cache,target=/home/node/.cache,uid=1000 \
Expand All @@ -332,9 +335,9 @@ COPY --chown=node:node .env.defaults .env.defaults
COPY --chown=node:node --from=web_build /home/node/app/web/dist /home/node/app/web/dist

ENV NODE_ENV=production \
API_HOST=http://api:8911
API_PROXY_TARGET=http://api:8911

CMD "node_modules/.bin/rw-web-server" "--apiHost" "$API_HOST"
CMD "node_modules/.bin/rw-web-server" "--api-proxy-target" "$API_PROXY_TARGET"
```

Most of this stage is similar to the `api_serve` stage, except that we're copying from the `web_build` stage instead of the `api_build`.
Expand Down
2 changes: 1 addition & 1 deletion packages/api-server/src/__tests__/createServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ describe('resolveOptions', () => {
DEFAULT_CREATE_SERVER_OPTIONS.fastifyServerOptions.requestTimeout,
logger: DEFAULT_CREATE_SERVER_OPTIONS.logger,
},
port: 8911,
port: 65501,
host: '::',
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

[web]
title = "Redwood App"
port = 8910
port = 65500
apiUrl = "/.redwood/functions" # You can customize graphql and dbauth urls individually too: see https://redwoodjs.com/docs/app-configuration-redwood-toml#api-paths
includeEnvironmentVariables = [
# Add any ENV vars that should be available to the web side to this array
# See https://redwoodjs.com/docs/environment-variables#web
]
[api]
port = 8911
port = 65501
[browser]
open = true
[notifications]
Expand Down
2 changes: 1 addition & 1 deletion packages/api-server/src/createServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function createServer(options: CreateServerOptions = {}) {
})

if (graphqlFunctionPath) {
const { redwoodFastifyGraphQLServer } = await import('./plugins/graphql')
const { redwoodFastifyGraphQLServer } = await import('./plugins/graphql.js')
// This comes from a babel plugin that's applied to api/dist/functions/graphql.{ts,js} in user projects
const { __rw_graphqlOptions } = await import(
`file://${graphqlFunctionPath}`
Expand Down
14 changes: 10 additions & 4 deletions packages/api-server/src/plugins/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,24 @@ export async function redwoodFastifyGraphQLServer(
return reply
}

const graphqlEndpoint = trimSlashes(yoga.graphqlEndpoint)

const routePaths = ['', '/health', '/readiness', '/stream']
for (const routePath of routePaths) {
fastify.route({
url: `${redwoodOptions.apiRootPath}${yoga.graphqlEndpoint}${routePath}`,
url: `${redwoodOptions.apiRootPath}${graphqlEndpoint}${routePath}`,
method,
handler: (req, reply) => graphQLYogaHandler(req, reply),
})
}

fastify.addHook('onReady', (done) => {
console.info(`GraphQL Yoga Server endpoint at ${yoga.graphqlEndpoint}`)
console.info(`GraphQL Yoga Server endpoint at ${graphqlEndpoint}`)
console.info(
`GraphQL Yoga Server Health Check endpoint at ${yoga.graphqlEndpoint}/health`
`GraphQL Yoga Server Health Check endpoint at ${graphqlEndpoint}/health`
)
console.info(
`GraphQL Yoga Server Readiness endpoint at ${yoga.graphqlEndpoint}/readiness`
`GraphQL Yoga Server Readiness endpoint at ${graphqlEndpoint}/readiness`
)

done()
Expand All @@ -126,3 +128,7 @@ export async function redwoodFastifyGraphQLServer(
console.log(e)
}
}

function trimSlashes(path: string) {
return path.replace(/^\/|\/$/g, '')
}
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.23.9",
"@prisma/client": "5.9.0",
"@prisma/client": "5.9.1",
"@whatwg-node/fetch": "0.9.16",
"cookie": "0.6.0",
"core-js": "3.35.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/auth0/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@auth0/auth0-spa-js": "2.1.2",
"@babel/cli": "7.23.9",
"@babel/core": "^7.22.20",
"@types/react": "18.2.37",
"@types/react": "^18.2.55",
"react": "0.0.0-experimental-e5205658f-20230913",
"typescript": "5.3.3",
"vitest": "1.2.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@babel/cli": "7.23.9",
"@babel/core": "^7.22.20",
"@types/netlify-identity-widget": "1.9.6",
"@types/react": "18.2.37",
"@types/react": "^18.2.55",
"react": "0.0.0-experimental-e5205658f-20230913",
"typescript": "5.3.3",
"vitest": "1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/clerk/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@babel/core": "^7.22.20",
"@clerk/clerk-react": "4.30.3",
"@clerk/types": "3.60.0",
"@types/react": "18.2.37",
"@types/react": "^18.2.55",
"react": "0.0.0-experimental-e5205658f-20230913",
"typescript": "5.3.3",
"vitest": "1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@babel/cli": "7.23.9",
"@babel/core": "^7.22.20",
"@simplewebauthn/typescript-types": "7.4.0",
"@types/react": "18.2.37",
"@types/react": "^18.2.55",
"jest": "29.7.0",
"react": "0.0.0-experimental-e5205658f-20230913",
"typescript": "5.3.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/firebase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"devDependencies": {
"@babel/cli": "7.23.9",
"@babel/core": "^7.22.20",
"@types/react": "18.2.37",
"@types/react": "^18.2.55",
"firebase": "10.7.0",
"jest": "29.7.0",
"react": "0.0.0-experimental-e5205658f-20230913",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/netlify/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@babel/cli": "7.23.9",
"@babel/core": "^7.22.20",
"@types/netlify-identity-widget": "1.9.6",
"@types/react": "18.2.37",
"@types/react": "^18.2.55",
"react": "0.0.0-experimental-e5205658f-20230913",
"typescript": "5.3.3",
"vitest": "1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supabase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@babel/cli": "7.23.9",
"@babel/core": "^7.22.20",
"@supabase/supabase-js": "2.39.0",
"@types/react": "18.2.37",
"@types/react": "^18.2.55",
"react": "0.0.0-experimental-e5205658f-20230913",
"typescript": "5.3.3",
"vitest": "1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supertokens/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"devDependencies": {
"@babel/cli": "7.23.9",
"@babel/core": "^7.22.20",
"@types/react": "18.2.37",
"@types/react": "^18.2.55",
"react": "0.0.0-experimental-e5205658f-20230913",
"supertokens-auth-react": "0.34.0",
"typescript": "5.3.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-packages/dataMigrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"yargs": "17.7.2"
},
"devDependencies": {
"@prisma/client": "5.9.0",
"@prisma/client": "5.9.1",
"@redwoodjs/framework-tools": "6.0.7",
"@types/fs-extra": "11.0.4",
"@types/yargs": "17.0.32",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@opentelemetry/resources": "1.18.1",
"@opentelemetry/sdk-trace-node": "1.18.1",
"@opentelemetry/semantic-conventions": "1.18.1",
"@prisma/internals": "5.9.0",
"@prisma/internals": "5.9.1",
"@redwoodjs/api-server": "6.0.7",
"@redwoodjs/cli-helpers": "6.0.7",
"@redwoodjs/fastify-web": "6.0.7",
Expand Down Expand Up @@ -73,7 +73,7 @@
"pluralize": "8.0.0",
"portfinder": "1.0.32",
"prettier": "2.8.8",
"prisma": "5.9.0",
"prisma": "5.9.1",
"prompts": "2.4.2",
"rimraf": "5.0.5",
"semver": "7.5.4",
Expand Down
29 changes: 16 additions & 13 deletions packages/cli/src/commands/experimental/templates/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# base
# ------------------------------------------------
# ----
FROM node:20-bookworm-slim as base

RUN corepack enable
Expand All @@ -22,6 +22,7 @@ COPY --chown=node:node web/package.json web/
COPY --chown=node:node yarn.lock .

RUN mkdir -p /home/node/.yarn/berry/index
RUN mkdir -p /home/node/.cache

RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 \
--mount=type=cache,target=/home/node/.cache,uid=1000 \
Expand All @@ -32,7 +33,7 @@ COPY --chown=node:node graphql.config.js .
COPY --chown=node:node .env.defaults .env.defaults

# api build
# ------------------------------------------------
# ---------
FROM base as api_build

# If your api side build relies on build-time environment variables,
Expand All @@ -41,24 +42,24 @@ FROM base as api_build
# ARG MY_BUILD_TIME_ENV_VAR

COPY --chown=node:node api api
RUN yarn redwood build api
RUN yarn rw build api

# web prerender build
# ------------------------------------------------
# -------------------
FROM api_build as web_build_with_prerender

COPY --chown=node:node web web
RUN yarn redwood build web
RUN yarn rw build web

# web build
# ------------------------------------------------
# ---------
FROM base as web_build

COPY --chown=node:node web web
RUN yarn redwood build web --no-prerender
RUN yarn rw build web --no-prerender

# serve api
# ------------------------------------------------
# api serve
# ---------
FROM node:20-bookworm-slim as api_serve

RUN corepack enable
Expand All @@ -77,6 +78,7 @@ COPY --chown=node:node api/package.json api/
COPY --chown=node:node yarn.lock .

RUN mkdir -p /home/node/.yarn/berry/index
RUN mkdir -p /home/node/.cache

RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 \
--mount=type=cache,target=/home/node/.cache,uid=1000 \
Expand All @@ -92,10 +94,10 @@ COPY --chown=node:node --from=api_build /home/node/app/node_modules/.prisma /hom

ENV NODE_ENV=production

CMD [ "node_modules/.bin/rw-server", "api", "--load-env-files" ]
CMD [ "node_modules/.bin/rw-server", "api" ]

# serve web
# ------------------------------------------------
# web serve
# ---------
FROM node:20-bookworm-slim as web_serve

RUN corepack enable
Expand All @@ -109,6 +111,7 @@ COPY --chown=node:node web/package.json web/
COPY --chown=node:node yarn.lock .

RUN mkdir -p /home/node/.yarn/berry/index
RUN mkdir -p /home/node/.cache

RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 \
--mount=type=cache,target=/home/node/.cache,uid=1000 \
Expand All @@ -127,7 +130,7 @@ ENV NODE_ENV=production \
CMD "node_modules/.bin/rw-web-server" "--api-proxy-target" "$API_PROXY_TARGET"

# console
# ------------------------------------------------
# -------
FROM base as console

# To add more packages:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
- SESSION_SECRET=super_secret_session_key_change_me_in_production_please
- CI=
- NODE_ENV=development
- REDWOOD_API_HOST=0.0.0.0

db:
image: postgres:16-bookworm
Expand Down
Loading

0 comments on commit 5136537

Please sign in to comment.