Skip to content

Commit 874c266

Browse files
Merge branch 'redlib-org:main' into main
2 parents 1e4e5fa + 9afe886 commit 874c266

23 files changed

Lines changed: 984 additions & 376 deletions

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Rust",
3-
"image": "mcr.microsoft.com/devcontainers/rust:0-1-bullseye",
3+
"image": "mcr.microsoft.com/devcontainers/rust:1.0.9-bookworm",
44
"features": {
55
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
66
},

Cargo.lock

Lines changed: 67 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ rss = "2.0.7"
4747
arc-swap = "1.7.1"
4848
serde_json_path = "0.7.1"
4949
async-recursion = "1.1.1"
50-
common-words-all = { version = "0.0.2", default-features = false, features = ["english", "one"] }
50+
pulldown-cmark = { version = "0.12.0", features = ["simd", "html"], default-features = false }
5151
hyper-rustls = { version = "0.24.2", features = [ "http2" ] }
5252
tegen = "0.1.4"
5353
serde_urlencoded = "0.7.1"
54+
chrono = { version = "0.4.39", default-features = false, features = [ "std" ] }
55+
htmlescape = "0.3.1"
56+
bincode = "1.3.3"
57+
base2048 = "2.0.2"
58+
revision = "0.10.0"
5459

5560

5661
[dev-dependencies]
@@ -61,11 +66,3 @@ sealed_test = "1.0.0"
6166
codegen-units = 1
6267
lto = true
6368
strip = "symbols"
64-
65-
[[bin]]
66-
name = "redlib"
67-
path = "src/main.rs"
68-
69-
[[bin]]
70-
name = "scraper"
71-
path = "src/scraper/main.rs"

Dockerfile.alpine

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# supported versions here: https://hub.docker.com/_/rust
2+
ARG ALPINE_VERSION=3.20
3+
4+
########################
5+
## builder image
6+
########################
7+
FROM rust:alpine${ALPINE_VERSION} AS builder
8+
9+
RUN apk add --no-cache musl-dev
10+
11+
WORKDIR /redlib
12+
13+
# download (most) dependencies in their own layer
14+
COPY Cargo.lock Cargo.toml ./
15+
RUN mkdir src && echo "fn main() { panic!(\"why am i running?\") }" > src/main.rs
16+
RUN cargo build --release --locked --bin redlib
17+
RUN rm ./src/main.rs && rmdir ./src
18+
19+
# copy the source and build the redlib binary
20+
COPY . ./
21+
RUN cargo build --release --locked --bin redlib
22+
RUN echo "finished building redlib!"
23+
24+
########################
25+
## release image
26+
########################
27+
FROM alpine:${ALPINE_VERSION} AS release
28+
29+
# Import redlib binary from builder
30+
COPY --from=builder /redlib/target/release/redlib /usr/local/bin/redlib
31+
32+
# Add non-root user for running redlib
33+
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
34+
USER redlib
35+
36+
# Document that we intend to expose port 8080 to whoever runs the container
37+
EXPOSE 8080
38+
39+
# Run a healthcheck every minute to make sure redlib is functional
40+
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1
41+
42+
# Add container metadata
43+
LABEL org.opencontainers.image.authors="sigaloid"
44+
45+
CMD ["redlib"]

Dockerfile.ubuntu

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# supported versions here: https://hub.docker.com/_/rust
2+
ARG RUST_BUILDER_VERSION=slim-bookworm
3+
ARG UBUNTU_RELEASE_VERSION=noble
4+
5+
########################
6+
## builder image
7+
########################
8+
FROM rust:${RUST_BUILDER_VERSION} AS builder
9+
10+
WORKDIR /redlib
11+
12+
# download (most) dependencies in their own layer
13+
COPY Cargo.lock Cargo.toml ./
14+
RUN mkdir src && echo "fn main() { panic!(\"why am i running?\") }" > src/main.rs
15+
RUN cargo build --release --locked --bin redlib
16+
RUN rm ./src/main.rs && rmdir ./src
17+
18+
# copy the source and build the redlib binary
19+
COPY . ./
20+
RUN cargo build --release --locked --bin redlib
21+
RUN echo "finished building redlib!"
22+
23+
########################
24+
## release image
25+
########################
26+
FROM ubuntu:${UBUNTU_RELEASE_VERSION} AS release
27+
28+
# Install ca-certificates
29+
RUN apt-get update && apt-get install -y ca-certificates
30+
31+
# Import redlib binary from builder
32+
COPY --from=builder /redlib/target/release/redlib /usr/local/bin/redlib
33+
34+
# Add non-root user for running redlib
35+
RUN useradd \
36+
--no-create-home \
37+
--password "!" \
38+
--comment "user for running redlib" \
39+
redlib
40+
USER redlib
41+
42+
# Document that we intend to expose port 8080 to whoever runs the container
43+
EXPOSE 8080
44+
45+
# Run a healthcheck every minute to make sure redlib is functional
46+
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1
47+
48+
# Add container metadata
49+
LABEL org.opencontainers.image.authors="sigaloid"
50+
51+
CMD ["redlib"]

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,17 @@ REDLIB_DEFAULT_USE_HLS = "on"
404404
>
405405
> If using Docker Compose, no changes are needed as the `.env` file is already referenced in `compose.yaml` via the `env_file: .env` line.
406406
407+
## Command Line Flags
408+
409+
Redlib supports the following command line flags:
410+
411+
- `-4`, `--ipv4-only`: Listen on IPv4 only.
412+
- `-6`, `--ipv6-only`: Listen on IPv6 only.
413+
- `-r`, `--redirect-https`: Redirect all HTTP requests to HTTPS (no longer functional).
414+
- `-a`, `--address <ADDRESS>`: Sets address to listen on. Default is `[::]`.
415+
- `-p`, `--port <PORT>`: Port to listen on. Default is `8080`.
416+
- `-H`, `--hsts <EXPIRE_TIME>`: HSTS header to tell browsers that this site should only be accessed over HTTPS. Default is `604800`.
417+
407418
## Instance settings
408419
409420
Assign a default value for each instance-specific setting by passing environment variables to Redlib in the format `REDLIB_{X}`. Replace `{X}` with the setting name (see list below) in capital letters.
@@ -429,7 +440,7 @@ Assign a default value for each user-modifiable setting by passing environment v
429440
| `WIDE` | `["on", "off"]` | `off` |
430441
| `POST_SORT` | `["hot", "new", "top", "rising", "controversial"]` | `hot` |
431442
| `COMMENT_SORT` | `["confidence", "top", "new", "controversial", "old"]` | `confidence` |
432-
| `BLUR_SPOILER` | `["on", "off"]` | `off` |
443+
| `BLUR_SPOILER` | `["on", "off"]` | `off` |
433444
| `SHOW_NSFW` | `["on", "off"]` | `off` |
434445
| `BLUR_NSFW` | `["on", "off"]` | `off` |
435446
| `USE_HLS` | `["on", "off"]` | `off` |
@@ -441,3 +452,4 @@ Assign a default value for each user-modifiable setting by passing environment v
441452
| `HIDE_SCORE` | `["on", "off"]` | `off` |
442453
| `HIDE_SIDEBAR_AND_SUMMARY` | `["on", "off"]` | `off` |
443454
| `FIXED_NAVBAR` | `["on", "off"]` | `on` |
455+
| `REMOVE_DEFAULT_FEEDS` | `["on", "off"]` | `off` |

0 commit comments

Comments
 (0)