Compare commits

...

10 Commits

Author SHA1 Message Date
bd43765749 replace dockupdater with watchtower 2024-03-15 16:34:24 +01:00
405e35ec08 db to lts 2024-02-14 20:28:36 +01:00
4236af8e13 make photo dir writable 2023-06-25 20:51:35 +02:00
c156e99804 add some advices 2023-06-24 00:24:59 +02:00
794210db0c make more usable by BFU 2023-06-23 15:04:53 +02:00
7b41b69877 repair domain check, ssh only disable password 2023-06-23 12:03:54 +02:00
708cc982ea enable firewall 2023-06-23 11:51:13 +02:00
688f467011 add README 2023-06-23 11:44:22 +02:00
19c71705bd ssh hardening and docker group 2023-06-23 11:37:35 +02:00
fe4d6e9060 correct home 2023-06-23 11:21:25 +02:00
3 changed files with 68 additions and 14 deletions

19
README.md Normal file
View File

@@ -0,0 +1,19 @@
# Photoview Oracle
## Instalace
1) Nainstalujte git `sudo apt update && sudo apt install git -y`.
2) Stáhněte tento repozitář `git clone https://git.h21.fun/h21/fotky-docker.git`.
3) Vlezte do něj `cd fotky-docker`.
4) Spusťe setup.sh `sudo ./setup.sh`.
5) Povolte port 80 a 443 na firewallu.
- Networking|Virtual cloud networks
- Subnets
- Security Lists
- Add Ingress Rule
- Source 0.0.0.0/0
- TCP
- Destination port 80
- A pak ještě jedno stejné pravidlo, ale s portem 443
6) U nastavení lokace fotek dejte `/photos`.
7) Snad Hotovo.

View File

@@ -2,13 +2,14 @@ version: "3"
services:
db:
image: mariadb:10.5
image: mariadb:lts
restart: always
environment:
- MYSQL_DATABASE=photoview
- MYSQL_USER=photoview
- MYSQL_PASSWORD=photosecret
- MYSQL_RANDOM_ROOT_PASSWORD=1
- MARIADB_AUTO_UPGRADE=1
volumes:
- db_data:/var/lib/mysql
@@ -44,9 +45,8 @@ services:
volumes:
- /home/ubuntu/etc/caddy:/etc/caddy:ro
dockupdater:
image: dockupdater/dockupdater
restart: unless-stopped
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock

View File

@@ -1,12 +1,43 @@
#!/bin/bash
# setup photoview
# run as root
# run as root
if [[ $(id -u) != "0" ]]; then
echo RUN AS ROOT!!
exit 1
fi
# where to store photos
while getopts d:h opt; do
case $opt in
d)
PHOTOS="$OPTARG"
;;
h)
cat <<EOF
USAGE: ./setup.sh [-d destination]
Where to store photos.
EOF
exit 0
;;
*)
;;
esac
done
shift $((OPTIND-1))
PHOTOS=${PHOTOS:-/mnt/fotky}
# create store folder
if [[ -d "$PHOTOS" ]]; then
echo "Destination folder exists."
elif [[ -f "$PHOTOS" ]]; then
echo "Destination is file, must be folder!" >&2
exit 1
else
mkdir -p "$PHOTOS"
chown ubuntu:ubuntu "$PHOTOS"
fi
# install docker
apt-get update
apt-get install ca-certificates curl gnupg -y
@@ -19,25 +50,29 @@ echo \
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
# where to store photos
read -p "Kde chcete mít fotky? [/mnt/fotky]"
PHOTOS=${REPLY:-/mnt/fotky}
echo $PHOTOS
# serve at what domain
read -p "Na jaké doméně budou stránky? "
DOMAIN=${REPLY?Musíte mít doménu}
DOMAIN=${REPLY:?Musíte mít doménu}
echo $DOMAIN
# make config files
home=/home/ubuntu
sudo -u ubuntu mkdir -p $home/etc/caddy
sed -e "s:__DOMAIN__:$DOMAIN:" Caddyfile | sudo -u ubuntu tee $home/etc/caddy/Caddyfile
sed -e "s:__PHOTO__:$PHOTOS:" docker-compose.yml | sudo -u ubuntu tee $home/etc/docker-compose.yml
sed -e "s:__DOMAIN__:$DOMAIN:" Caddyfile | sudo -u ubuntu tee $home/etc/caddy/Caddyfile >/dev/null
sed -e "s:__PHOTO__:$PHOTOS:" docker-compose.yml | sudo -u ubuntu tee $home/etc/docker-compose.yml > /dev/null
# install
cd $HOME/etc
cd $home/etc
docker compose up -d
# add user ubuntu to docker group
usermod -a -G docker ubuntu
# SSH
# #TODO
sed -E 's/^.*PasswordAuthentication yes.*$/PasswordAuthentication no/' -i /etc/ssh/sshd_config
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIq7eEoXW6aUp5kdoG3YC6EulPH9SsSemDBzyv/Tofjr amogus" >> /home/ubuntu/.ssh/authorized_keys
# Summary
echo "Fotky jsou uloženy ve složce $PHOTOS"
echo "Photoview je dostupné na doméně $DOMAIN"