From 78bc7bca528fec6a44690d05dae0729fc63ee671 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 14 Nov 2022 10:31:59 +0000 Subject: [PATCH 1/5] added check in 00 to make script_cofngi if not exists --- 00-create-pod.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/00-create-pod.sh b/00-create-pod.sh index 5bab3a3..4552508 100755 --- a/00-create-pod.sh +++ b/00-create-pod.sh @@ -4,8 +4,10 @@ mkdir ./uploads ./static ./config -p chown -R 911:911 ./uploads +if [ ! -f ./script_config.sh ]; then + cp ./script_config_sample.sh ./script_config.sh +fi + podman pod create \ --name rebased-pod \ - -p 5000:5000 \ - -p 4000:4000 - + -p 5000:5000 From 8ec39cb99d2689e903ca5aab9f334cf620fa0bac Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 14 Nov 2022 10:38:52 +0000 Subject: [PATCH 2/5] added todos.md --- todos.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 todos.md diff --git a/todos.md b/todos.md new file mode 100644 index 0000000..8a1a32e --- /dev/null +++ b/todos.md @@ -0,0 +1,3 @@ +# ToDos: + + - [ ] Currently using Rebased main Dockerfile for creation which uses Ubuntu, I'd like to switch it to use Alpine (but I am quite happy for the actual build to use Ubuntu I guess) From 7198394146205b3f153d827f65c4c4d13f81a8fe Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 14 Nov 2022 14:25:40 +0000 Subject: [PATCH 3/5] created alpine fork --- 00-create-pod.sh | 5 ++-- 10-build-rebased.sh | 10 +------ 30-run-rebased.sh | 17 +++-------- 35-gen-config.sh | 7 +++-- 50-create-user.sh | 14 +++++++++ Containerfile | 69 +++++++++++++++++++++++++++++++++++++++++++++ script_config.sh | 4 +-- 7 files changed, 97 insertions(+), 29 deletions(-) create mode 100755 50-create-user.sh create mode 100644 Containerfile diff --git a/00-create-pod.sh b/00-create-pod.sh index 4552508..3ba00a2 100755 --- a/00-create-pod.sh +++ b/00-create-pod.sh @@ -2,12 +2,11 @@ mkdir ./uploads ./static ./config -p -chown -R 911:911 ./uploads - if [ ! -f ./script_config.sh ]; then cp ./script_config_sample.sh ./script_config.sh fi podman pod create \ --name rebased-pod \ - -p 5000:5000 + -p 5000:5000 \ + -p 4000:4000 diff --git a/10-build-rebased.sh b/10-build-rebased.sh index 3720b94..7471e47 100755 --- a/10-build-rebased.sh +++ b/10-build-rebased.sh @@ -2,13 +2,5 @@ source ./script_config.sh -if [ ! -d ./build ]; then - git clone https://gitlab.com/soapbox-pub/rebased.git ./build - cd ./build -else - cd ./build - git pull -fi - -podman build -f Dockerfile --build-arg="BUILD_DATE=$DATE" --build-arg="VCS_REF=$REBASED_VER" -t $REBASED_IMG +podman build -f Containerfile --build-arg="BUILD_DATE=$DATE" --build-arg="VCS_REF=$REBASED_VER" -t $REBASED_IMG diff --git a/30-run-rebased.sh b/30-run-rebased.sh index 490dd3c..55ced45 100755 --- a/30-run-rebased.sh +++ b/30-run-rebased.sh @@ -8,26 +8,17 @@ podman stop rebased-web podman rm rebased-web echo Creating new 'rebased-web' container... -if [ ! -f ./config/prod.secret.exs ]; then - $conf="" -fi podman run -d \ --name rebased-web \ --pod rebased-pod \ + -e DB_USER=$PG_USER \ + -e DB_PASS=$PG_PASS \ + -e DB_NAME=$PG_NAME \ + -e DB_HOST=$PG_HOST \ -v ./uploads:/var/lib/pleroma/uploads:z \ -v ./static:/var/lib/pleroma/static:z \ - -v ./config:/config:rw \ -v ./config:/var/lib/pleroma/config \ -v ./config/prod.secret.exs:/var/lib/pleroma/config.exs \ - -e DOMAIN=social.example.com \ - -e INSTANCE_NAME=rebased \ - -e ADMIN_EMAIL=admin@example.com \ - -e NOTIFY_EMAIL=notify@example.com \ - -e DB_USER=rebased \ - -e DB_PASS=rebased \ - -e DB_NAME=rebased \ - -e DB_HOST=localhost \ - -e POSTGRES_HOST=localhost \ $REBASED_IMG diff --git a/35-gen-config.sh b/35-gen-config.sh index 0d87cf1..3dc7fca 100755 --- a/35-gen-config.sh +++ b/35-gen-config.sh @@ -2,7 +2,10 @@ source ./script_config.sh -podman exec -it --user=0 --privileged rebased-web /opt/pleroma/bin/pleroma_ctl instance gen -echo "Check files in config - if all looks good rename generated_config.exs to prod.secret.exs" +podman exec -it --user=0 rebased-web /opt/pleroma/bin/pleroma_ctl instance gen +podman exec rebased-web cat /src/config/generated_config.exs > ./config/prod.secret.exs +echo . +echo ========================= +echo "Check ./config/prod.secret.exs and if all looks OK, restart rebased-web container" diff --git a/50-create-user.sh b/50-create-user.sh new file mode 100755 index 0000000..76eb90f --- /dev/null +++ b/50-create-user.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +admin="" +echo "Username:" +read -r user +echo "Email:" +read -r email +echo "Make Admin? (y/N)" +read -r makeadmin +if [[ $makeadmin == "y" ]]; then + admin="--admin" +fi +podman exec -it rebased-web /opt/pleroma/bin/pleroma_ctl user new $user $email $admin +echo Done. diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..40130d7 --- /dev/null +++ b/Containerfile @@ -0,0 +1,69 @@ +FROM elixir:1.14.1-alpine as build + +ARG MIX_ENV=prod \ + OAUTH_CONSUMER_STRATEGIES="twitter facebook google microsoft slack github keycloak:ueberauth_keycloak_strategy" + +WORKDIR /src + +RUN echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories +RUN apk update &&\ + apk add git bash gcc g++ musl-dev make cmake file-dev \ + exiftool imagemagick libmagic ncurses postgresql-client ffmpeg +RUN git clone https://gitlab.com/soapbox-pub/rebased.git /src +RUN mix local.hex --force &&\ + mix local.rebar --force + +RUN cd /src &&\ + mix deps.get --only prod &&\ + mkdir release &&\ + mix release --path release + +ARG BUILD_DATE +ARG VCS_REF + +ENV TZ="Etc/UTC" + +LABEL maintainer="hello@soapbox.pub" \ + org.opencontainers.image.title="rebased" \ + org.opencontainers.image.description="Rebased" \ + org.opencontainers.image.authors="hello@soapbox.pub" \ + org.opencontainers.image.vendor="soapbox.pub" \ + org.opencontainers.image.documentation="https://gitlab.com/soapbox-pub/rebased" \ + org.opencontainers.image.licenses="AGPL-3.0" \ + org.opencontainers.image.url="https://soapbox.pub" \ + org.opencontainers.image.revision=$VCS_REF \ + org.opencontainers.image.created=$BUILD_DATE + +ARG HOME=/opt/pleroma +ARG DATA=/var/lib/pleroma + +RUN apk add curl ca-certificates imagemagick libmagic ffmpeg postgresql-client elixir +RUN git clone https://github.com/facebookresearch/fastText.git ./fasttext &&\ + cd fasttext && make && ls +RUN addgroup rebased &&\ + adduser --system --shell /bin/false -G rebased --home ${HOME} rebased &&\ + mkdir -p ${DATA}/uploads &&\ + mkdir -p ${DATA}/static &&\ + chown -R rebased ${DATA} &&\ + mkdir -p /etc/pleroma &&\ + chown -R rebased /etc/pleroma &&\ + mkdir -p /usr/share/fasttext &&\ + curl -L https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.ftz -o /usr/share/fasttext/lid.176.ftz &&\ + chmod 0644 /usr/share/fasttext/lid.176.ftz + +RUN cp /src/fasttext/fasttext /usr/bin/fasttext + +USER rebased + +RUN cp -r /src/release/* ${HOME} + +RUN cp /src/config/docker.exs /etc/pleroma/config.exs &&\ + cp /src/docker-entrypoint.sh ${HOME} + + +RUN chown -R rebased ${HOME} ${DATA} +RUN chmod +x ${HOME}/docker-entrypoint.sh + +EXPOSE 5000 + +ENTRYPOINT ["/opt/pleroma/docker-entrypoint.sh"] diff --git a/script_config.sh b/script_config.sh index 0d3f8b7..f9f1c57 100644 --- a/script_config.sh +++ b/script_config.sh @@ -1,10 +1,10 @@ #!/bin/bash DATE=$(date +"%Y-%m-%d") -PG_USER=pleroma +PG_USER=rebased PG_PASS=rebased PG_HOST=localhost -PG_NAME=pleroma +PG_NAME=rebased REBASED_VER=develop REBASED_IMG="rebased-$REBASED_VER-$DATE" From bad8c43d3dceed91b860b4583295cd071baf2240 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 14 Nov 2022 14:51:45 +0000 Subject: [PATCH 4/5] alpine fork, correct permissions, appears working now --- 00-create-pod.sh | 5 ++--- 30-run-rebased.sh | 1 + Containerfile | 2 ++ script_config.sh | 1 + script_config_sample.sh | 12 ++++++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 script_config_sample.sh diff --git a/00-create-pod.sh b/00-create-pod.sh index 3ba00a2..8f48a5a 100755 --- a/00-create-pod.sh +++ b/00-create-pod.sh @@ -5,8 +5,7 @@ mkdir ./uploads ./static ./config -p if [ ! -f ./script_config.sh ]; then cp ./script_config_sample.sh ./script_config.sh fi - +source ./script_config.sh podman pod create \ --name rebased-pod \ - -p 5000:5000 \ - -p 4000:4000 + -p $PORT:5000 diff --git a/30-run-rebased.sh b/30-run-rebased.sh index 55ced45..9835375 100755 --- a/30-run-rebased.sh +++ b/30-run-rebased.sh @@ -6,6 +6,7 @@ touch ./config/prod.secret.exs echo Stopping old 'rebased-web' container... podman stop rebased-web podman rm rebased-web +chmod -R 777 uploads echo Creating new 'rebased-web' container... podman run -d \ diff --git a/Containerfile b/Containerfile index 40130d7..6b62d24 100644 --- a/Containerfile +++ b/Containerfile @@ -66,4 +66,6 @@ RUN chmod +x ${HOME}/docker-entrypoint.sh EXPOSE 5000 +WORKDIR /var/lib/pleroma + ENTRYPOINT ["/opt/pleroma/docker-entrypoint.sh"] diff --git a/script_config.sh b/script_config.sh index f9f1c57..0b27bc7 100644 --- a/script_config.sh +++ b/script_config.sh @@ -1,6 +1,7 @@ #!/bin/bash DATE=$(date +"%Y-%m-%d") +PORT=5000 PG_USER=rebased PG_PASS=rebased PG_HOST=localhost diff --git a/script_config_sample.sh b/script_config_sample.sh new file mode 100644 index 0000000..0b27bc7 --- /dev/null +++ b/script_config_sample.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +DATE=$(date +"%Y-%m-%d") +PORT=5000 +PG_USER=rebased +PG_PASS=rebased +PG_HOST=localhost +PG_NAME=rebased +REBASED_VER=develop + +REBASED_IMG="rebased-$REBASED_VER-$DATE" +echo $REBASED_IMG From 15902cbd86c8ebf0bc4745b5566c452d2d426fb4 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 14 Nov 2022 14:53:24 +0000 Subject: [PATCH 5/5] updated readme to explain use of alpine --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b955618..66759de 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,10 @@ Its main advantages are its lightness and speed. ## Features -This podman set up is configured using the official Dockerfile at [Rebased GitLab](https://gitlab.com/soapbox-pub/rebased) -and working through each script will allow you to set up your own Rebased server. +This podman set up build and creates a Rebased container image using Alpine Linux. +Working through each script will allow you to set up your own Rebased server. + +For a more "official" set up, please use the `ubuntu` branch of this repo which builds the image directly using Rebased's own Dockerfile. ## Build-time variables