Sign inSign up

faghy/diaspora

By faghy

•Updated almost 2 years ago

Diaspora latest plesk ready

Image
Networking
Developer tools
0

302

faghy/diaspora repository overview

⁠diaspora-docker plesk Optimizer

Diaspora Optimized for Plesk or Linux

This Docker image provides a pre-configured environment to deploy Diaspora, the decentralized social networking platform, optimized for seamless integration with Plesk. It offers an easy-to-use setup script and environment tailored for Plesk-managed hosting environments, allowing for streamlined management of Diaspora instances with PostgreSQL and Redis support, RVM, and asset precompilation. Ideal for developers and system administrators seeking a scalable and robust social networking solution compatible with Plesk.

⁠Requirements

As a basic requirement, Docker must be installed on the Linux system.

⁠With Plesk

We test it with Plesk Obsidian 18.0.64 with Docker extension
important for Plesk: do not install the image from plesk docker GUI of Plesk, but install from domain host folder via command line

⁠Instructions

In your domain's file system create this directory:

    ⁠diaspora_app

These will be the volumes associated with the diaspora container.

Create Dockerfile, docker-compose.yml and diaspora-setup.sh in the root of your domain.

Copy the original files database.yml.example diaspora.toml.example into diaspo_conf, appropriately modified as needed and renamed without .example ( database.yml diaspora.toml )

Optional: create diaspora as ftp-user (in Plesk choose FTP and add FTP account)

Look up user UID and GID with command:

id diaspora
(or your user)

Enter the UID and GID number in the docker-compose.yml and put the same password you chose in the file database.yml

⁠docker-compose.yml

I recommend highlighting the text of docker-compose.yml and copying it without using the copy button to avoid pasting wrong HTML tags
version: "3.4"

volumes:   diaspora_data:   diaspora_app:   diaspora_config:   redis_data:   postgresql_data:
services:   diaspora:   build:   context: .   dockerfile: Dockerfile   args:   DIA_UID: 10003   DIA_GID: 1003   image: faghy/diaspora:latest   ports:   - "3000:3000"   environment:   ENVIRONMENT_REDIS: redis://redis   SERVER_LISTEN: tcp://0.0.0.0:3000   DB: postgresql   restart: always   depends_on:   - postgresql   - redis   volumes:   - ./data:/home/diaspora/public   - ./diaspo_conf:/home/diaspora/config   - ./diaspora_app:/home/diaspora/app:rw   redis:   image: redis:7   restart: always   command: redis-server --save 60 1 --loglevel warning   volumes:   - redis_data:/data   postgresql:   image: postgres:15   restart: always   ports:   - "55432:5432"   environment:   POSTGRES_DB: diaspora_production   POSTGRES_USER: diaspora   POSTGRES_PASSWORD: diaspora   volumes:   - postgresql_data:/var/lib/postgresql

⁠diaspora-setup.sh

#!/bin/bash

#Clone the Diaspora repository into the existing non-empty folder #Define the target directory and a temporary directory TARGET_DIR="/home/diaspora" TEMP_DIR="/diaspora/diaspora_temp_clone"

⁠Check if Diaspora is already installed by looking for an important file (e.g., config/database.yml)

if [ -f "$TARGET_DIR/Gemfile" ]; then echo "Diaspora is already installed. Starting the server..." cd $TARGET_DIR ./script/server else

#Clone the repository into the temporary directory git clone -b main https://github.com/diaspora/diaspora.git⁠ $TEMP_DIR

#Check if the clone was successful if [ $? -eq 0 ]; then # Copy the contents from the temporary directory to the target directory # This command copies files without overwriting existing content rsync -av --ignore-existing $TEMP_DIR/ $TARGET_DIR/

# Remove the temporary directory
rm -rf $TEMP_DIR

echo "Cloning completed and files added without overwriting existing files."

else

