Skip to content

Commit a50c492

Browse files
authored
chore(docs): add deployment page (#1601)
1 parent 873cea7 commit a50c492

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: Deployments
3+
description: "How to deploy Tempest to production."
4+
---
5+
6+
There are many ways to deploy a PHP application. This page will list the most basic way of setting up a Tempest production server.
7+
8+
## Prerequisites
9+
10+
Your server will need PHP [8.4+](https://www.php.net/downloads.php) and [Composer](https://getcomposer.org/) at the minimum. You should also have either [Bun](https://bun.sh) or [Node](https://nodejs.org) available if you chose to bundle front-end assets. While shared servers will probably work given enough configuration, it is recommended to use a dedicated server for production. The rest of this page will assume you have a server with SSH access available.
11+
12+
## Deployment scripts
13+
14+
Currently, Tempest doesn't have a dedicated deployment script that comes with the framework. There will be a `tempest ship` command in the future, but that's still [work in progress](https://github.com/tempestphp/tempest-framework/issues/352). However, creating a deployment script is very simple, given that you have SSH access.
15+
16+
This website, for example, has a very simple [`deploy` command](https://github.com/tempestphp/tempest-docs/blob/main/src/Console/DeployCommand.php) that does two things:
17+
18+
- Login via SSH and pull in the latest changes from the repository.
19+
- Run the [deploy.sh](https://github.com/tempestphp/tempest-docs/blob/main/deploy.sh) script that's included in the repository.
20+
21+
This `deploy.sh` script could look something like this:
22+
23+
```sh
24+
#!/bin/bash
25+
26+
{:hl-comment:# Sourcing bashrc because we're connecting via SSH':}
27+
{:hl-keyword:.:} /home/user/.bashrc
28+
29+
{:hl-comment:# Dependencies:}
30+
{:hl-keyword:composer:} install --no-dev
31+
{:hl-keyword:bun:} install
32+
33+
{:hl-comment:# Tempest:}
34+
{:hl-keyword:tempest:} cache:clear --force --internal --all
35+
{:hl-keyword:tempest:} discovery:generate
36+
{:hl-keyword:tempest:} migrate:up --force
37+
{:hl-keyword:tempest:} static:clean --force
38+
{:hl-keyword:bun:} run build
39+
{:hl-keyword:tempest:} static:generate --allow-dead-links --verbose=true
40+
```
41+
42+
As you can see, there are a number of steps involved to deploying a Tempest project:
43+
44+
- Installing composer and frontend dependencies
45+
- Clearing all caches and regenerating the discovery cache
46+
- Running migrations
47+
- Clean up static assets if you're using static pages
48+
- Compiling frontend assets
49+
- Finally, regenerating static pages if you're using them
50+
51+
## Initial installation
52+
53+
While a deploy script handles day-by-day deployments, initial server setup requires a number of one-time steps.
54+
55+
First, make sure there's a `.env` file created in your project's root directory. Don't forget to run `tempest key:generate` once to create a signing key.
56+
57+
```dotenv
58+
# Generated by `tempest key:generate`
59+
SIGNING_KEY=…
60+
61+
# Set to production
62+
ENVIRONMENT=production
63+
64+
# Set the base URI to your production domain
65+
BASE_URI=https://tempestphp.com
66+
67+
# Enable all caches
68+
INTERNAL_CACHES=true
69+
70+
# Use full discovery cache in production
71+
DISCOVERY_CACHE=true
72+
73+
# Set the PHP executable path if you're using Tempest's front-end scaffolding
74+
# See: https://tempestphp.com/2.x/getting-started/installation#scaffolding-front-end-assets
75+
PHP_EXECUTABLE_PATH=/usr/bin/php8.4
76+
77+
# Any project-specific environment variables you may need.
78+
# …
79+
```
80+
81+
Next, make sure that the `.tempest` directory is writable by the web server, this is the cache directory used by Tempest. Finally, [enable the scheduler](/2.x/features/scheduling#using-the-scheduler).
82+
83+
## In closing
84+
85+
If you find that there is anything missing from this page, please let us know by opening an issue [on GitHub](https://github.com/tempestphp/tempest-framework).

0 commit comments

Comments
 (0)