-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example config with caddy, ready to run (#212)
- Loading branch information
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
MYSQL_ROOT_PASSWORD=Enter a secret value here | ||
MYSQL_LYCHEE_PASSWORD=Enter a secret value here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(common) { | ||
encode zstd gzip | ||
header /* { | ||
-Server | ||
-x-powered-by | ||
} | ||
} | ||
|
||
<YOUR_DOMAIN> { | ||
handle /* { | ||
reverse_proxy lychee | ||
} | ||
import common | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Configuration with caddy | ||
|
||
This is an example configuration for using the Lychee photo management tool with the Caddy web server. Make sure to adjust the domain in the Caddyfile and set the `MYSQL_ROOT_PASSWORD` and `MYSQL_LYCHEE_PASSWORD` in the .env file to secure your database. | ||
|
||
These configurations are automatically applied when using the `setup.sh` script. | ||
|
||
## Setup | ||
|
||
The `setup.sh` script downloads necessary files, generates strong MySQL passwords, and updates the domain in the Caddyfile. | ||
|
||
``` | ||
curl -O https://raw.githubusercontent.com/LycheeOrg/Lychee-Docker/refs/heads/master/configuration-with-caddy/setup.sh && chmod +x setup.sh && ./setup.sh | ||
``` | ||
|
||
## Start | ||
|
||
Docker pulls the containers and then starts them as services running in the background. | ||
|
||
``` | ||
docker-compose pull | ||
docker-compose up -d | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
services: | ||
|
||
caddy: | ||
container_name: caddy | ||
image: caddy:2 | ||
restart: unless-stopped | ||
ports: | ||
- 80:80 | ||
- 443:443 | ||
- 443:443/udp | ||
volumes: | ||
- ./Caddyfile:/etc/caddy/Caddyfile:ro | ||
- ./caddy-config:/config | ||
- ./caddy-data:/data | ||
networks: | ||
- lychee | ||
|
||
lychee_db: | ||
container_name: lychee_db | ||
image: mariadb:10 | ||
restart: unless-stopped | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} | ||
- MYSQL_DATABASE=lychee | ||
- MYSQL_USER=lychee | ||
- MYSQL_PASSWORD=${MYSQL_LYCHEE_PASSWORD} | ||
expose: | ||
- 3306 | ||
volumes: | ||
- mysql:/var/lib/mysql | ||
networks: | ||
- lychee | ||
|
||
lychee: | ||
container_name: lychee | ||
image: lycheeorg/lychee:dev | ||
restart: unless-stopped | ||
environment: | ||
- PHP_TZ=UTC | ||
- TIMEZONE=UTC | ||
- DB_CONNECTION=mysql | ||
- DB_HOST=lychee_db | ||
- DB_PORT=3306 | ||
- DB_DATABASE=lychee | ||
- DB_USERNAME=lychee | ||
- DB_PASSWORD=${MYSQL_LYCHEE_PASSWORD} | ||
- STARTUP_DELAY=10 | ||
- TRUSTED_PROXIES=* | ||
expose: | ||
- 80 | ||
volumes: | ||
- ./lychee/conf:/conf | ||
- ./lychee/uploads:/uploads | ||
- ./lychee/sym:/sym | ||
- ./lychee/logs:/logs | ||
- ./lychee/tmp:/lychee-tmp | ||
depends_on: | ||
- lychee_db | ||
networks: | ||
- lychee | ||
|
||
networks: | ||
lychee: | ||
|
||
volumes: | ||
mysql: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Set variables | ||
REPO_URL="https://raw.githubusercontent.com/LycheeOrg/Lychee-Docker/refs/heads/master/configuration-with-caddy" | ||
DOCKER_COMPOSE_FILE="docker-compose.yml" | ||
ENV_FILE=".env" | ||
CADDYFILE="Caddyfile" | ||
|
||
# Prompt for domain | ||
read -p "Enter your domain name: " DOMAIN | ||
|
||
# Download files from GitHub | ||
curl -O "$REPO_URL/$DOCKER_COMPOSE_FILE" || { echo "Failed to download $DOCKER_COMPOSE_FILE"; exit 1; } | ||
curl -O "$REPO_URL/$ENV_FILE" || { echo "Failed to download $ENV_FILE"; exit 1; } | ||
curl -O "$REPO_URL/$CADDYFILE" || { echo "Failed to download $CADDYFILE"; exit 1; } | ||
|
||
# Set MYSQL_ROOT_PASSWORD and MYSQL_LYCHEE_PASSWORD in the .env file | ||
MYSQL_ROOT_PASSWORD="$(openssl rand -base64 24)" | ||
MYSQL_LYCHEE_PASSWORD="$(openssl rand -base64 24)" | ||
|
||
if [ -f "$ENV_FILE" ]; then | ||
sed -i "s/^MYSQL_ROOT_PASSWORD=.*/MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD/" "$ENV_FILE" | ||
sed -i "s/^MYSQL_LYCHEE_PASSWORD=.*/MYSQL_LYCHEE_PASSWORD=$MYSQL_LYCHEE_PASSWORD/" "$ENV_FILE" | ||
else | ||
echo "$ENV_FILE not found. Creating the file." | ||
echo "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" > "$ENV_FILE" | ||
echo "MYSQL_LYCHEE_PASSWORD=$MYSQL_LYCHEE_PASSWORD" >> "$ENV_FILE" | ||
fi | ||
|
||
# Replace domain placeholder in the Caddyfile | ||
if [ -f "$CADDYFILE" ]; then | ||
sed -i "s/<YOUR_DOMAIN>/$DOMAIN/" "$CADDYFILE" | ||
else | ||
echo "$CADDYFILE not found." | ||
exit 1 | ||
fi | ||
|
||
# Display success message | ||
echo "Files successfully downloaded and passwords set:" | ||
echo "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" | ||
echo "MYSQL_LYCHEE_PASSWORD=$MYSQL_LYCHEE_PASSWORD" | ||
|
||
echo "Caddyfile updated with domain: $DOMAIN" | ||
|
||
echo "You can now run 'docker-compose up -d'." |