docs: make 2.x the default version (#3369)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
---
|
||||
description: "Deploy Fresh on Cloudflare Workers"
|
||||
---
|
||||
|
||||
Deploy Fresh to Cloudflare Workers by following these instructions:
|
||||
|
||||
1. Run `deno install --allow-scripts npm:@cloudflare/vite-plugin npm:wrangler`
|
||||
2. Add the cloudflare plugin in your vite configuration file:
|
||||
|
||||
```diff vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
+ import { cloudflare } from "@cloudflare/vite-plugin";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
fresh(),
|
||||
+ cloudflare(),
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
3. Follow further instructions provided by the cloudflare vite plugin.
|
||||
|
||||
Check out the
|
||||
[Cloudflare Documentation](https://developers.cloudflare.com/workers/vite-plugin/)
|
||||
for further information.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
description: "Generate a self contained executable with deno compile."
|
||||
---
|
||||
|
||||
You can create a self-contained executable out of your app with the
|
||||
[`deno compile` command](https://docs.deno.com/runtime/reference/cli/compile/).
|
||||
It will include all assets and dependencies. This executable can run on any
|
||||
platform without requiring Deno to be installed.
|
||||
|
||||
```sh
|
||||
# Build your app first
|
||||
$ deno task build
|
||||
# Generate self-contained executable
|
||||
deno compile --include static --include _fresh --include deno.json -A my-app _fresh/compiled-entry.js
|
||||
```
|
||||
|
||||
The compiled entry supports two environment variables out of the box:
|
||||
|
||||
- `PORT` to set the port number (`PORT=4000 my-app`)
|
||||
- `HOSTNAME` to set the host name number (`HOSTNAME=0.0.0.0 my-app`)
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
description: "Deploy Fresh on Deno Deploy"
|
||||
---
|
||||
|
||||
The recommended way to deploy Fresh is by using
|
||||
[Deno Deploy](https://deno.com/deploy). It will automatically create branch
|
||||
previews for pull requests, collect request and HTTP metrics, as well has
|
||||
collect traces for you out of the box.
|
||||
|
||||
1. Log in to [Deno Deploy](https://deno.com/deploy)
|
||||
1. Create a new app
|
||||
1. Link your GitHub repository
|
||||
1. Pick the "Fresh" preset if it's not already detected automatically
|
||||
|
||||
Every time you merge into the `main` branch a new production deployment will be
|
||||
created.
|
||||
@@ -0,0 +1,51 @@
|
||||
---
|
||||
description: "Deploy Fresh with Docker"
|
||||
---
|
||||
|
||||
You can deploy Fresh to any platform that can run Docker containers. Docker is a
|
||||
tool to containerize projects and portably run them on any supported platform.
|
||||
|
||||
When packaging your Fresh app for Docker, it is important that you set the
|
||||
`DENO_DEPLOYMENT_ID` environment variable in your container. This variable needs
|
||||
to be set to an opaque string ID that represents the version of your application
|
||||
that is currently being run. This could be a Git commit hash, or a hash of all
|
||||
files in your project. It is critical for the function of Fresh that this ID
|
||||
changes when _any_ file in your project changes - if it doesn't, incorrect
|
||||
caching **will** cause your project to not function correctly.
|
||||
|
||||
Here is an example `Dockerfile` for a Fresh project:
|
||||
|
||||
```dockerfile Dockerfile
|
||||
FROM denoland/deno:latest
|
||||
|
||||
ARG GIT_REVISION
|
||||
ENV DENO_DEPLOYMENT_ID=${GIT_REVISION}
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
RUN deno task build
|
||||
RUN deno cache _fresh/server.js
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["serve", "-A", "_fresh/server.js"]
|
||||
```
|
||||
|
||||
To build your Docker image inside of a Git repository:
|
||||
|
||||
```sh Terminal
|
||||
$ docker build --build-arg GIT_REVISION=$(git rev-parse HEAD) -t my-fresh-app .
|
||||
```
|
||||
|
||||
Then run your Docker container:
|
||||
|
||||
```sh Terminal
|
||||
$ docker run -t -i -p 80:8000 my-fresh-app
|
||||
```
|
||||
|
||||
To deploy to a cloud provider, push it to a container registry and follow their
|
||||
documentation.
|
||||
|
||||
- [Amazon Web Services](https://docs.aws.amazon.com/AmazonECS/latest/userguide/create-container-image.html#create-container-image-push-ecr)
|
||||
- [Google Cloud](https://cloud.google.com/container-registry/docs/pushing-and-pulling)
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
description: "Create a production build of your app"
|
||||
---
|
||||
|
||||
When shipping an app to production, we can run a build step that optimizes
|
||||
assets for consumption in the browser. This step can be invoked by running:
|
||||
|
||||
```sh Terminal
|
||||
deno task build
|
||||
# or
|
||||
deno run -A dev.ts build
|
||||
```
|
||||
|
||||
Once completed, it will have created a `_fresh` folder in the project directory
|
||||
which contains the optimized assets.
|
||||
|
||||
> [info]: The `_fresh` folder should not be committed to git. Exclude it via
|
||||
> `.gitignore`.
|
||||
>
|
||||
> ```gitignore .gitignore
|
||||
> # Ignore fresh build directory
|
||||
> _fresh/
|
||||
> ```
|
||||
|
||||
## Running a production build
|
||||
|
||||
To run Fresh in production mode, run the `start` task:
|
||||
|
||||
```sh Terminal
|
||||
deno task start
|
||||
# or
|
||||
deno serve -A _fresh/server.js
|
||||
```
|
||||
|
||||
Fresh will automatically pick up the optimized assets in the `_fresh` directory.
|
||||
Reference in New Issue
Block a user