diff --git a/00-create-pod.sh b/00-create-pod.sh index 8a4cd3c..8f48a5a 100755 --- a/00-create-pod.sh +++ b/00-create-pod.sh @@ -1,10 +1,11 @@ #!/bin/bash mkdir ./uploads ./static ./config -p -chmod -R 777 uploads +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/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 e465173..9835375 100755 --- a/30-run-rebased.sh +++ b/30-run-rebased.sh @@ -6,28 +6,20 @@ 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... -if [ ! -f ./config/prod.secret.exs ]; then - $conf="" -fi podman run -d \ --name rebased-web \ --pod rebased-pod \ - -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=$PG_USER \ -e DB_PASS=$PG_PASS \ -e DB_NAME=$PG_NAME \ -e DB_HOST=$PG_HOST \ - -e POSTGRES_HOST=$PG_HOST \ + -v ./uploads:/var/lib/pleroma/uploads:z \ + -v ./static:/var/lib/pleroma/static:z \ + -v ./config:/var/lib/pleroma/config \ + -v ./config/prod.secret.exs:/var/lib/pleroma/config.exs \ $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..6b62d24 --- /dev/null +++ b/Containerfile @@ -0,0 +1,71 @@ +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 + +WORKDIR /var/lib/pleroma + +ENTRYPOINT ["/opt/pleroma/docker-entrypoint.sh"] diff --git a/README.md b/README.md index 6a1875b..f4c5fae 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 diff --git a/script_config_sample.sh b/script_config_sample.sh index 0d3f8b7..0b27bc7 100644 --- a/script_config_sample.sh +++ b/script_config_sample.sh @@ -1,10 +1,11 @@ #!/bin/bash DATE=$(date +"%Y-%m-%d") -PG_USER=pleroma +PORT=5000 +PG_USER=rebased PG_PASS=rebased PG_HOST=localhost -PG_NAME=pleroma +PG_NAME=rebased REBASED_VER=develop REBASED_IMG="rebased-$REBASED_VER-$DATE" 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)