@kirschbaum-development/sst-laravel 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile.worker +1 -1
- package/README.md +14 -0
- package/docs/api.md +12 -0
- package/laravel-sst.ts +30 -1
- package/package.json +1 -1
- package/src/web-server.ts +26 -0
package/Dockerfile.worker
CHANGED
package/README.md
CHANGED
|
@@ -118,6 +118,20 @@ const app = new LaravelService('MyLaravelApp', {
|
|
|
118
118
|
|
|
119
119
|
This has no effect when no `domain` is set, or when you provide an explicit `web.loadBalancer` (configure `loadBalancer.ports` yourself in that case).
|
|
120
120
|
|
|
121
|
+
#### Access logs
|
|
122
|
+
|
|
123
|
+
The web container runs nginx (`serversideup/php:*-fpm-nginx`), which logs every request — including the load balancer health-check pings — to stdout, where it ends up in CloudWatch. To silence those access logs, set `accessLogs: false`:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
const app = new LaravelService('MyLaravelApp', {
|
|
127
|
+
web: {
|
|
128
|
+
accessLogs: false,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
This points the serversideup `NGINX_ACCESS_LOG` variable at `/dev/null`. Error logs and the Laravel application logs are unaffected. Only the web container runs nginx, so this has no effect on workers or the Reverb service.
|
|
134
|
+
|
|
121
135
|
### Reverb
|
|
122
136
|
|
|
123
137
|
You can deploy a dedicated Laravel Reverb service for WebSocket traffic. Reverb runs as a worker-style container using `php artisan reverb:start`, but SST Laravel also attaches a load balancer so you can give it its own public domain.
|
package/docs/api.md
CHANGED
|
@@ -292,6 +292,18 @@ web: {
|
|
|
292
292
|
}
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
+
#### `web.accessLogs`
|
|
296
|
+
- **Type:** `boolean`
|
|
297
|
+
- **Default:** `true`
|
|
298
|
+
- **Description:** Stream the nginx access logs from the web container to CloudWatch. The web container runs nginx (`serversideup/php:*-fpm-nginx`), which logs every request — including the load balancer health-check pings — to stdout. Set to `false` to silence those access logs (points the serversideup `NGINX_ACCESS_LOG` variable at `/dev/null`). Error logs and the Laravel application logs are unaffected. Only the web container runs nginx, so this has no effect on workers or the Reverb service.
|
|
299
|
+
|
|
300
|
+
**Example:**
|
|
301
|
+
```typescript
|
|
302
|
+
web: {
|
|
303
|
+
accessLogs: false,
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
295
307
|
#### `web.executionRole`
|
|
296
308
|
- **Type:** `ServiceArgs["executionRole"]`
|
|
297
309
|
- **Description:** Execution role for the web service.
|
package/laravel-sst.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { RemoteEnvFile } from './src/remote-env-file';
|
|
|
28
28
|
import { buildReverbEnvironmentVariables } from './src/reverb';
|
|
29
29
|
import { getSecretsFingerprint } from './src/secrets-manager';
|
|
30
30
|
import { buildDefaultPublicPorts, Port } from './src/load-balancer';
|
|
31
|
+
import { buildWebServerEnvironment } from './src/web-server';
|
|
31
32
|
|
|
32
33
|
// Re-export RemoteEnvVault for external use
|
|
33
34
|
export { RemoteEnvVault, RemoteEnvVaultArgs };
|
|
@@ -212,6 +213,29 @@ export interface LaravelWebArgs extends LaravelServiceArgs {
|
|
|
212
213
|
* ```
|
|
213
214
|
*/
|
|
214
215
|
httpsRedirect?: boolean;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Stream the nginx access logs from the web container to CloudWatch.
|
|
219
|
+
*
|
|
220
|
+
* The web container runs nginx (`serversideup/php:*-fpm-nginx`), which logs
|
|
221
|
+
* every request — including the load balancer health-check pings — to
|
|
222
|
+
* stdout. Set this to `false` to silence those access logs (it points the
|
|
223
|
+
* serversideup `NGINX_ACCESS_LOG` variable at `/dev/null`). Error logs and
|
|
224
|
+
* the Laravel application logs are unaffected.
|
|
225
|
+
*
|
|
226
|
+
* Only the web container runs nginx, so this has no effect on workers or
|
|
227
|
+
* the Reverb service.
|
|
228
|
+
*
|
|
229
|
+
* @default `true`
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```js
|
|
233
|
+
* web: {
|
|
234
|
+
* accessLogs: false,
|
|
235
|
+
* }
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
accessLogs?: boolean;
|
|
215
239
|
}
|
|
216
240
|
|
|
217
241
|
export interface LaravelReverbArgs extends LaravelServiceArgs {
|
|
@@ -466,7 +490,12 @@ export class LaravelService extends Component {
|
|
|
466
490
|
});
|
|
467
491
|
|
|
468
492
|
const addWebService = () => {
|
|
469
|
-
const envVariables =
|
|
493
|
+
const envVariables = {
|
|
494
|
+
...getEnvironmentVariables(),
|
|
495
|
+
...buildWebServerEnvironment({
|
|
496
|
+
accessLogs: args.web?.accessLogs,
|
|
497
|
+
}),
|
|
498
|
+
};
|
|
470
499
|
|
|
471
500
|
this.services['web'] = new sst.aws.Service(
|
|
472
501
|
`${name}-Web`,
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface WebServerEnvironmentOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Whether the nginx access logs should keep streaming to CloudWatch.
|
|
4
|
+
*
|
|
5
|
+
* @default true
|
|
6
|
+
*/
|
|
7
|
+
accessLogs?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Builds the web-server-specific container environment overrides derived from
|
|
12
|
+
* the web service options.
|
|
13
|
+
*
|
|
14
|
+
* Setting `accessLogs` to `false` points the serversideup `NGINX_ACCESS_LOG`
|
|
15
|
+
* variable at `/dev/null`, which silences the nginx access logs (including the
|
|
16
|
+
* load balancer health-check pings) while leaving the error logs untouched.
|
|
17
|
+
*/
|
|
18
|
+
export function buildWebServerEnvironment({
|
|
19
|
+
accessLogs,
|
|
20
|
+
}: WebServerEnvironmentOptions): Record<string, string> {
|
|
21
|
+
if (accessLogs === false) {
|
|
22
|
+
return { NGINX_ACCESS_LOG: '/dev/null' };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {};
|
|
26
|
+
}
|