From 7198394146205b3f153d827f65c4c4d13f81a8fe Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 14 Nov 2022 14:25:40 +0000 Subject: [PATCH] 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"