pict-rs 0.3.2 on OpenBSD 7.2: Install

Summary

This post is a part of Lemmy 0.16.7 on OpenBSD 7.2 about Lemmy.

Premise

The server is OpenBSD and Rust (rustlang) is installed. Also, there is _lemmy user whose home directory is /var/lemmy.

Environment

OS: O…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by nabbisen

Summary

This post is a part of Lemmy 0.16.7 on OpenBSD 7.2 about Lemmy.

Premise

The server is OpenBSD and Rust (rustlang) is installed. Also, there is _lemmy user whose home directory is /var/lemmy.

Environment

  • OS: OpenBSD 7.2
  • Object Storage: MinIO - AWS S3-compatible (Optional)
  • Apps
    • pict-rs: 0.3.2
    • based on Rust 1.63 + Actix 0.13 + Actix Web 4

Tutorial

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

You have to install protobuf, "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

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)

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

Well done :) Go on to the next step.

Return


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by nabbisen


Print Share Comment Cite Upload Translate Updates
APA

nabbisen | Sciencx (2023-01-15T13:12:13+00:00) pict-rs 0.3.2 on OpenBSD 7.2: Install. Retrieved from https://www.scien.cx/2023/01/15/pict-rs-0-3-2-on-openbsd-7-2-install/

MLA
" » pict-rs 0.3.2 on OpenBSD 7.2: Install." nabbisen | Sciencx - Sunday January 15, 2023, https://www.scien.cx/2023/01/15/pict-rs-0-3-2-on-openbsd-7-2-install/
HARVARD
nabbisen | Sciencx Sunday January 15, 2023 » pict-rs 0.3.2 on OpenBSD 7.2: Install., viewed ,<https://www.scien.cx/2023/01/15/pict-rs-0-3-2-on-openbsd-7-2-install/>
VANCOUVER
nabbisen | Sciencx - » pict-rs 0.3.2 on OpenBSD 7.2: Install. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/01/15/pict-rs-0-3-2-on-openbsd-7-2-install/
CHICAGO
" » pict-rs 0.3.2 on OpenBSD 7.2: Install." nabbisen | Sciencx - Accessed . https://www.scien.cx/2023/01/15/pict-rs-0-3-2-on-openbsd-7-2-install/
IEEE
" » pict-rs 0.3.2 on OpenBSD 7.2: Install." nabbisen | Sciencx [Online]. Available: https://www.scien.cx/2023/01/15/pict-rs-0-3-2-on-openbsd-7-2-install/. [Accessed: ]
rf:citation
» pict-rs 0.3.2 on OpenBSD 7.2: Install | nabbisen | Sciencx | https://www.scien.cx/2023/01/15/pict-rs-0-3-2-on-openbsd-7-2-install/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.