initial poc release

initial poc release
This commit is contained in:
Carlos Sousa 2023-12-19 23:54:01 +01:00 committed by GitHub
commit 3cd5944a2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 157 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM nginx:alpine
COPY ./src/html /usr/share/nginx/html
COPY ./src/nginx/default.conf /etc/nginx/conf.d/default.conf
# Set permissions for the images directory
RUN mkdir -p /usr/share/nginx/html/images && chmod -R 755 /usr/share/nginx/html/images
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

23
docker-compose.yml Normal file
View File

@ -0,0 +1,23 @@
version: '3.8'
services:
nginxcdn:
container_name: nginxcdn
restart: unless-stopped
build: .
ports:
- "80:80"
volumes:
- ./images:/usr/share/nginx/html/images
# Used in Reverse Proxy Setup
#expose:
# - 80
# Networks
#networks:
# - reverse_proxy_network
# Used in a reverse proxy setup
# networks:
# reverse_proxy_network:
# name: reverse_proxy_network
# external: true

1
helpers/.env.sample Normal file
View File

@ -0,0 +1 @@
IMAGE_DIR=/path/to/your/directory

31
helpers/makeThumbnails.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# Directory containing the script
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Load IMAGE_DIR from .env file
if [ -f "$SCRIPT_DIR/.env" ]; then
export $(grep -v '^#' "$SCRIPT_DIR/.env" | xargs)
else
echo "Error: .env file not found."
exit 1
fi
# Loop through each file in the directory
for file in "$IMAGE_DIR"/*; do
# Check if file is an image
if [[ $file == *.jpg || $file == *.png || $file == *.jpeg ]]; then
# Get image dimensions
width=$(identify -format "%w" "$file")
height=$(identify -format "%h" "$file")
# Determine if image is landscape or portrait
if [ "$width" -ge "$height" ]; then
# Landscape image, resize to 200x100
convert "$file" -resize 200x100 "${file%.*}_thumbnail.${file##*.}"
else
# Portrait image, resize to 100x200
convert "$file" -resize 100x200 "${file%.*}_thumbnail.${file##*.}"
fi
fi
done

24
src/html/404.html Normal file
View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>404 Not Found</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
</head>
<body>
<article>
<h1>Oops! Page Not Found</h1>
<div>
<p>Seems like you've found the doorway to the great nothing. Careful, or you'll fall into the vast emptiness of space! Just kidding, it's just a 404 error.</p>
<p>Why not try heading <a href="/">home</a> and start again?</p>
</div>
</article>
</body>
</html>

24
src/html/50x.html Normal file
View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Server Error</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
</head>
<body>
<article>
<h1>Oops! Something Went Wrong</h1>
<div>
<p>Our server is currently having a bit of a hiccup. It might be out for a coffee break or just daydreaming. We're on it though!</p>
<p>Meanwhile, you can return <a href="/">home</a> and try refreshing. Who knows, it might be back from its break!</p>
</div>
</article>
</body>
</html>

22
src/html/index.html Normal file
View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome!</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
</style>
</head>
<body>
<article>
<h1>Welcome to our little CDN!</h1>
<div>
<p>Hello there! You've stumbled upon our little corner of the internet. We're thrilled to have you here!</p>
<p>Feel free to explore, click around, and have fun. Remember, don't feed the virtual animals!</p>
</div>
</article>
</body>
</html>

22
src/nginx/default.conf Normal file
View File

@ -0,0 +1,22 @@
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ =404;
# Cache settings
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}