From e7106cec60763ec7178e11024e0a5123ae270a90 Mon Sep 17 00:00:00 2001 From: Dumitru Botezatu Date: Sat, 13 Apr 2024 16:37:16 +0300 Subject: [PATCH 1/2] removed docker, optimized .env --- .env.example | 45 +++------- README.md | 171 ++------------------------------------ config/filesystems.php | 9 -- config/logging.php | 9 +- config/queue.php | 2 +- docker-compose.yml | 52 ------------ docker/Dockerfile | 77 ----------------- docker/crontab | 1 - docker/mixpost | 31 ------- docker/nginx/default.conf | 26 ------ docker/php.ini | 4 - docker/start.sh | 9 -- docker/supervisord.conf | 26 ------ 13 files changed, 20 insertions(+), 442 deletions(-) delete mode 100644 docker-compose.yml delete mode 100644 docker/Dockerfile delete mode 100644 docker/crontab delete mode 100755 docker/mixpost delete mode 100644 docker/nginx/default.conf delete mode 100644 docker/php.ini delete mode 100644 docker/start.sh delete mode 100644 docker/supervisord.conf diff --git a/.env.example b/.env.example index 2a160e0..1f71192 100644 --- a/.env.example +++ b/.env.example @@ -1,47 +1,24 @@ -# You app name. It is usually equal to the name of your project. -APP_NAME='Mixpost Lite' +# This value is the name of your application. +APP_NAME='Mixpost' -# Your application environment. If you are ready for production, set 'production' -APP_ENV=local - -# Is used to encrypt and decrypt sensitive data. Generate it with: 'php artisan key:generate' +# Key used to encrypt and decrypt sensitive data. Generate this using the following tool: +# https://mixpost.app/tools/encryption-key-generator APP_KEY= -# Debug mode. If the environment is in production, we recommend setting it to 'false' -APP_DEBUG=true - -# URL of your application. Important: it is not allowed to be a slash at the end of the url. -APP_URL=http://localhost - -# You can define the application port here (Only if you install with docker-compose) -APP_PORT=80 - -# The user ID in your system. You can find it with 'id -u' (Only if you install with docker-compose) -UID=1000 +# Debug mode setting. Set to 'false' for production environments. +APP_DEBUG=false -# The group ID in your system. You can find it with 'id -g' (Only if you install with docker-compose) -GID=1000 +# Full application URL. Important: it is not allowed to be a slash at the end of the url. +APP_URL=https://example.com -# Mysql connection setup -DB_CONNECTION=mysql # Change this only if you know what you are doing +# MySQL connection setup DB_HOST=127.0.0.1 DB_PORT=3306 -FORWARD_DB_PORT=3306 # (Only if you install with docker-compose. You can leave it 3306) -DB_DATABASE=laravel +DB_DATABASE=mixpost_db DB_USERNAME=root DB_PASSWORD= # Redis connection setup REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null -REDIS_PORT=6379 -FORWARD_REDIS_PORT=6379 # (Only if you install with docker-compose. You can leave it 6379) - -#Change this only if you know what you are doing -QUEUE_CONNECTION=redis - -#Change this only if you know what you are doing -MIXPOST_DISK=mixpost - -#Change this only if you know what you are doing -MIXPOST_LOG_CHANNEL=mixpost \ No newline at end of file +REDIS_PORT=6379 \ No newline at end of file diff --git a/README.md b/README.md index 1b49731..03e6ff6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ -[](https://supportukrainenow.org) - -* * * [Logo Mixpost](https://mixpost.app) @@ -9,172 +6,18 @@ Mixpost it's the coolest Self-hosted social media management software. -Easily create, schedule, publish, and manage social media content in one place, with no limits or monthly subscription fees. More details on [mixpost.app](https://mixpost.app/). - -Join our community: - -- [Discord](https://discord.gg/5YdseZnK2Z) -- [Facebook Private Group](https://www.facebook.com/groups/inovector) - -## About Mixpost Lite - -Mixpost Lite is the free version of Mixpost. - -This repository is the standalone application with the [Laravel Package of Mixpost Lite](https://github.com/inovector/mixpost) pre-installed and configured. +This package is the Lite version of Mixpost Pro. -Mixpost has 3 packages: +Easily create, schedule, publish, and manage social media content in one place, with no limits or monthly subscription fees. -- Lite (Personal use only) -- Pro Team (Business use) -- Pro SaaS (Launch your own SaaS and start generating revenue) +More details on [mixpost.app](https://mixpost.app/) -Do you want a more advanced version? **Mixpost Pro** is under development and will be released soon. Sign up to be notified when it's released [mixpost.app](https://mixpost.app/). - -## Requirements +Join our community: -* PHP 8.1 or higher -* Database (eg: MySQL, PostgresSQL, SQLite) -* Redis 6.2 or higher -* Web Server (eg: Apache, Nginx, IIS) -* URL Rewrite (eg: mod_rewrite for Apache) +- [Discord](https://mixpost.app/discord) +- [Facebook Private Group](https://www.facebook.com/groups/getmixpost) ## Installation -Install Mixpost Lite with composer: - -```bash -composer create-project inovector/MixpostApp -``` - -### Configure the app url - -You will need to modify the value of the APP_URL in the `.env` file to your project URL. - -For example: `APP_URL=https://your-domain.com` - -### Configure the database - -You will need to modify the values of the DB_* entries in the `.env` file to make sure they are aligned with your database. - -Then, run migration to create all tables. - -```bash -php artisan migrate -``` - -### Create the first user - -After that you can create an initial user by executing: - -```bash -php artisan mixpost-auth:create -``` - -You can log in to Mixpost at `/mixpost` using the user account you created. - - -## Server configuration (Manual) - -*Please do not skip the server configuration step as it is important for Mixpost to work well.* - -[Server configuration Guide](https://docs.inovector.com/books/server-configuration-mixpost) - -*** - -## Docker Installation - -Logo Docker - -
- -**We provide you two methods of installing the Mixpost using Docker:** - - - Pull Docker image. - - Build Docker image on your machine and have full control. - -## Pull Docker image -This is the most suitable method, see image on [docker hub](https://hub.docker.com/r/inovector/mixpost), there are also the installation instructions. You can use [Portainer](https://www.portainer.io/) to install Mixpost Lite or simply by creating a `docker-composer.yml` file. - -## Build Docker Image on your machine -You can build a docker image that will have all server configurations and start the containers. - -This method is mostly for developers. If you decide to install Mixpost using this method, it means that you know what you are doing. - -Download the latest version of Mixpost Lite from [here](https://github.com/inovector/MixpostApp/releases), copy .env.example to `.env`, and fill in all the necessary values: -```env -APP_PORT=80 -UID=1000 // Your local user id, you can find it this way: id -u -GID=1000 // Your local group id, you can find it this way: id -g - -DB_HOST=127.0.0.1 -DB_DATABASE=laravel -DB_USERNAME=root -DB_PASSWORD= - -REDIS_HOST=127.0.0.1 -REDIS_PASSWORD=null -``` - -**Important**: the `DB_HOST` must be `mysql` and `REDIS_HOST` must be `redis`. - -*Attention! If you have already installed the project with composer `composer create-project inovector/MixpostApp`, you can avoid step **3** below.* - -### 1. Build Mixpost Lite image & Run the containers: -```bash -docker-compose up -d -``` - -IMORTANT NOTE! - -If you are logged in as the **root** user on your machine, you must make sure that the user in the container is the owner of the files: - -```bash -docker-compose exec -it app bash - -# If the command above cannot log you into the container: -# `docker ps`, and identify the mixpost container name -# docker exec -it {mixpost_container_name} bash - -chown -R mixpost:mixpost /var/www/html - -exit -``` - -### 2. Make the binary `mixpost` file executable: -```bash -chmod +x ./docker/mixpost -``` -This binary will help you to avoid the long command `docker-compose exec -it -u mixpost app`. If you don't want to use this binary, you are free to use docker-compose command. - -### 3. Execute these commands one by one to setup Mixpost Lite: - -```bash -./docker/mixpost composer install -./docker/mixpost php artisan key:generate -./docker/mixpost php artisan mixpost:setup-gitignore -./docker/mixpost php artisan queue:batches-table -./docker/mixpost php artisan storage:link -./docker/mixpost php artisan queue:restart -``` - -If you are reading for production, you cache the config and routes: - -```bash -./docker/mixpost php artisan config:cache -./docker/mixpost php artisan route:cache -``` - -Do not forget to restart the queue after caching: `./docker/mixpost php artisan queue:restart` - -### 4. And then you can migrate all tables: - -```bash -./docker/mixpost php artisan migrate -``` - -### 5. Create the first user: -```bash -./docker/mixpost php artisan mixpost-auth:create -``` +Read our [documentation](https://docs.mixpost.app/lite) on how to get started. -You can log in to Mixpost at `/mixpost` using the user account you created. \ No newline at end of file diff --git a/config/filesystems.php b/config/filesystems.php index 7476aec..ebcfadc 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -55,15 +55,6 @@ 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 'throw' => false, ], - - 'mixpost' => [ - 'driver' => 'local', - 'root' => storage_path('app/public/mixpost'), - 'url' => env('APP_URL').'/storage/mixpost', - 'visibility' => 'public', - 'throw' => false, - ], - ], /* diff --git a/config/logging.php b/config/logging.php index e4e8a61..7f8b6cf 100644 --- a/config/logging.php +++ b/config/logging.php @@ -117,14 +117,7 @@ 'emergency' => [ 'path' => storage_path('logs/laravel.log'), - ], - - 'mixpost' => [ - 'driver' => 'daily', - 'path' => storage_path('logs/mixpost.log'), - 'level' => env('LOG_LEVEL', 'debug'), - 'days' => 14, - ], + ] ], ]; diff --git a/config/queue.php b/config/queue.php index d4334da..b9db34b 100644 --- a/config/queue.php +++ b/config/queue.php @@ -13,7 +13,7 @@ | */ - 'default' => env('QUEUE_CONNECTION', 'sync'), + 'default' => env('QUEUE_CONNECTION', 'redis'), /* |-------------------------------------------------------------------------- diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 00c5b79..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,52 +0,0 @@ -version: '3' -services: - app: - build: - context: ./docker - dockerfile: Dockerfile - args: - - UID=${UID:-1000} - - GID=${GID:-1000} - image: mixpost - ports: - - '${APP_PORT:-80}:80' - volumes: - - '.:/var/www/html' - depends_on: - - mysql - - redis - mysql: - image: 'mysql/mysql-server:8.0' - ports: - - '${FORWARD_DB_PORT:-3306}:3306' - environment: - MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' - MYSQL_DATABASE: '${DB_DATABASE}' - MYSQL_USER: '${DB_USERNAME}' - MYSQL_PASSWORD: '${DB_PASSWORD}' - volumes: - - 'mixpost-mysql:/var/lib/mysql' - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] - retries: 3 - timeout: 5s - redis: - image: 'redis:latest' - command: redis-server --appendonly yes --replica-read-only no --requirepass "${REDIS_PASSWORD}" - ports: - - '${FORWARD_REDIS_PORT:-6379}:6379' - volumes: - - 'mixpost-redis:/data' - healthcheck: - test: ["CMD", "redis-cli", "ping"] - retries: 3 - timeout: 5s -volumes: - mixpost-mysql: - driver: local - mixpost-redis: - driver: local - mixpost-storage: - driver: local - mixpost-logs: - driver: local \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 65c8f10..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,77 +0,0 @@ -FROM ubuntu:22.04 - -LABEL maintainer="Dima Botezatu [dima@inovector.com]" - -WORKDIR /var/www/html - -ARG UID -ARG GID - -ENV UID=${UID} -ENV GID=${GID} -ENV DEBIAN_FRONTEND noninteractive -ENV TZ=UTC - -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -# Install softwares (nginx, supervisord, ffmpeg, php-fpm...etc.) -RUN apt update --fix-missing -RUN apt install -y curl nginx supervisor zip unzip git vim mysql-client htop cron -RUN apt install -y ffmpeg -RUN apt install -y software-properties-common -RUN add-apt-repository ppa:ondrej/php -RUN apt install -y php8.2 php8.2-fpm php8.2-cli php8.2-mysql php8.2-gd php8.2-curl php8.2-bcmath php8.2-mbstring php8.2-mysqli php8.2-redis php8.2-xml php8.2-zip php8.2-intl - -#Clean -RUN apt-get -y autoremove -RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -RUN apt clean - -# Enable PHP-fpm on nginx virtualhost configuration -COPY nginx/default.conf /etc/nginx/sites-available/default -RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf - -COPY php.ini /etc/php/8.2/fpm/conf.d/99-app.ini -RUN mkdir -p /var/run/php - -# Copy supervisor configuration -COPY supervisord.conf /etc/supervisor/supervisord.conf - -# Add cron job -ADD crontab /etc/cron.d/mixpost_crontab -RUN chmod 0644 /etc/cron.d/mixpost_crontab -RUN crontab /etc/cron.d/mixpost_crontab -RUN touch /var/log/cron.log - -# Copy start.sh script and define default command for the container -COPY start.sh /usr/local/bin/start.sh -RUN chmod +x /usr/local/bin/start.sh - -# Install composer -RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" -RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer -RUN php -r "unlink('composer-setup.php');" - -# MacOS staff group's gid is 20, it is already exists in ubuntu. Let's just remove it. -RUN delgroup dialout - -# Add user for mixpost application -# Tell php8.2-fpm to use mixpost user instead of www-data user - -RUN if [ "$GID" -ne 0 ] && [ "$UID" -ne 0 ]; then \ - groupadd -g ${GID} --system mixpost && \ - useradd -g mixpost --system -N -ms /bin/bash -u ${UID} mixpost && \ - sed -i "s/user = www-data/user = mixpost/g" /etc/php/8.2/fpm/pool.d/www.conf && \ - sed -i "s/group = www-data/group = mixpost/g" /etc/php/8.2/fpm/pool.d/www.conf; \ -else \ - groupadd -g 1000 --system mixpost && \ - useradd -g mixpost --system -N -ms /bin/bash -u 1000 mixpost && \ - sed -i "s/user = www-data/user = mixpost/g" /etc/php/8.2/fpm/pool.d/www.conf && \ - sed -i "s/group = www-data/group = mixpost/g" /etc/php/8.2/fpm/pool.d/www.conf && \ - mkdir -p /home/mixpost/.composer && \ - chown -R mixpost:mixpost /home/mixpost;\ -fi - -EXPOSE 80 - -ENTRYPOINT ["start.sh"] \ No newline at end of file diff --git a/docker/crontab b/docker/crontab deleted file mode 100644 index 39dd8da..0000000 --- a/docker/crontab +++ /dev/null @@ -1 +0,0 @@ -* * * * * cd /var/www/html && php artisan schedule:run >> /dev/null 2>&1 diff --git a/docker/mixpost b/docker/mixpost deleted file mode 100755 index b3c702f..0000000 --- a/docker/mixpost +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -# Check if the operating system supports it -UNAMEOUT="$(uname -s)" - -case "${UNAMEOUT}" in - Linux*) MACHINE=linux;; - Darwin*) MACHINE=mac;; - *) MACHINE="UNKNOWN" -esac - -if [ "$MACHINE" == "UNKNOWN" ]; then - echo "Unsupported operating system [$(uname -s)]. Mixpost supports macOS, Linux, and Windows (WSL2)." >&2 - - exit 1 -fi - -# Define Docker Compose command prefix -docker compose &> /dev/null -if [ $? == 0 ]; then - DOCKER_COMPOSE=(docker compose) -else - DOCKER_COMPOSE=(docker-compose) -fi - -ARGS+=(exec -u mixpost) -[ ! -t 0 ] && ARGS+=(-T) -ARGS+=(app "$@") - -# Run Docker Compose with the defined arguments -"${DOCKER_COMPOSE[@]}" "${ARGS[@]}" \ No newline at end of file diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf deleted file mode 100644 index 36a1186..0000000 --- a/docker/nginx/default.conf +++ /dev/null @@ -1,26 +0,0 @@ -server { - listen 80; - root /var/www/html/public; - index index.php index.html; - client_max_body_size 200M; - - location / { - try_files $uri /index.php?$args; - } - - location ~ \.php$ { - try_files $uri =404; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; - - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_read_timeout 1000; - proxy_set_header X-Real-IP $remote_addr; - proxy_buffer_size 128k; - proxy_buffers 4 256k; - proxy_busy_buffers_size 256k; - } -} \ No newline at end of file diff --git a/docker/php.ini b/docker/php.ini deleted file mode 100644 index d6fbffd..0000000 --- a/docker/php.ini +++ /dev/null @@ -1,4 +0,0 @@ -[PHP] -post_max_size = 200M -upload_max_filesize = 200M -variables_order = EGPCS \ No newline at end of file diff --git a/docker/start.sh b/docker/start.sh deleted file mode 100644 index 89e1722..0000000 --- a/docker/start.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -service cron start - -/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf & - -echo "Mixpost has started!" - -tail -f /dev/null \ No newline at end of file diff --git a/docker/supervisord.conf b/docker/supervisord.conf deleted file mode 100644 index fbc442d..0000000 --- a/docker/supervisord.conf +++ /dev/null @@ -1,26 +0,0 @@ -[supervisord] -nodaemon=true -user=root -logfile=/var/log/supervisor/supervisord.log -pidfile=/var/run/supervisord.pid - -[program:php-fpm] -command=/usr/sbin/php-fpm8.2 -F -numprocs=1 -autostart=true -autorestart=true - -[program:nginx] -command=/usr/sbin/nginx -numprocs=1 -autostart=true - -[program:mixpost_horizon] -process_name=%(program_name)s_%(process_num)02d -command=php /var/www/html/artisan horizon -autostart=true -autorestart=true -user=mixpost -redirect_stderr=true -stdout_logfile=/var/www/html/storage/logs/horizon.log -stopwaitsecs=3600 \ No newline at end of file From e77cabf202272e6ac146aad1f75f8d30a69ffde4 Mon Sep 17 00:00:00 2001 From: Dumitru Botezatu Date: Fri, 3 May 2024 13:03:34 +0300 Subject: [PATCH 2/2] added aws credentials --- .env.example | 11 ++++++++++- composer.json | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 1f71192..d069548 100644 --- a/.env.example +++ b/.env.example @@ -21,4 +21,13 @@ DB_PASSWORD= # Redis connection setup REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null -REDIS_PORT=6379 \ No newline at end of file +REDIS_PORT=6379 + +# The disk on which to store added files. Disks: "public", "s3". For "s3" you should fill in the AWS_* credentials below. +MIXPOST_DISK=public + +# AWS Credentials +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION= +AWS_BUCKET= \ No newline at end of file diff --git a/composer.json b/composer.json index bd74a6d..3037436 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,9 @@ "inovector/mixpost-auth": "^1.0", "laravel/framework": "^10.0", "laravel/horizon": "^5.14", - "laravel/tinker": "^2.8" + "laravel/tinker": "^2.8", + "league/flysystem-aws-s3-v3": "^3.0", + "league/flysystem-sftp-v3": "^3.0" }, "require-dev": { "fakerphp/faker": "^1.9.1",