From 04a5ba3a3d28dc167c5a9a7ba2fc7156f6bc4994 Mon Sep 17 00:00:00 2001 From: Varakh Date: Fri, 1 Nov 2024 11:09:16 +0100 Subject: [PATCH] Move to PHP83 as PHP distribution, update documentation --- CHANGELOG.md | 5 ++++ Dockerfile | 58 ++++++++++++++++++++--------------------- README.md | 64 +++++++++++++++++++++++++++++++++++++--------- docker-compose.yml | 17 +++++++----- local_build.sh | 27 ------------------- src/s6/php-fpm/run | 2 +- 6 files changed, 97 insertions(+), 76 deletions(-) delete mode 100755 local_build.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ad28f5..356731a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## 2024-11-01 + +* Move to PHP83 +* Update documentation + ## 2024-04-14 * Update to FileBin `4.0.2` diff --git a/Dockerfile b/Dockerfile index 00abf1b..77ced4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # # Build image # -FROM alpine:3 as builder +FROM alpine:3.20 as builder ARG FB_VERSION ARG FB_SOURCE_URL="https://github.com/Bluewind/filebin" @@ -22,7 +22,7 @@ RUN apk add --update --no-cache git && \ git clone --branch ${FB_VERSION} "${FB_SOURCE_URL}" --depth=${FB_CLONE_DEPTH} /app/fb_src && \ rm -rf /app/fb_src/.git -FROM alpine:3 +FROM alpine:3.20 COPY --from=builder /app/fb_src /var/www LABEL maintainer="Varakh " \ @@ -92,27 +92,27 @@ RUN chmod -x /wait-for.sh && \ ghostscript \ msmtp \ composer \ - php81 \ - php81-fpm \ - php81-intl \ - php81-curl \ - php81-dom \ - php81-pcntl \ - php81-posix \ - php81-session \ - php81-gd \ - php81-exif \ - php81-phar \ - php81-pdo \ - php81-pgsql \ - php81-pdo_pgsql \ - php81-pdo_mysql \ - php81-mysqli \ - php81-fileinfo \ - php81-mbstring \ - php81-ctype \ - php81-ldap \ - php81-pecl-memcached \ + php83 \ + php83-fpm \ + php83-intl \ + php83-curl \ + php83-dom \ + php83-pcntl \ + php83-posix \ + php83-session \ + php83-gd \ + php83-exif \ + php83-phar \ + php83-pdo \ + php83-pgsql \ + php83-pdo_pgsql \ + php83-pdo_mysql \ + php83-mysqli \ + php83-fileinfo \ + php83-mbstring \ + php83-ctype \ + php83-ldap \ + php83-pecl-memcached \ memcached \ ca-certificates && \ rm -rf /var/cache/apk/* && \ @@ -120,16 +120,16 @@ RUN chmod -x /wait-for.sh && \ # prepare www dir cp -r /var/www/application/config/example/* /var/www/application/config && \ # set environments - sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" /etc/php81/php.ini && \ - sed -i "s|;*upload_max_filesize =.*|upload_max_filesize = ${MAX_UPLOAD}|i" /etc/php81/php.ini && \ - sed -i "s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i" /etc/php81/php.ini && \ - sed -i "s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i" /etc/php81/php.ini && \ - sed -i 's+.*sendmail_path =.*+sendmail_path = "/usr/bin/msmtp -C /var/www/msmtprc --logfile /var/www/msmtp.log -a filebinmail -t"+' /etc/php81/php.ini && \ + sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" /etc/php83/php.ini && \ + sed -i "s|;*upload_max_filesize =.*|upload_max_filesize = ${MAX_UPLOAD}|i" /etc/php83/php.ini && \ + sed -i "s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i" /etc/php83/php.ini && \ + sed -i "s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i" /etc/php83/php.ini && \ + sed -i 's+.*sendmail_path =.*+sendmail_path = "/usr/bin/msmtp -C /var/www/msmtprc --logfile /var/www/msmtp.log -a filebinmail -t"+' /etc/php83/php.ini && \ # clean up and permissions rm -rf /var/cache/apk/* && \ chown nobody:nginx -R /var/www && \ rm /usr/bin/php && \ - ln -s /usr/bin/php81 /usr/bin/php + ln -s /usr/bin/php83 /usr/bin/php # Add nginx config ADD src/filebin.nginx.conf /etc/nginx/nginx.conf diff --git a/README.md b/README.md index 8d85ad8..0f9f3a7 100644 --- a/README.md +++ b/README.md @@ -2,45 +2,85 @@ A docker image for [FileBin](https://git.server-speed.net/users/flo/filebin/) to have it up and running in seconds. -Visit project on [https://git.myservermanager.com/varakh/docker-filebin](https://git.myservermanager.com/varakh/docker-filebin) +Visit project +on [https://git.myservermanager.com/varakh/docker-filebin](https://git.myservermanager.com/varakh/docker-filebin) or [Docker Hub](https://hub.docker.com/r/varakh/filebin). -The main git repository is hosted at _[https://git.myservermanager.com/varakh/docker-filebin](https://git.myservermanager.com/varakh/docker-filebin)_. +The main git repository is hosted at +_[https://git.myservermanager.com/varakh/docker-filebin](https://git.myservermanager.com/varakh/docker-filebin)_. Other repositories are mirrors and pull requests, issues, and planning are managed there. Contributions are very welcome! ## Getting started -The recommended way to get started is to use the example `docker-compose.yml` file and use *Docker*. Before, make +There's an example [`docker-compose.yml`](./docker-compose.yml) file to get started quickly. Before, make yourself familiar with the environment variables which can be set. Defaults should do as a starting point. _Be sure to read persisting volumes_ section and execute the required command. -Default database is PostgreSQL. Other databases are supported and can be configured via exposed environment variables. +Default database is Postgres. Other databases are supported and can be configured via exposed environment variables. Please refer to the original documentation of the application for further details. PHP modules for MySQL are included in the image. After your database and the application docker container is up and running, add a first user by executing a command within the docker container: -``` -docker exec -it filebin_app /bin/sh +```shell +# docker +docker exec -it filebin_app sh + +# podman +podman exec -it filebin_app sh + +# inside container php /var/www/index.php user add_user ``` -_Alternatively_ you can also use *Podman* for a root-less deployment, e.g. with something similar to: +_Alternatively_ you can also use *Podman* for deployment, e.g. with something similar to: -``` -podman run -e POSTGRES_PASSWORD=fb -e POSTGRES_USER=fb -e POSTGRES_DB=fb -p 5432:5432 docker.io/postgres:11 -podman run -e BASE_URL=http://localhost:8080 -e DB_HOST=your_host -e DB_PORT=5432 -e DB_NAME=fb -e DB_USER=fb -e DB_PASS=fb -e ENCRYPTION_KEY=your_32_long_secret -p 8080:80 docker.io/varakh/filebin:latest +```shell +# create recommended volumes +podman volume create fb-data-vol +podman volume create fb-db-vol + +# create pod, making it available on localhost only +podman pod create -n filebin -p '127.0.0.1:8080:80' + +# start database container +podman run -d --name filebin_db \ + --pod filebin + -v fb-db-vol:/var/lib/postgresql/data \ + -e POSTGRES_PASSWORD=fb \ + -e POSTGRES_USER=fb \ + -e POSTGRES_DB=fb \ + docker.io/postgres:15 + +# start application container +# - generate ENCRYPTION_KEY key via 'openssl rand -hex 16' +# - adapt 'BASE_URL' to your public domain +podman run -d --name filebin_app \ + --pod filebin \ + -v fb-data-vol:/var/www/data/uploads \ + -e ENCRYPTION_KEY= \ + -e BASE_URL=http://localhost:8080 \ + -e DB_HOST=localhost \ + -e DB_PORT=5432 \ + -e DB_NAME=fb \ + -e DB_USER=fb \ + -e DB_PASS=fb \ + docker.io/varakh/filebin:latest ``` ### Persisting volumes -You'll probably want the `uploads/` folder to be persistent across container restarts. +> Postgres data should also be persisted. Please look into the above examples or consult Postgres docker image +> documentation. -Here's an example on how to persist the `data/uploads/` folder of the application. +You'll probably want FileBin's `uploads/` folder to be persistent across container restarts. + +Here's an example on how to persist the `data/uploads/` folder of the application with a host bind. You can also use +actual volumes for that. * Create folder: `mkdir -p ./filebin_data` * Afterward, adjust permissions so that the folder can be used within the docker diff --git a/docker-compose.yml b/docker-compose.yml index 47d0a58..8b4c95b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - networks: fb: external: false @@ -13,7 +11,8 @@ services: - POSTGRES_USER=fb - POSTGRES_DB=fb volumes: - - ./filebin_db/:/var/lib/postgresql/data # persist postgres data on the host + # persist postgres data on host in current directory, you can also switch to actual volumes + - ./filebin_db/:/var/lib/postgresql/data restart: always networks: - fb @@ -24,17 +23,21 @@ services: depends_on: - db ports: - - "127.0.0.1:8080:80" # exposed port :80 mapped to :8080 on only this host. 8080 should then be used in proxy + # exposed port :80 mapped to :8080 on only this host. 8080 should then be used in proxy + - "127.0.0.1:8080:80" environment: - - BASE_URL=https://fb.domain.tld/ # with trailing slash + # with trailing slash + - BASE_URL=https://fb.domain.tld/ - DB_HOST=db - DB_PORT=5432 - DB_NAME=fb - DB_USER=fb - DB_PASS=fb - - ENCRYPTION_KEY= # REQUIRED: set a 32 character long sequence + # REQUIRED: set a 32 character long sequence, e.g. with 'openssl rand -hex 16' + - ENCRYPTION_KEY= volumes: - - "./filebin_data:/var/www/data/uploads" # persist filebin data on the host + # persist filebin data on host in current directory, you can also switch to actual volumes + - "./filebin_data:/var/www/data/uploads" stdin_open: true tty: true restart: always diff --git a/local_build.sh b/local_build.sh deleted file mode 100755 index ddc5221..0000000 --- a/local_build.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -set -e; - -if [[ -v FB_VERSION ]]; then - echo "Processing with version ${FB_VERSION}" -else - echo "Set FB_VERSION before calling this script" - exit 1; -fi - -BUILD_DIR="fb_src" - -if [[ ! -d "${BUILD_DIR}" ]]; then - mkdir -p "${BUILD_DIR}"; - echo "Created ${BUILD_DIR}" -else - rm -rf "${BUILD_DIR}"; - mkdir -p "${BUILD_DIR}"; - echo "Re-created ${BUILD_DIR}" -fi - -git clone --branch ${FB_VERSION} https://github.com/Bluewind/filebin --depth=1 "${BUILD_DIR}"; -sudo docker build --no-cache -t varakh/filebin:${FB_VERSION} -t varakh/filebin:latest .; - - - diff --git a/src/s6/php-fpm/run b/src/s6/php-fpm/run index bd4199b..63d412c 100755 --- a/src/s6/php-fpm/run +++ b/src/s6/php-fpm/run @@ -1,3 +1,3 @@ #!/bin/sh -exec /usr/sbin/php-fpm81 --nodaemonize +exec /usr/sbin/php-fpm83 --nodaemonize