Compare commits
No commits in common. "master" and "development" have entirely different histories.
master
...
developmen
@ -13,17 +13,17 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: Get branch name
|
- name: Get branch name
|
||||||
id: branch-name
|
id: branch-name
|
||||||
uses: tj-actions/branch-names@v8
|
uses: tj-actions/branch-names@v7
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Restore Docker Cache
|
- name: Restore Docker Cache
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v3
|
||||||
id: docker-cache
|
id: docker-cache
|
||||||
with:
|
with:
|
||||||
path: /usr/bin/docker
|
path: /usr/bin/docker
|
||||||
@ -38,23 +38,23 @@ jobs:
|
|||||||
echo "Done"
|
echo "Done"
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Login to Repo
|
- name: Login to Repo
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.REPO_USERNAME }}
|
username: ${{ secrets.REPO_USERNAME }}
|
||||||
password: ${{ secrets.REPO_TOKEN }}
|
password: ${{ secrets.REPO_TOKEN }}
|
||||||
|
|
||||||
- name: Restore Docker Build Cache
|
- name: Restore Docker Build Cache
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v3
|
||||||
id: build-cache
|
id: build-cache
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-cache
|
path: /tmp/.buildx-cache
|
||||||
key: ${{ runner.os }}-buildx
|
key: ${{ runner.os }}-buildx
|
||||||
|
|
||||||
- name: Build and Push (Latest)
|
- name: Build and Push (Latest)
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v4
|
||||||
if: steps.branch-name.outputs.current_branch == 'master'
|
if: steps.branch-name.outputs.current_branch == 'master'
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
@ -64,7 +64,7 @@ jobs:
|
|||||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
|
||||||
- name: Build and Push (Other Branches)
|
- name: Build and Push (Other Branches)
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v4
|
||||||
if: steps.branch-name.outputs.current_branch != 'master'
|
if: steps.branch-name.outputs.current_branch != 'master'
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
|
32
Dockerfile
32
Dockerfile
@ -1,20 +1,18 @@
|
|||||||
# Stage 1: Build Nginx
|
# Stage 1: Build Nginx
|
||||||
FROM alpine:3.20.3 as builder
|
FROM alpine:3.18.4 as builder
|
||||||
|
|
||||||
# Install build dependencies and required tools
|
# Install build dependencies and required tools
|
||||||
RUN apk update && apk upgrade && \
|
RUN apk update && apk upgrade && \
|
||||||
apk add --no-cache build-base pcre-dev openssl-dev zlib-dev linux-headers
|
apk add --no-cache php81 php81-fpm php81-gd build-base pcre-dev openssl-dev zlib-dev linux-headers
|
||||||
|
|
||||||
# Download and build the latest version of Nginx from source
|
# Download and build the latest version of Nginx from source
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
RUN wget https://nginx.org/download/nginx-1.27.0.tar.gz && \
|
RUN wget https://nginx.org/download/nginx-1.25.2.tar.gz
|
||||||
tar -xzvf nginx-1.27.0.tar.gz && \
|
RUN tar -xzvf nginx-1.25.2.tar.gz
|
||||||
cd nginx-1.27.0 && \
|
WORKDIR /tmp/nginx-1.25.2
|
||||||
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx.conf && \
|
RUN ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx.conf
|
||||||
make > /dev/null 2>&1 && \
|
RUN make
|
||||||
make install > /dev/null 2>&1 && \
|
RUN make install
|
||||||
make_status=$? && \
|
|
||||||
if [ $make_status -ne 0 ]; then echo "Nginx build failed"; exit $make_status; fi
|
|
||||||
|
|
||||||
# Cleanup unnecessary files
|
# Cleanup unnecessary files
|
||||||
RUN rm -rf /tmp/*
|
RUN rm -rf /tmp/*
|
||||||
@ -25,26 +23,20 @@ COPY ./docker/nginx.conf /etc/nginx/nginx.conf
|
|||||||
# Setup scripts
|
# Setup scripts
|
||||||
COPY ./upload.php /tmp/upload.php
|
COPY ./upload.php /tmp/upload.php
|
||||||
COPY ./docker/start.sh /start.sh
|
COPY ./docker/start.sh /start.sh
|
||||||
COPY ./docker/index.html /tmp/index.html
|
|
||||||
|
|
||||||
# Copy public directory
|
# Stage 2: Create a smaller image
|
||||||
COPY ./public /tmp/public
|
FROM alpine:3.18.4
|
||||||
|
|
||||||
# Stage 2: Create a smaller production image
|
|
||||||
FROM alpine:3.20.3
|
|
||||||
|
|
||||||
# Copy Nginx and PHP-FPM binaries and configurations from the builder stage
|
# Copy Nginx and PHP-FPM binaries and configurations from the builder stage
|
||||||
COPY --from=builder /usr/local/nginx /usr/local/nginx
|
COPY --from=builder /usr/local/nginx /usr/local/nginx
|
||||||
COPY --from=builder /usr/local/sbin/nginx /usr/local/sbin/nginx
|
|
||||||
COPY --from=builder /etc/nginx /etc/nginx
|
COPY --from=builder /etc/nginx /etc/nginx
|
||||||
|
COPY --from=builder /etc/php81 /etc/php81
|
||||||
COPY --from=builder /tmp/upload.php /tmp/upload.php
|
COPY --from=builder /tmp/upload.php /tmp/upload.php
|
||||||
COPY --from=builder /tmp/index.html /tmp/index.html
|
|
||||||
COPY --from=builder /start.sh /start.sh
|
COPY --from=builder /start.sh /start.sh
|
||||||
COPY --from=builder /tmp/public /tmp/public
|
|
||||||
|
|
||||||
# Install runtime dependencies
|
# Install runtime dependencies
|
||||||
RUN apk update && apk upgrade && \
|
RUN apk update && apk upgrade && \
|
||||||
apk add --no-cache php83 php83-fpm php83-gd pcre
|
apk add --no-cache php81 php81-fpm php81-gd
|
||||||
|
|
||||||
# Cleanup unnecessary files
|
# Cleanup unnecessary files
|
||||||
RUN rm -rf /var/cache/apk/*
|
RUN rm -rf /var/cache/apk/*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# ShareX Uploader
|
# ShareX Upload Script
|
||||||
|
|
||||||
This PHP script allows you to easily upload ShareX screenshots and videos. It includes token authentication for security and can handle various image file types by converting them to WebP format for efficient storage.
|
This PHP script allows you to easily upload ShareX screenshots and videos. It includes token authentication for security and can handle various image file types by converting them to WebP format for efficient storage.
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ This PHP script allows you to easily upload ShareX screenshots and videos. It in
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Copy the `docker-compose.yml` file to your server.
|
1. Copy the `docker-compose.yml` file to your server.
|
||||||
2. Edit the `docker-compose.yml` file and change environment variables to what you need, and update `./uploads` to where you want to store the files.
|
2. Edit the `docker-compose.yml` file and change `MAX_UPLOAD_SIZE` to the maximum file size you want to allow, and update `./uploads` to where you want to store the files.
|
||||||
3. Run `docker-compose up -d` to start the container.
|
3. Run `docker-compose up -d` to start the container.
|
||||||
4. Go to where the files are stored and edit the variables in `upload.php` to your liking.
|
4. Go to where the files are stored and edit the variables in `upload.php` to your liking.
|
||||||
5. Run `docker-compose restart` to restart the container.
|
5. Run `docker-compose restart` to restart the container.
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>ShareX Uploader</title>
|
|
||||||
|
|
||||||
<!-- TailwindCSS -->
|
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
|
||||||
</head>
|
|
||||||
<body
|
|
||||||
class="h-screen bg-neutral-900 text-white flex flex-col text-center items-center p-4 gap-2"
|
|
||||||
>
|
|
||||||
<p class="text-blue-400 text-4xl">ShareX Uploader</p>
|
|
||||||
<p class="text-gray-400 text-xl">Created by ImFascinated</p>
|
|
||||||
<div>
|
|
||||||
<a href="https://s.fascinated.cc/s/sharex-uploader">Source</a>
|
|
||||||
<a href="https://s.fascinated.cc/s/gitea">Gitea</a>
|
|
||||||
<a href="https://s.fascinated.cc/s/github">GitHub</a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -39,12 +39,6 @@ http {
|
|||||||
|
|
||||||
client_max_body_size 500M; # Will get replaced by the environment variable MAX_UPLOAD_SIZE
|
client_max_body_size 500M; # Will get replaced by the environment variable MAX_UPLOAD_SIZE
|
||||||
|
|
||||||
# Fallback 404 page
|
|
||||||
location = /not-found.html {
|
|
||||||
internal;
|
|
||||||
root /tmp/public;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Upload endpoint
|
# Upload endpoint
|
||||||
location /upload.php {
|
location /upload.php {
|
||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
@ -66,8 +60,6 @@ http {
|
|||||||
open_file_cache_min_uses 1;
|
open_file_cache_min_uses 1;
|
||||||
open_file_cache_errors on;
|
open_file_cache_errors on;
|
||||||
|
|
||||||
error_page 404 /not-found.html;
|
|
||||||
|
|
||||||
# Serve the file directly from disk
|
# Serve the file directly from disk
|
||||||
try_files $uri $uri/ =404;
|
try_files $uri $uri/ =404;
|
||||||
}
|
}
|
||||||
|
@ -14,24 +14,16 @@ else
|
|||||||
echo "Upload script was not found, copying it."
|
echo "Upload script was not found, copying it."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Checking if default index.html exists in /var/www/html"
|
|
||||||
if [ -f "/var/www/html/index.html" ]; then
|
|
||||||
echo "Upload script was found, ignoring copy."
|
|
||||||
else
|
|
||||||
cp /tmp/index.html /var/www/html
|
|
||||||
echo "Default index.html was not found, copying it."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Letting php know that we are running in docker
|
# Letting php know that we are running in docker
|
||||||
echo "env[DOCKER] = true" >> /etc/php83/php-fpm.d/www.conf
|
echo "env[DOCKER] = true" >> /etc/php81/php-fpm.d/www.conf
|
||||||
echo "clear_env = no" >> /etc/php83/php-fpm.d/www.conf
|
echo "clear_env = no" >> /etc/php81/php-fpm.d/www.conf
|
||||||
|
|
||||||
# Create the directory for PHP socket
|
# Create the directory for PHP socket
|
||||||
mkdir -p /run/php
|
mkdir -p /run/php
|
||||||
|
|
||||||
# Set php-fpm to listen on socket
|
# Set php-fpm to listen on socket
|
||||||
touch /run/php/php.sock
|
touch /run/php/php.sock
|
||||||
sed -i 's/^listen = .*/listen = \/run\/php\/php.sock/' /etc/php83/php-fpm.d/www.conf
|
sed -i 's/^listen = .*/listen = \/run\/php\/php.sock/' /etc/php81/php-fpm.d/www.conf
|
||||||
|
|
||||||
echo "Setting permissions for upload script"
|
echo "Setting permissions for upload script"
|
||||||
chmod 777 /var/www/html/upload.php
|
chmod 777 /var/www/html/upload.php
|
||||||
@ -39,15 +31,15 @@ chmod 777 /var/www/html/upload.php
|
|||||||
echo "Setting max upload size to ${MAX_UPLOAD_SIZE}"
|
echo "Setting max upload size to ${MAX_UPLOAD_SIZE}"
|
||||||
|
|
||||||
# Set max upload size for php
|
# Set max upload size for php
|
||||||
sed -i "s/^upload_max_filesize = .*/upload_max_filesize = ${MAX_UPLOAD_SIZE}/" /etc/php83/php.ini
|
sed -i "s/^upload_max_filesize = .*/upload_max_filesize = ${MAX_UPLOAD_SIZE}/" /etc/php81/php.ini
|
||||||
sed -i "s/^post_max_size = .*/post_max_size = ${MAX_UPLOAD_SIZE}/" /etc/php83/php.ini
|
sed -i "s/^post_max_size = .*/post_max_size = ${MAX_UPLOAD_SIZE}/" /etc/php81/php.ini
|
||||||
|
|
||||||
# Set max upload size for nginx
|
# Set max upload size for nginx
|
||||||
sed -i "s/client_max_body_size 500M;/client_max_body_size ${MAX_UPLOAD_SIZE};/" /etc/nginx/nginx.conf
|
sed -i "s/client_max_body_size 500M;/client_max_body_size ${MAX_UPLOAD_SIZE};/" /etc/nginx/nginx.conf
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
echo "Starting PHP & Nginx"
|
echo "Starting PHP & Nginx"
|
||||||
php-fpm83 &&
|
php-fpm81 &&
|
||||||
chmod 777 /run/php/php.sock &&
|
chmod 777 /run/php/php.sock &&
|
||||||
/usr/local/sbin/nginx -g 'daemon off;'
|
/usr/local/sbin/nginx -g 'daemon off;'
|
||||||
}
|
}
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>File Not Found</title>
|
|
||||||
|
|
||||||
<!-- TailwindCSS -->
|
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
|
||||||
</head>
|
|
||||||
<body
|
|
||||||
class="h-screen bg-neutral-900 text-white flex flex-col text-center justify-center items-center p-4 gap-2"
|
|
||||||
>
|
|
||||||
<p class="text-red-400 text-3xl">404 - File Not Found</p>
|
|
||||||
<p class="text-gray-400 text-xl">
|
|
||||||
We're sorry, the file you requested could not be found.
|
|
||||||
</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["config:recommended", ":dependencyDashboard"]
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user