pict-rs 0.3.2 on OpenBSD 7.2: Install
- Network services
- Published
- 3 min read
- @nabbisen
Table of contents
Summary Summary
This post is a part of Lemmy 0.16.7 on OpenBSD 7.2 about Lemmy (opens in a new tab).
Premise Premise
The server is OpenBSD (opens in a new tab) and Rust (rustlang) (opens in a new tab) is installed. Also, there is _lemmy user whose home directory is /var/lemmy.
Environment Environment
- OS: OpenBSD 7.2 (opens in a new tab)
- Object Storage: MinIO (opens in a new tab) - AWS (opens in a new tab) S3 (opens in a new tab)-compatible (Optional)
- Apps
- pict-rs (opens in a new tab): 0.3.2
- based on Rust 1.63 (opens in a new tab) + Actix Web 4 (opens in a new tab) + Actix 0.13
- pict-rs (opens in a new tab): 0.3.2
Tutorial Tutorial
pict-rs server pict-rs server
Lemmy uses pict-rs to store image. It is a simple image hosting service which is open source and written in Rust, too.
Prepare for the dependencies Prepare for the dependencies
You have to install protobuf (opens in a new tab), “Protocol Buffers - Google’s data interchange format”
Therefore switch back to your own user if you are acting as _lemmy to install it:
$ exit
$ doas pkg_add protobuf
The output was:
quirks-6.42 signed on 2023-01-13T18:22:41Z
protobuf-3.21.6: ok
Build pict-rs server Build pict-rs server
Switch to _lemmy:
$ doas su - _lemmy
Get the source of the stable version (v0.4 didn’t work in my case):
$ git clone https://git.asonix.dog/asonix/pict-rs.git --branch v0.3.2 --single-branch
The output was:
Cloning into 'pict-rs'...
remote: Enumerating objects: 2707, done.
remote: Counting objects: 100% (2707/2707), done.
remote: Compressing objects: 100% (1932/1932), done.
remote: Total 2707 (delta 1806), reused 1077 (delta 687), pack-reused 0
Receiving objects: 100% (2707/2707), 2.21 MiB | 114.00 KiB/s, done.
Resolving deltas: 100% (1806/1806), done.
Note: switching to '4dff8de9851041911b8243a35bf9f6df4d612268'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
(...)
Go inside:
$ cd pict-rs
Then run to build:
$ cargo build --release
The output was:
Updating git repository `https://github.com/asonix/rust-s3`
(...)
Compiling rustls v0.20.6
(...)
Compiling actix-web v4.1.0
(...)
Compiling pict-rs v0.3.2 (/var/lemmy/pict-rs)
Finished release [optimized] target(s) in 20m 35s
Now you can run pict-rs server with -p option to specify data directory:
$ cargo run --release -- -p data
The output was:
Finished release [optimized] target(s) in 0.24s
Running `target/release/pict-rs -p data`
2023-01-14T12:51:58.377271Z INFO restructure{store=FileStore { path_gen: "generator", root_dir: "data" }}: pict_rs::store::file_store::restructure: new
2023-01-14T12:51:58.377478Z INFO restructure{store=FileStore { path_gen: "generator", root_dir: "data" }}: pict_rs::store::file_store::restructure: close time.busy=11.3µs time.idle=197µs
2023-01-14T12:51:58.377627Z INFO actix_server::builder: Starting 1 workers
2023-01-14T12:51:58.377736Z INFO actix_server::server: Actix runtime found; starting in Actix runtime
Additionally, you can specify address to listen:
$ cargo run --release -- -a 127.0.0.1:8080 -p data
Additionally, you can modify its configuration:
$ nvim pict-rs.toml
For example:
- api_key = 'API_KEY'
- image_format = 'jpeg'
- opentelemetry_url = 'http://localhost:4317/'
+ opentelemetry_url = 'http://127.0.0.1:4317/'
Integrate pict-rs with MinIO (Optional) Integrate pict-rs with MinIO (Optional)
pict-rs stores image files in their local directory by default.
Well, there is a way to introduce MinIO bucket usage by editting pict-rc.toml as below:
- type = "file_store"
+ type = "s3_store"
+
+ region = "https://(minio-fqdn)"
+ bucket_name = "(...)"
+ access_key = "(...)"
+ secret_key = "(...)"
and, of course, creating MinIO bucket and service account, with bucket policy like:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"admin:*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::{bucket-name}",
"arn:aws:s3:::{bucket-name}/*"
]
}
]
}Conclusion Conclusion
Well done :) Go on to the next step.
More on: Run web, mail and federated services
-
Tor 🧅 provides highly private access 👯 to the Web ✨
-
OpenBSD develops and maintains their own web server called “httpd” under ISC license.
-
Pleroma is one of the fediverse implementations for microblogging like Twitter and Mastodon.
OBSD Solutions
OBSD Solutions: OpenBSD consulting and support by Scqr, Reflerd Inc. (opens in a new tab)
Comments and feedback are welcome.