Files
sweet/docs/latest/concepts/deployment.md
T
Christian Svensson a2de5154ec fix(docs): improve and increase consistency for code blocks (#3163)
Follow-up from #3162.

This PR does various tweaks, mostly related to code blocks.

- Adds missing titles to code blocks, and updates titles to be more
consistent
- Adds filenames to most ` ```tsx` blocks with e.g. `main.ts`, `dev.ts`
or a suitable example (e.g. `routes/greeting.tsx`) based on the code
- Adds filenames to ` ```diff` blocks if there's a relevant file, to
make the icon e.g. TS over Diff icon
  - Code blocks with Fresh code (e.g. interfaces) uses ` ```tsx fresh 🍋`
- Changes most ` ```sh` blocks with example terminal commands to ` ```sh
Terminal`
- Updates ` ```txt Project Structure` or ` ```diff Project Structure`
blocks to be more consistent
- Changes `sh` or `txt` to `txt-files` which improves highlighting and
makes icon consistent
- Renames `<project dir>` to `<project root>` to match builder `root`
option terminology
- Adds `<project root>` root folder to most/all overview folder
overviews
  - Makes the structure blocks more consistently displayed
- Tried to make some "bare" examples more complete

## Comparison

Here's a small curated set of before/after changes.

### Deployment

- `deno` highlighted in terminal commands
- `.gitignore` syntax highlighting works without using `sh` as language

<img width="1641" height="1009" alt="image"
src="https://github.com/user-attachments/assets/170cf833-1f6a-4b0d-8d2d-a081bc28a967"
/>

### File routing

Updated icon, comments same as before, but root and hierarchy have new
colors (`operator`/`function`).

<img width="1647" height="588" alt="image"
src="https://github.com/user-attachments/assets/f28db51b-4bee-45e4-be1c-e137a6d3ae3d"
/>
2025-08-01 09:07:42 +02:00

87 lines
2.7 KiB
Markdown

---
description: |
Fresh can be deployed to a variety of platforms easily.
---
While Fresh is designed to be deployed to [Deno Deploy][deno-deploy], it can be
deployed to any system or platform that can run a Deno based web server.
Here are instructions for specific providers / systems:
- [Deno Deploy](#-deno-deploy)
- [Docker](#-docker)
## Deno Deploy
The recommended way to deploy Fresh is by using Deno Deploy. Deno Deploy
provides a GitHub integration that can deploy your Fresh projects to its
globally distributed edge network in seconds, automatically.
View [the getting started guide][deploy-to-production] for instructions on how
to deploy Fresh to Deno Deploy.
## 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:1.38.3
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][aws-container-registry]
- [Google Cloud][gcp-container-registry]
## Self Contained Executable
With Deno 2.1, you can create a self-contained executable of your Fresh project
that includes all assets and dependencies. This executable can run on any
platform without requiring Deno to be installed.
```sh Terminal
$ deno task build
$ deno compile --include static --include _fresh --include deno.json -A main.ts
```
[aws-container-registry]: https://docs.aws.amazon.com/AmazonECS/latest/userguide/create-container-image.html#create-container-image-push-ecr
[gcp-container-registry]: https://cloud.google.com/container-registry/docs/pushing-and-pulling
[deno-deploy]: https://deno.com/deploy
[deploy-to-production]: /docs/getting-started/deploy-to-production