From 7c88276a63282c23880536ebb145c5519b901c5b Mon Sep 17 00:00:00 2001 From: Daniel Szabo Date: Sun, 2 Jul 2023 13:04:28 +0300 Subject: [PATCH] Docker setup script Plus added gitignore for docker volume --- .gitignore | 1 + README.md | 20 ++++++-------------- compose.yaml | 45 +++++++++++++++++++++++++++++++++++++++++++++ docker-setup.sh | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 compose.yaml create mode 100755 docker-setup.sh diff --git a/.gitignore b/.gitignore index 68963df..737ff02 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ target/ pasta_data/* *.env +**/**/microbin-data diff --git a/README.md b/README.md index b90e192..64ba7df 100644 --- a/README.md +++ b/README.md @@ -11,29 +11,21 @@ MicroBin is a super tiny, feature rich, configurable, self-contained and self-hosted paste bin web application. It is very easy to set up and use, and will only require a few megabytes of memory and disk storage. It takes only a couple minutes to set it up, why not give it a try now? -Install it from Cargo: +Run our quick docker setup script ([DockerHub](https://hub.docker.com/r/danielszabo99/microbin)): ```bash -cargo install microbin +sudo sh -c 'curl -s https://raw.githubusercontent.com/szabodanika/microbin/master/docker-setup.sh | bash' ``` -Download the configuration file and edit it the way you see fit. -```bash -curl -L -O https://raw.githubusercontent.com/szabodanika/microbin/master/.env -``` +Or install it manually from [Cargo](https://crates.io/crates/microbin): -Register your configuration: -```bash -source .env -``` - -And finally run MicroBin: ```bash +cargo install microbin; +curl -L -O https://raw.githubusercontent.com/;szabodanika/microbin/master/.env; +source .env; microbin ``` -Or get the Docker Image from [Dockerhub: danielszabo99/microbin](https://hub.docker.com/r/danielszabo99/microbin). - On our website [microbin.eu](https://microbin.eu) you will find the following: - [Screenshots](https://microbin.eu/screenshots/) diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..1aa4d17 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,45 @@ +services: + microbin: + image: danielszabo99/microbin:2.0.0-beta1 + restart: always + ports: + - "${MICROBIN_PORT}:8080" + volumes: + - ./microbin-data:/app/pasta_data + environment: + MICROBIN_BASIC_AUTH_USERNAME: ${MICROBIN_BASIC_AUTH_USERNAME} + MICROBIN_BASIC_AUTH_PASSWORD: ${MICROBIN_BASIC_AUTH_PASSWORD} + MICROBIN_ADMIN_USERNAME: ${MICROBIN_ADMIN_USERNAME} + MICROBIN_ADMIN_PASSWORD: ${MICROBIN_ADMIN_PASSWORD} + MICROBIN_EDITABLE: ${MICROBIN_EDITABLE} + MICROBIN_FOOTER_TEXT: ${MICROBIN_FOOTER_TEXT} + MICROBIN_HIDE_FOOTER: ${MICROBIN_HIDE_FOOTER} + MICROBIN_HIDE_HEADER: ${MICROBIN_HIDE_HEADER} + MICROBIN_HIDE_LOGO: ${MICROBIN_HIDE_LOGO} + MICROBIN_NO_LISTING: ${MICROBIN_NO_LISTING} + MICROBIN_HIGHLIGHTSYNTAX: ${MICROBIN_HIGHLIGHTSYNTAX} + MICROBIN_BIND: ${MICROBIN_BIND} + MICROBIN_PRIVATE: ${MICROBIN_PRIVATE} + MICROBIN_PURE_HTML: ${MICROBIN_PURE_HTML} + MICROBIN_JSON_DB: ${MICROBIN_JSON_DB} + MICROBIN_PUBLIC_PATH: ${MICROBIN_PUBLIC_PATH} + MICROBIN_SHORT_PATH: ${MICROBIN_SHORT_PATH} + MICROBIN_READONLY: ${MICROBIN_READONLY} + MICROBIN_SHOW_READ_STATS: ${MICROBIN_SHOW_READ_STATS} + MICROBIN_TITLE: ${MICROBIN_TITLE} + MICROBIN_THREADS: ${MICROBIN_THREADS} + MICROBIN_GC_DAYS: ${MICROBIN_GC_DAYS} + MICROBIN_ENABLE_BURN_AFTER: ${MICROBIN_ENABLE_BURN_AFTER} + MICROBIN_DEFAULT_BURN_AFTER: ${MICROBIN_DEFAULT_BURN_AFTER} + MICROBIN_WIDE: ${MICROBIN_WIDE} + MICROBIN_QR: ${MICROBIN_QR} + MICROBIN_ETERNAL_PASTA: ${MICROBIN_ETERNAL_PASTA} + MICROBIN_ENABLE_READONLY: ${MICROBIN_ENABLE_READONLY} + MICROBIN_DEFAULT_EXPIRY: ${MICROBIN_DEFAULT_EXPIRY} + MICROBIN_NO_FILE_UPLOAD: ${MICROBIN_NO_FILE_UPLOAD} + MICROBIN_CUSTOM_CSS: ${MICROBIN_CUSTOM_CSS} + MICROBIN_HASH_IDS: ${MICROBIN_HASH_IDS} + MICROBIN_ENCRYPTION_CLIENT_SIDE: ${MICROBIN_ENCRYPTION_CLIENT_SIDE} + MICROBIN_ENCRYPTION_SERVER_SIDE: ${MICROBIN_ENCRYPTION_SERVER_SIDE} + MICROBIN_MAX_FILE_SIZE_ENCRYPTED_MB: ${MICROBIN_MAX_FILE_SIZE_ENCRYPTED_MB} + MICROBIN_MAX_FILE_SIZE_UNENCRYPTED_MB: ${MICROBIN_MAX_FILE_SIZE_UNENCRYPTED_MB} \ No newline at end of file diff --git a/docker-setup.sh b/docker-setup.sh new file mode 100755 index 0000000..14592cb --- /dev/null +++ b/docker-setup.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Check if wget is installed; if not, try to use curl +if ! command -v wget &> /dev/null +then + download_command="curl -O" +else + download_command="wget" +fi + +# Get installation directory from user +echo -e "\033[1mEnter installation directory (default is /usr/share/microbin):\033[0m" +read install_dir +install_dir=${install_dir:-/usr/share/microbin} + +# Create directory and download files +mkdir -p $install_dir +cd $install_dir +$download_command https://raw.githubusercontent.com/szabodanika/microbin/master/.env +$download_command https://raw.githubusercontent.com/szabodanika/microbin/master/compose.yaml + +# Get public path URL and port from user +echo -e "\033[1mEnter public path URL (e.g. https://microbin.myserver.net or http://localhost:8080):\033[0m" +read public_path + +echo -e "\033[1mEnter port number (default is 8080):\033[0m" +read port +port=${port:-8080} + +# Update environment variables in .env file +sed -i "s|MICROBIN_PUBLIC_PATH=.*|MICROBIN_PUBLIC_PATH=${public_path}|" .env +sed -i "s|MICROBIN_PORT=.*|MICROBIN_PORT=${port}|" .env + +# Start Microbin using Docker Compose +docker compose --env-file .env up --detach \ No newline at end of file