From d1ad6ccbf898b34b0df8245fe1ac3db8f0f0ab1f Mon Sep 17 00:00:00 2001 From: Mageas Date: Sat, 4 Dec 2021 18:29:44 +0100 Subject: [PATCH] Initial commit --- Dockerfile | 29 +++++++++++++++++++++++++++++ README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 11 +++++++++++ 3 files changed, 84 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bf1f86b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM rust:1.56-alpine as builder + +ARG GIT="https://gitlab.com/Mageas/matrix_piped_feed" +ARG GIT_BRANCH="master" + +WORKDIR /usr/src/app + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache musl-dev clang-dev openssl-dev git make cmake g++ sqlite-dev sqlite-static + +RUN git clone "$GIT" --branch "$GIT_BRANCH" . + +RUN RUSTFLAGS="-Ctarget-feature=-crt-static" cargo install --path . + + +FROM alpine:3.15.0 + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache libstdc++ sqlite-libs su-exec + +COPY --from=builder /usr/local/cargo/bin/matrix_piped_feed /app/matrix_piped_feed +RUN chmod u+x /app/matrix_piped_feed + +COPY entrypoint.sh /entrypoint.sh +RUN chmod u+x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..eccdc69 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# **matrix_piped_feed_docker** + +This is the docker for my [matrix_piped_feed](https://gitlab.com/Mageas/matrix_piped_feed) project. + +### **Configuration of matrix_piped_feed** + +Copy [config_example.json](https://gitlab.com/Mageas/matrix_piped_feed/-/blob/55866cbe34b7a3dc8a4a05dd8c5fd2624222a65f/config_example.json) form the **matrix_piped_feed** project as *config.json* in your directory. + +Update *config.json* with your informations (for more informations about the *config.json* [here](https://gitlab.com/Mageas/matrix_piped_feed)). + +### **Configuration of docker-compose** + +Create a *docker-compose.yml* file in your directory. + +Content of docker-compose.yml: +```yml +version: '3.5' +services: + matrix_piped_feed: + image: registry.gitlab.com/mageas/matrix_piped_feed_docker + volumes: + - ./config.json:/app/config.json + - database:/app/db + environment: + - UID=1000 + - GID=1000 + - MATRIX_PIPED_FEED__DATABASE=/app/db/database.db3 + +volumes: + database: +``` + +Explanations of docker-compose: +- `./config.json:/app/config.json` sync your config with the container +- `database:/app/sled_db` save your database with the host +- `UID=1000` change the container user id +- `GID=1000` change the container group id +- `MATRIX_PIPED_FEED__DATABASE=/app/db/database.db3` change de database directory to map it with the host + +Check [matrix_piped_feed](https://gitlab.com/Mageas/matrix_piped_feed_docker) to change the path of the `config.json` and `database.db3`. + +### **Run the container** + +`docker-compose up -d` diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..b1289c2 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +app="/app" + +cd ${app} + +echo ${MATRIX_PIPED_FEED__DATABASE} + +chown ${UID:-0}:${GID:-0} -R ${app} + +su-exec ${UID:-0}:${GID:-0} ./matrix_piped_feed