Skip to content

Commit b9d29a8

Browse files
committed
docs: updated documentation on deployment
1 parent 609c988 commit b9d29a8

File tree

3 files changed

+63
-36
lines changed

3 files changed

+63
-36
lines changed

.env.prod.example

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ LOG_CHANNEL=stack
1111
LOG_STACK=errorlog,nightwatch
1212
LOG_DEPRECATIONS_CHANNEL=errorlog
1313

14-
NIGHTWATCH_TOKEN=
15-
NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1
16-
1714
DB_CONNECTION=sqlite
1815
DB_DATABASE=/var/www/html/storage/database.sqlite
1916

17+
NIGHTWATCH_ENABLED=false
18+
NIGHTWATCH_TOKEN=
19+
NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1
20+
2021
FILESYSTEM_DISK=local
2122
AWS_ACCESS_KEY_ID=
2223
AWS_SECRET_ACCESS_KEY=

README.md

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Repo management for Nethsecurity installations.
44

55
Something went wrong with some packages? Go straight to
6-
the [faulty packages section](#list-of-behaviours-in-case-of-distribution-of-faulty-packages). :rocket:
6+
the [faulty packages section](#list-of-behaviors-when-faulty-packages-get-accidentally-distributed). :rocket:
77

88
## Application Structure
99

@@ -13,8 +13,10 @@ The application is structured as follows:
1313
- `php`: Main application that handles the logic and dispatches the jobs.
1414
- `scheduler`: Scheduler that handles cron jobs for the php application.
1515
- `worker`: Worker that handles the jobs dispatched by the php application.
16+
- `redis`: Redis instance for cache.
17+
- `nightwatch-agent`: Agent for nightwatch stats.
1618

17-
The storage can be configured to use different disks, however a local shared storage is mandatory due to the `sqlite`
19+
The storage can be configured to use different disks, however, a local shared storage is mandatory due to the `sqlite`
1820
database that `php`, `scheduler` and `worker` containers share.
1921

2022
## Application Behavior
@@ -24,19 +26,20 @@ Base file request:
2426
```mermaid
2527
sequenceDiagram
2628
client ->> nginx/php: Request file
27-
database ->> nginx/php: Get repository
29+
nginx/php ->>database: Get repository
30+
database ->> nginx/php:
2831
opt repository not found
2932
nginx/php ->> client: 404 Not Found
3033
end
31-
database ->> nginx/php: Check cache
34+
nginx/php ->> redis: Check cache
35+
redis ->> nginx/php:
3236
alt cache miss
3337
nginx/php ->> my: Ask for authorization
3438
my ->> nginx/php:
35-
alt authorized
36-
nginx/php ->> database: Save cache
37-
else not authorized
38-
nginx/php ->> client: 403 Forbidden
39-
end
39+
nginx/php ->> redis: Save authorization status
40+
end
41+
opt not authorized
42+
nginx/php ->> client: 403 Forbidden
4043
end
4144
nginx/php ->> filesystem: Check if file exists
4245
alt file does not exists
@@ -79,7 +82,7 @@ been done with these tools.
7982

8083
Copy the `.env.example` file to `.env` and edit the entries as needed.
8184

82-
Most of the environment variables are self-explanatory and there's no need to change their defaults unless explicitly
85+
Most of the environment variables are self-explanatory, and there's no need to change their defaults unless explicitly
8386
told so.
8487
However, there are a few that you might want to change:
8588

@@ -159,7 +162,7 @@ php artisan test
159162
### Build the production image
160163

161164
GitHub Actions takes care of the deployment of the images to the registry, however if you want to build the production
162-
image yourself follow the instructions below.
165+
image yourself, follow the instructions below.
163166

164167
```bash
165168
docker buildx bake -f docker-bake.hcl production
@@ -169,19 +172,13 @@ You will find the images tagged as `ghcr.io/nethserver/parceler-*:latest`.
169172

170173
## Production
171174

172-
The production environment is composed by the following services:
173-
174-
- `nginx`: nginx frontend that handles http requests.
175-
- `php`: php-fpm that runs a Parceler instance.
176-
- `scheduler`: scheduler dispatcher for worker.
177-
- `worker`: worker that handles all jobs sent to queues.
178-
179-
It's advised to use a reverse proxy to handle the SSL termination and load balancing.
175+
The same services used for development are used for production, it's advised to use a reverse proxy to handle the SSL
176+
termination and load balancing.
180177

181178
### Parceler Configuration
182179

183180
The parceler service is being configured through an environment file, you can find the example in `.env.prod.example`.
184-
While some of the values are self-explanatory, there are a few that you need to manually set:
181+
While most values are self-explanatory, there are a few that you need to manually set:
185182

186183
- `APP_KEY`: The application key, you can generate one using the development environment
187184
using `php artisan key:generate --show`.
@@ -190,11 +187,13 @@ While some of the values are self-explanatory, there are a few that you need to
190187
- `FILESYSTEM_DISK`: Disk to use during production, works same as development, more info in the development setup.
191188
- `REPOSITORY_MILESTONE_TOKEN`: Token used to trigger from remote the milestone creation, you can set this to a random
192189
value, it's used to avoid unwanted requests.
190+
- `NIGHTWATCH_TOKEN`: In case you want to enable nightwatch stats, you need to set this to the token provided by
191+
nightwatch.
193192

194193
### Container Configuration
195194

196195
Now that parceler is out the way, there's additional configuration needed for the containers to run properly, here's
197-
container specific configuration:
196+
container-specific configuration:
198197

199198
`nginx` needs variables to wait for the `php` container to be ready before starting, you can set the following:
200199

@@ -229,16 +228,15 @@ found [in the documentation](https://rclone.org/docs/#config-file).
229228
### Maintenance mode
230229

231230
To avoid any issues with the files served by the service, if you are operating with the files, you can put the service
232-
in maintenance mode, this will prevent any new requests from being processed and will return a 503 status code. Be aware
233-
that even crons and queues will stop working, to force queues you
234-
can [resort to this command](https://laravel.com/docs/11.x/queues#maintenance-mode-queues).
231+
in maintenance mode. This will prevent any new requests from being processed and will return a 503 status code. Be aware
232+
that even cron jobs and queues will stop working; to force queues, you can [resort to this command](https://laravel.com/docs/11.x/queues#maintenance-mode-queues).
235233
To enable maintenance mode, you can use the following command:
236234

237235
```bash
238236
php artisan down
239237
```
240238

241-
To disable maintenance mode, you can use the following command:
239+
To disable the maintenance mode, you can use the following command:
242240

243241
```bash
244242
php artisan up
@@ -256,14 +254,14 @@ To add a repository, you need to enter to the `php` container and run the follow
256254
php artisan repository:create
257255
```
258256

259-
The command will guide you through the process of adding a repository, here's the fields that will be asked:
257+
The command will guide you through the process of adding a repository; here are the fields that will be asked:
260258

261-
- `name`: name of the repository, will be used to identify the repository under the
259+
- `name`: name of the repository will be used to identify the repository under the
262260
path `repositories/{community|enterprise}/{repository_name}`,
263261
- `command`: the command the worker will run to sync the repository it can be anything available in the container.
264262
Save the content of the repository under the path `source/{repository_name}` in the disk you're using.
265263
(e.g. if you're using the local disk, save the content of the repository
266-
under `storage/app/source/{repository_name}`). `rclone` binary is available in the container, to add configuration
264+
under `storage/app/source/{repository_name}`). `rclone` binary is available in the container, to add a configuration
267265
file follow the [Additional Configuration](#additional-configuration) section.
268266
- `source_folder`: if repository files are stored in a subfolder, you can specify it here, otherwise leave it empty.
269267
- `delay`: how many days the upstream files are delayed.
@@ -378,7 +376,7 @@ Additional authentication must be provided, the token is set in the `.env` file
378376
curl -X POST -H Accept:application/json -H Authorization:Bearer <token> <url>/repository/<repository_name>/milestone
379377
```
380378

381-
## List of behaviours in case of distribution of faulty packages
379+
## List of behaviors when faulty packages get accidentally distributed
382380

383381
The following list is a guide on how to handle the distribution of faulty packages, to find which of the snapshots has a
384382
faulty package go to the [list repository files](#listing-files-in-a-repository) section.

deploy/docker-compose.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,49 @@ services:
1717
FPM_HOST: php
1818
FPM_PORT: 9000
1919
worker:
20-
extends:
21-
service: php
20+
image: ghcr.io/nethesis/parceler-php:latest
21+
volumes:
22+
- storage:/var/www/html/storage
23+
- /etc/localtime:/etc/localtime:ro
24+
env_file:
25+
- .env
2226
stop_signal: SIGKILL
2327
command: worker
2428
environment:
2529
PHP_HOST: php
2630
PHP_PORT: 9000
2731
scheduler:
28-
extends:
29-
service: php
32+
image: ghcr.io/nethesis/parceler-php:latest
33+
volumes:
34+
- storage:/var/www/html/storage
35+
- /etc/localtime:/etc/localtime:ro
36+
env_file:
37+
- .env
3038
stop_signal: SIGKILL
3139
command: scheduler
3240
environment:
3341
PHP_HOST: php
3442
PHP_PORT: 9000
43+
nightwatch-agent:
44+
image: ghcr.io/nethesis/parceler-php:latest
45+
volumes:
46+
- storage:/var/www/html/storage
47+
- /etc/localtime:/etc/localtime:ro
48+
env_file:
49+
- .env
50+
stop_signal: SIGKILL
51+
command: nightwatch
52+
environment:
53+
PHP_HOST: php
54+
PHP_PORT: 9000
55+
healthcheck:
56+
test: php artisan nightwatch:status
57+
interval: 30s
58+
timeout: 5s
59+
retries: 3
60+
start_period: 5s
61+
redis:
62+
image: redis:8.2.1-alpine
3563

3664
volumes:
3765
storage: { }

0 commit comments

Comments
 (0)