-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d158709
commit dce6230
Showing
7 changed files
with
212 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
description: | | ||
Building your Fresh app for production. | ||
--- | ||
|
||
Fresh comes with built-in capabilities to compress assets to improve page load | ||
speed. | ||
|
||
## Building | ||
|
||
You can build your Fresh app by invoking the `deno task build` script. This will | ||
run the `dev.ts` file, which will then call Fresh's `Builder` class and generate | ||
optimized bundles for the browser. Put any additional tasks that should be done | ||
to prepare your app for deployment here. You can check if the build task was | ||
invoke by checking for `Deno.args.includes("build")`. | ||
|
||
Here is an example what the `dev.ts` file looks like for the Fresh documentation | ||
website: | ||
|
||
```ts dev.ts | ||
import { Builder } from "fresh/dev"; | ||
import { app } from "./main.ts"; | ||
import { tailwind } from "@fresh/plugin-tailwind"; | ||
|
||
const builder = new Builder({ target: "safari12" }); | ||
tailwind(builder, app, {}); | ||
|
||
if (Deno.args.includes("build")) { | ||
await builder.build(app); | ||
} else { | ||
await builder.listen(app); | ||
} | ||
``` | ||
|
||
## Preview your app | ||
|
||
You can preview your production app locally by running the `deno task start` or | ||
running `deno run -A main.ts` directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
description: | | ||
Deploy Fresh to Deno Deploy which is an optimized edge platform. | ||
--- | ||
|
||
[Deno Deploy](https://deno.com/deploy) is a hassle-free deployment platform for | ||
serverless TypeScript/JavaScript applications created by us. Fresh works best | ||
with that. | ||
|
||
## Creating a new Deploy project | ||
|
||
Head over to your [Deno Deploy Dashboard](https://dash.deno.com/projects) and | ||
click on the "New Project" button. Select the GitHub repository of your project | ||
and the branch you want to deploy from. The default branch is typically `main` | ||
for production deployments. Follow the rest of the wizard and finish deployment | ||
by clicking the "Deploy Project" button at the bottom. Each time new code lands | ||
in the `main` branch, a new deployment will be made to update your website | ||
automatically. | ||
|
||
> [info]: Deno deploy will automatically integrate with GitHub to create preview | ||
> deployments for every PR. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
description: | | ||
Deploy Fresh via Docker yourself. | ||
--- | ||
|
||
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. | ||
|
||
## Creating a Docker image | ||
|
||
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 | ||
# Pick the latest deno version here | ||
FROM denoland/deno:1.44.4 | ||
|
||
ARG GIT_REVISION | ||
ENV DENO_DEPLOYMENT_ID=${GIT_REVISION} | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
RUN deno cache main.ts | ||
|
||
EXPOSE 8000 | ||
|
||
CMD ["run", "-A", "main.ts"] | ||
``` | ||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
description: | | ||
Fresh is a full stack modern web framework for JavaScript and TypeScript | ||
developers, designed to make it trivial to create high-quality, performant, | ||
and personalized web applications. | ||
--- | ||
|
||
Fresh is an approchable full stack web framework, designed to make it trivial to | ||
create high-quality, performant, and personalized web applications. You can use | ||
it to create your home page, a blog, a large web application like GitHub or | ||
Twitter, or anything else you can think of. | ||
|
||
Fresh is built around the | ||
[island architecture](https://jasonformat.com/islands-architecture/) where every | ||
page is rendered on the server and only the JavaScript for the interactive areas | ||
on your page - so called islands - is shipped to the browser. This allows Fresh | ||
to minimize the amount of JavaScript that is sent to the browser to make your | ||
websites load faster. | ||
|
||
Fresh uses [Preact](https://preactjs.com) under the hood, which is a super tiny | ||
react-like framework. Whenever possible, we use standard | ||
[Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) instead of | ||
re-inventing the wheel. | ||
|
||
## Project goals | ||
|
||
The Fresh project was created and is maintained by the [Deno](https://deno.com/) | ||
company with the goal of beign one of the fastest web frameworks and showing how | ||
Deno can be used to built highly optimized websites. Many experiences gained | ||
here in Fresh directly help making Deno better. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters