docker-filebin/README.md

202 lines
6.8 KiB
Markdown
Raw Normal View History

2019-12-18 18:39:33 +00:00
# FileBin 🐋
A docker image for [FileBin](https://git.server-speed.net/users/flo/filebin/) to have it up and running in seconds.
2019-12-18 18:39:33 +00:00
Visit project
on [https://git.myservermanager.com/varakh/docker-filebin](https://git.myservermanager.com/varakh/docker-filebin)
2021-05-20 23:03:02 +00:00
or [Docker Hub](https://hub.docker.com/r/varakh/filebin).
2019-12-18 18:39:33 +00:00
The main git repository is hosted at
_[https://git.myservermanager.com/varakh/docker-filebin](https://git.myservermanager.com/varakh/docker-filebin)_.
2022-07-05 20:10:24 +00:00
Other repositories are mirrors and pull requests, issues, and planning are managed there.
Contributions are very welcome!
2019-12-18 18:39:33 +00:00
## Getting started
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.
2019-12-18 18:39:33 +00:00
2019-12-18 18:51:33 +00:00
_Be sure to read persisting volumes_ section and execute the required command.
2019-12-18 18:39:33 +00:00
Default database is Postgres. Other databases are supported and can be configured via exposed environment variables.
2021-05-20 23:03:02 +00:00
Please refer to the original documentation of the application for further details. PHP modules for MySQL are included in
the image.
2019-12-18 18:39:33 +00:00
2021-05-20 23:03:02 +00:00
After your database and the application docker container is up and running, add a first user by executing a command
within the docker container:
2019-12-18 18:39:33 +00:00
```shell
# docker
docker exec -it filebin_app sh
2019-12-18 18:39:33 +00:00
# podman
podman exec -it filebin_app sh
# inside container
php /var/www/index.php user add_user
```
_Alternatively_ you can also use *Podman* for deployment, e.g. with something similar to:
```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=<your_32_long_secret> \
-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
```
2019-12-18 18:39:33 +00:00
### Persisting volumes
> Postgres data should also be persisted. Please look into the above examples or consult Postgres docker image
> documentation.
You'll probably want FileBin's `uploads/` folder to be persistent across container restarts.
2019-12-18 18:39:33 +00:00
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.
2019-12-18 18:39:33 +00:00
* Create folder: `mkdir -p ./filebin_data`
2024-01-21 17:40:43 +00:00
* Afterward, adjust permissions so that the folder can be used within the docker
2021-05-20 23:03:02 +00:00
container: `chown -R 65534:102 <host-mount>` (`nobody:nginx`)
2019-12-18 18:39:33 +00:00
* Reference the folder as a docker volume, e.g. with `./filebin_data:/var/www/data/uploads`
### Cron jobs
Application specific cron jobs are run every 15 minutes.
### Advanced configuration: customize non-exposed configuration variables
2021-05-20 23:03:02 +00:00
If you need to make frequent changes or adapt configuration values which are not exposed as environment variables, you
probably want the `config-local.php` and `database.php` or the entire `config/` folder on the hosts file system.
2019-12-18 18:39:33 +00:00
2021-05-20 23:03:02 +00:00
In order to do so, first _extract_ the current configuration, e.g. by extracting only the required `.php` files or by
extracting the entire `config/` folder. In this example we'll just use entire folder.
2019-12-18 18:39:33 +00:00
```
docker cp filebin_app:/var/www/application/config/ ./filebin_config
chown -R 65534:102 ./filebin_config
```
2021-05-20 23:03:02 +00:00
Add the `./filebin_config` folder as a host bind to the application docker container, e.g.
with `./filebin_config:/var/www/application/config/`
2019-12-18 18:39:33 +00:00
### Available environment variables
Please have a look into `Dockerfile` for available environment variables, they're all exposed there.
2021-05-20 23:03:02 +00:00
All variables to FileBin itself should be self-explaining. You should also be familiar with the `php.ini` variables.
They're only inserted on build, if you like to increase the file limit above the used php variable values of this image,
you'll need to rebuild the docker image.
2019-12-18 18:39:33 +00:00
There are two environment variables introduced by this image:
2021-05-20 23:03:02 +00:00
* `RECONFIGURE`: If all defined environment should be re-applied to the provided `.tpl` files within the image. You
probably want this to be `1` unless you mounted your `config/` folder on the host
* `MIGRATE`: Calls FileBin database migration every time the container is started and updates dependencies
via `composer`
* `SMTP_ENABLED`: Set to `true` in order to enable sending mails via an external SMTP server, set to `false` to use
PHP's internal mailer, see other `SMTP_` variables in the `Dockerfile`
2019-12-18 18:39:33 +00:00
### Setting up a nginx proxy
2021-05-20 23:03:02 +00:00
Be sure to set the environment variable `BASE_URL` to the same where you expose it,
e.g. `BASE_URL=https://fb.domain.tld`.
2019-12-18 18:39:33 +00:00
An example nginx configuration might look like the following.
```
upstream filebin {
server 127.0.0.1:8080;
2019-12-18 18:39:33 +00:00
}
server {
listen 80;
server_name fb.domain.tld;
return 301 https://fb.domain.tld$request_uri;
}
server {
listen 443 ssl;
server_name fb.domain.tld;
ssl_certificate /etc/letsencrypt/live/fb.domain.tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/fb.domain.tld/privkey.pem;
gzip on;
access_log off;
location / {
proxy_redirect off;
proxy_pass http://filebin;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
client_body_buffer_size 128k;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
```
## Updates
Just use a newly released image version. Configuration should be compatible.
## Backup
Backup the host binds for `uploads/` and the database manually.
2021-05-20 23:03:02 +00:00
If you're using the provided `docker-compose.yml` file you probably can do something like the following and afterwards
backup the extracted file from `/tmp` of your host system:
2019-12-18 18:39:33 +00:00
```
docker exec filebin_db bash -c "/usr/bin/pg_dumpall -U fb|gzip -c > /filebin_db.sql.gz";
2019-12-19 00:07:00 +00:00
docker cp filebin_db:/filebin_db.sql.gz /tmp/;
2019-12-18 18:39:33 +00:00
docker exec filebin_db bash -c "rm /filebin_db.sql.gz";
```
## Building
Steps:
* Clone to local `build/` folder which is later added
* Build image
* Push to registry or use locally
Call `local_build.sh` and export `FB_VERSION=$versionTag` before, e.g. `FB_VERSION=3.6.2`.