echo "Error during repository cloning." fi #Unset GEM_HOME to avoid conflicts with RVM unset GEM_HOME #----- Download and configure RVM and Ruby ----- curl -L https://s.diaspora.software/1t⁠ | bash #Check and configure RVM if it exists if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then #Add RVM configuration to the .bashrc file echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc #Source .bashrc to apply changes source ~/.bashrc #Configure autolibs for RVM rvm autolibs read-fail #Install the desired Ruby version rvm install 3.3 else echo "RVM was not found in $HOME/.rvm/scripts/rvm. Please check the RVM installation."

fi

#----- Install the necessary gems ----- cd /home/diaspora script/configure_bundler bin/bundle install --full-index

#----- Create and migrate the database ----- RAILS_ENV=production bin/rake db:create db:migrate

#----- Precompile assets ----- RAILS_ENV=production bin/rake assets:precompile

#----- Start the server ----- ./script/server fi

⁠Dockerfile

# Base Image
FROM docker.io/amd64/ruby:3.3-slim-bullseye

⁠Install required packages

RUN apt-get update &&
apt-get install -y -qq --no-install-recommends apt-utils &&
DEBIAN_FRONTEND=noninteractive
apt-get install -y -qq --no-install-recommends
postgresql-client
rsync
build-essential
git
curl
gsfonts
imagemagick
libmagickwand-dev
nodejs
libssl-dev
libcurl4-openssl-dev
libxml2-dev
libxslt1-dev
libidn11-dev
yarnpkg
libpq-dev
patch
gawk
cmake
bison
libgdbm-dev
libsqlite3-dev
libtool
sqlite3
libncurses5-dev
libreadline-dev
gosu &&
rm -rf /var/lib/apt/lists/*

⁠Arguments for UID and GID

ARG DIA_UID ARG DIA_GID

RUN echo "DIA_UID=${DIA_UID}, DIA_GID=${DIA_GID}"

⁠Create user and group for diaspora

RUN addgroup --gid $DIA_GID diaspora &&
adduser
--no-create-home
--disabled-password
--gecos ""
--uid $DIA_UID
--gid $DIA_GID
diaspora &&
mkdir -p /home/diaspora /diaspora &&
chown -R diaspora:diaspora /home/diaspora /diaspora

⁠Copy entrypoint scripts

COPY diaspora-setup.sh /diaspora-setup.sh

⁠Set execution permissions for the entrypoint scripts

RUN chmod +x /diaspora-setup.sh &&
chown -R diaspora:diaspora /diaspora-setup.sh

⁠Set the working directory

WORKDIR /home/diaspora

⁠Change the user for subsequent commands

USER diaspora

⁠Clone the Diaspora repository

#RUN git clone -b main https://github.com/diaspora/diaspora.git⁠ /home/diaspora

⁠Copy example configuration file

#COPY diaspora.toml /home/diaspora/config/diaspora.toml #COPY database.yml /home/diaspora/config/database.yml

USER root RUN chown -R diaspora:diaspora /home/diaspora

USER diaspora

VOLUME /home/diaspora/public VOLUME /home/diaspora/app VOLUME /home/diaspora/config

⁠Keeps the container running to allow manual configuration

CMD ["/./diaspora-setup.sh"] #CMD ["tail", "-f", "/dev/null"]

⁠nginx directive on plesk

(Change code with your URL)
location / {
	proxy_pass http://diaspo.it:3000;
	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;
	proxy_set_header X-Forwarded-Proto https;
}

⁠Gestisce i file statici dalla cartella data

location /assets/ { root /var/www/vhosts/diaspo.it/data; add_header X-Content-Type-Options "nosniff"; try_files $uri $uri/ =404; }

location /uploads/ { root /var/www/vhosts/diaspo.it/data; try_files $uri $uri/ =404; }

location /public/ { root /var/www/vhosts/diaspo.it/data; try_files $uri $uri/ =404; }

⁠Final

important for Plesk: do not install the image from plesk docker GUI of Plesk, but install from domain host folder via command line
With SSH in the path of Dockerfile run:
docker-compose up -d --build

Tag summary

Content type

Image

Digest

sha256:64e2c1ceb…

Size

287.8 MB

Last updated

almost 2 years ago

docker pull faghy/diaspora