Improve README and install some extra files via CMake

This commit is contained in:
Matteo Settenvini 2024-06-22 16:49:50 +02:00
parent 804ab6ef36
commit e3aca4fe72
6 changed files with 88 additions and 10 deletions

View File

@ -56,6 +56,6 @@ repos:
- id: trufflehog
name: TruffleHog
description: Detect secrets in your data.
entry: bash -c 'podman run -v "$(pwd):/workdir" --rm docker.io/trufflesecurity/trufflehog:latest git file:///workdir'
entry: bash -c 'podman run -v "$(pwd):/workdir" --rm docker.io/trufflesecurity/trufflehog:latest git file:///workdir' --only-verified
language: system
stages: ["commit", "push"]

View File

@ -2,4 +2,5 @@
// SPDX-License-Identifier: CC0-1.0
{
"liveServer.settings.port": 8001,
"cmake.configureOnOpen": true,
}

View File

@ -3,13 +3,15 @@
cmake_minimum_required(VERSION 3.25)
project(serves3 VERSION 1.0.0 LANGUAGES NONE)
project(serves3 VERSION 1.1.0 LANGUAGES C)
include(GNUInstallDirs)
include(FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.4.1
GIT_TAG v0.5.0
)
FetchContent_MakeAvailable(Corrosion)
@ -20,3 +22,7 @@ corrosion_import_crate(
message(STATUS "Imported crates: ${imported_crates}")
install(IMPORTED_RUNTIME_ARTIFACTS serves3)
install(FILES serves3.toml.example
DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES serves3@.service
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system)

View File

@ -1,5 +1,8 @@
[//]: # SPDX-FileCopyrightText: © Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
[//]: # SPDX-License-Identifier: EUPL-1.2
<!--
SPDX-FileCopyrightText: © Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
SPDX-License-Identifier: EUPL-1.2
-->
# serves3
@ -11,7 +14,37 @@ Also helpful to do a different TLS termination.
## Configuration
Copy `serves3.toml.example` to `serves3.toml` and adjust your settings.
Copy `serves3.toml.example` to `serves3.toml` from this project's sources and adjust your settings. If the project was built and installed via CMake, a copy of the example settings file is in `/usr/share/doc/serves3`.
For instance:
```toml
# apply this configuration to Rocket's "default" profile
[default.s3_bucket]
# the bucket name
name = ""
# the API endpoint address
endpoint = "https://eu-central-1.linodeobjects.com"
# the bucket region
region = "eu-central-1"
# the access key ID
access_key_id = ""
# the access key secret
secret_access_key = ""
# whether to use path_style S3 URLs, see
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access
path_style = false
# Here you can add any other rocket options, see
# https://rocket.rs/guide/v0.5/configuration/
[default]
[debug]
[release]
```
You can also use the same file to customize the server options. See the [Rocket documentation](https://rocket.rs/v0.5-rc/guide/configuration/#rockettoml) for a list of understood values.
@ -59,10 +92,10 @@ Then, e.g. for running on port 8000, you would put the corresponding configurati
If you want more granular control on installation options, use CMake:
```bash
cmake -B build .
cmake -DCMAKE_INSTALL_PREFIX=/usr -B build .
cmake --build build
cmake --install build
cd run-folder # folder with Settings.toml
sudo cmake --install build
cd run-folder # folder with serves3.toml
serves3
```
@ -70,7 +103,7 @@ Else you can simply rely on `cargo`:
```bash
cargo install --root /usr/local --path . # for instance
cd run-folder # folder with Settings.toml
cd run-folder # folder with serves3.toml
serves3
```
@ -79,6 +112,7 @@ serves3
## 1.1.0 Reworked configuration file logic
* **Breaking change**: configuration file renamed to `serves3.toml`. Please note that the format changed slightly; have a look at the provided `serves3.toml.example` file for reference.
* Fixes #2: URLs to directories not ending with a slash are not redirected properly
## 1.0.0

View File

@ -1,10 +1,28 @@
# SPDX-FileCopyrightText: Public domain.
# SPDX-License-Identifier: CC0-1.0
# apply this configuration to Rocket's "default" profile
[default.s3_bucket]
# the bucket name
name = ""
# the API endpoint address
endpoint = "https://eu-central-1.linodeobjects.com"
# the bucket region
region = "eu-central-1"
# the access key ID
access_key_id = ""
# the access key secret
secret_access_key = ""
# whether to use path_style S3 URLs, see
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access
path_style = false
# Here you can add any other rocket options, see
# https://rocket.rs/guide/v0.5/configuration/
[default]
[debug]
[release]

19
serves3@.service Normal file
View File

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: © Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
# SPDX-License-Identifier: CC0-1.0
[Unit]
Description=ServeS3, a S3 proxy
StartLimitInterval=100
StartLimitBurst=10
[Service]
Type=simple
ExecStart=/usr/local/bin/serves3
WorkingDirectory=/etc/serves3/%i/
Environment=ROCKET_PORT=%i
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target