neon-mmd / websurfx

:rocket: An open source alternative to searx which provides a modern-looking :sparkles:, lightning-fast :zap:, privacy respecting :disguised_face:, secure :lock: meta search engine
https://github.com/neon-mmd/websurfx/tree/rolling/docs
GNU Affero General Public License v3.0
734 stars 96 forks source link

🔧 Volumes for docker deployment to make editing config files easier #274

Closed neon-mmd closed 1 year ago

neon-mmd commented 1 year ago

What would you like to share?

Make editing of files like allowlist, blocklist and config.lua easier by transitioning from copying these files into the image to mounting them as a volume. So that they can be accessed easily which helps avoid rebuilding of the image on file changes.

This issue requires that the two files docker-compose.yml and dockerfile needs to be edited with minor changes as show below:

Docker Compose File

---
version: "3.9"
services:
  app:
    image: websurfx:latest
    build: .
    ports:
      - 8080:8080
    depends_on:
      - redis
    links:
      - redis
+    volumes:
+      - ./websurfx/:/etc/xdg/websurfx/
+      - ./public/:/opt/websurfx/public/
  redis:
    image: redis:latest
    ports:
      - 6379:6379

Dockerfile

FROM rust:latest AS chef
# We only pay the installation cost once,
# it will be cached from the second build onwards
RUN cargo install cargo-chef --locked

WORKDIR /app

FROM chef AS planner
COPY . . 
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json

# Build application
COPY . .
RUN cargo install --path .

# We do not need the Rust toolchain to run the binary!
FROM gcr.io/distroless/cc-debian12
COPY --from=builder /app/public/ /opt/websurfx/public/
- COPY --from=builder /app/websurfx/config.lua /etc/xdg/websurfx/config.lua
- COPY --from=builder /app/websurfx/allowlist.txt /etc/xdg/websurfx/allowlist.txt
- COPY --from=builder /app/websurfx/blocklist.txt /etc/xdg/websurfx/blocklist.txt
+ VOLUME ["/etc/xdg/websurfx/"]
COPY --from=builder /usr/local/cargo/bin/* /usr/local/bin/
CMD ["websurfx"]

Note

  1. To get started contributing make sure to read the contributing.md file for the guidlines on how to contribute in this project
  2. To contribute first fork this project by following this video tutorial if you are not familliar with process and add your changes and make a pull request with the changes to this repository and if you are new to GitHub then follow this video tutorial to get started contributing :slightly_smiling_face: .

Do you want to work on this issue?

None

Additional information

No response

github-actions[bot] commented 1 year ago

The issue has been unlocked and is now ready for dev. If you would like to work on this issue, you can comment to have it assigned to you. You can learn more in our contributing guide https://github.com/neon-mmd/websurfx/blob/rolling/CONTRIBUTING.md

evanyang1 commented 1 year ago

Giving this a try!

neon-mmd commented 1 year ago

Giving this a try!

Ok, no problem, before you work on this issue. I will assign this issue to you :slightly_smiling_face: .