|
| 1 | +# What is Friendica? |
| 2 | + |
| 3 | +Friendica is a decentralised communications platform that integrates social communication. |
| 4 | +Our platform links to independent social projects and corporate services. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +# How to use this image |
| 9 | + |
| 10 | +The images are designed to be used in a micro-service environment. |
| 11 | +There are two types of the image you can choose from. |
| 12 | + |
| 13 | +The `apache` tag contains a full Friendica installation including an apache web server. |
| 14 | +It is designed to be easy to use and gets you running pretty fast. |
| 15 | +This is also the default for the `latest` tag and version tags that are not further specified. |
| 16 | + |
| 17 | +The second option is a `fpm` container. |
| 18 | +It is based on the [php-fpm](https://hub.docker.com/_/php/) image and runs a fastCGI-Process that serves your Friendica server. |
| 19 | +To use this image it must be combined with any Webserver that can proxy the http requests to the FastCGI-port of the container. |
| 20 | + |
| 21 | +[](http://play-with-docker.com?stack=https://raw.githubusercontent.com/nupplaphil/friendica-docker/fec33c98be957436279b7074ca08068b18622627/stack.yml) |
| 22 | +(Admin-E-Mail: `[email protected]`) |
| 23 | + |
| 24 | +## Using the apache image |
| 25 | + |
| 26 | +You need at least one other mariadb/mysql-container to link it to Friendica. |
| 27 | + |
| 28 | +The apache image contains a webserver and exposes port 80. |
| 29 | +To start the container type: |
| 30 | + |
| 31 | +```console |
| 32 | +$ docker run -d -p 8080:80 --link some-mysql:mysql friendica/server |
| 33 | +``` |
| 34 | + |
| 35 | +Now you can access the Friendica installation wizard at http://localhost:8080/ from your host system. |
| 36 | + |
| 37 | +## Using the fpm image |
| 38 | + |
| 39 | +To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container. |
| 40 | +For fpm connection this container exposes port 9000. |
| 41 | +In most cases you might want use another container or your host as proxy. |
| 42 | +If you use your host you can address your Friendica container directly on port 9000. |
| 43 | +If you use another container, make sure that you add them to the same docker network (via `docker run --network <NAME> ...` or a `docker-compose` file). |
| 44 | +In both cases you don't want to map the fpm port to you host. |
| 45 | + |
| 46 | +```console |
| 47 | +$ docker run -d friendica/server:fpm |
| 48 | +``` |
| 49 | + |
| 50 | +As the fastCGI-Process is not capable of serving static files (style sheets, images, ...) the webserver needs access to these files. |
| 51 | +This can be achieved with the `volumes-from` option. |
| 52 | +You can find more information in the docker-compose section. |
| 53 | + |
| 54 | +## Using the cron job |
| 55 | + |
| 56 | +There are three options to enable the cron-job for Friendica: |
| 57 | + |
| 58 | +- Using the default Image and activate the cron-job (see [Installation](https://friendi.ca/resources/installation/), sector `Activating scheduled tasks`) |
| 59 | +- Using the default image (apache, fpm, fpm-alpine) and creating **two** container (one for cron and one for the main app) |
| 60 | +- Using one of the additional, prepared [`cron dockerfiles`](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/cron) |
| 61 | + |
| 62 | +## Possible Environment Variables |
| 63 | + |
| 64 | +**Friendica Settings** |
| 65 | +- `FRIENDICA_ADMIN_MAIL` E-Mail address of the administrator. |
| 66 | +- `FRIENDICA_TZ` The default localization of the Friendica server. |
| 67 | +- `FRIENDICA_LANG` The default language of the Friendica server. |
| 68 | +- `FRIENDICA_PHP_PATH` The path of the PHP binary. |
| 69 | +- `FRIENDICA_SITENAME` The Sitename of the Friendica server. |
| 70 | +- `FRIENDICA_NO_VALIDATION` If set to `true`, the URL and E-Mail validation will be disabled. |
| 71 | +- `FRIENDICA_DATA` If set to `true`, the fileystem will be used instead of the DB backend. |
| 72 | +- `FRIENDICA_DATA_DIR` The data directory of the Friendica server (Default: /var/www/data). |
| 73 | + |
| 74 | +**Friendica Logging** |
| 75 | +- `FRIENDICA_DEBUGGING` If set to `true`, the logging of Friendica is enabled. |
| 76 | +- `FRIENDICA_LOGFILE` (optional) The path to the logfile (Default: /var/www/friendica.log). |
| 77 | +- `FRIENDICA_LOGLEVEL` (optional) The loglevel to log (Default: notice). |
| 78 | + |
| 79 | +**Database** (**required at installation**) |
| 80 | +- `MYSQL_USERNAME` Username for the database user using mysql. |
| 81 | +- `MYSQL_USER` Username for the database user using mariadb. |
| 82 | +- `MYSQL_PASSWORD` Password for the database user using mysql / mariadb. |
| 83 | +- `MYSQL_DATABASE` Name of the database using mysql / mariadb. |
| 84 | +- `MYSQL_HOST` Hostname of the database server using mysql / mariadb. |
| 85 | +- `MYSQL_PORT` Port of the database server using mysql / mariadb (Default: `3306`) |
| 86 | + |
| 87 | +**Lock Driver (Redis)** |
| 88 | +- `REDIS_HOST` The hostname of the redis instance (in case of locking). |
| 89 | +- `REDIS_PORT` (optional) The port of the redis instance (in case of locking). |
| 90 | +- `REDIS_PW` (optional) The password for the redis instance (in case of locking). |
| 91 | +- `REDIS_DB` (optional) The database instance of the redis instance (in case of locking). |
| 92 | + |
| 93 | +**Develop/Release Candidat Settings** |
| 94 | +- `FRIENDICA_UPGRADE` If set to `true`, a develop or release candidat node will get updated at startup. |
| 95 | +- `FRIENDICA_REPOSITORY` If set, a custom repository will be chosen (Default: `friendica`) |
| 96 | +- `FRIENDICA_ADDONS_REPO` If set, a custom repository for the addons will be chosen (Default: `friendica`) |
| 97 | +- `FRIENDICA_VERSION` If set, a custom branch will be chosen (Default is based on the chosen image version) |
| 98 | +- `FRIENDICA_ADDONS` If set, a custom branch for the addons will be chosen (Default is based on the chosen image version) |
| 99 | + |
| 100 | +## Administrator account |
| 101 | + |
| 102 | +Because Friendica links the administrator account to a specific mail address, you **have** to set a valid address for `MAILNAME`. |
| 103 | + |
| 104 | +## Mail settings |
| 105 | + |
| 106 | +The binary `ssmtp` is used for the `mail()` support of Friendica. |
| 107 | + |
| 108 | +You have to set the `--hostname/-h` parameter correctly to use the right domainname for the `mail()` command. |
| 109 | + |
| 110 | +You have to set a valid SMTP-MTA for the `SMTP` environment variable to enable mail support in Friendica. |
| 111 | +A valid SMTP-MTA would be, for example, `mx.example.org`. |
| 112 | + |
| 113 | +The following environment variables are possible for the SMTP examples. |
| 114 | + |
| 115 | +- `SITENAME` The name of the Friendica node. (**required**) |
| 116 | +- `SMTP` Address of the SMTP Mail-Gateway. (**required**) |
| 117 | +- `SMTP_FROM` Sender user-part of the address. (Default: `no-reply` - e.g. [email protected]) |
| 118 | +- `SMTP_TLS` Use TLS for connecting the SMTP Mail-Gateway. (Default: empty) |
| 119 | +- `SMTP_STARTTLS` Use STARTTLS for connecting the SMTP Mail-Gateway. (Default: empty) |
| 120 | +- `SMTP_AUTH_USER` Username for the SMTP Mail-Gateway. (Default: empty) |
| 121 | +- `SMTP_AUTH_PASS` Password for the SMTP Mail-Gateway. (Default: empty) |
| 122 | +- `SMTP_AUTH_METHOD` Authentication method for the SMTP Mail-Gateway. (Default: empty/plain text) |
| 123 | + |
| 124 | +## Database settings |
| 125 | + |
| 126 | +You have to link a running database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup. |
| 127 | + |
| 128 | +## Persistent data |
| 129 | + |
| 130 | +The Friendica installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`. |
| 131 | +The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. |
| 132 | +That means your data is saved even if the container crashes, is stopped or deleted. |
| 133 | + |
| 134 | +To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder. |
| 135 | +To achieve this you need one volume for your database container and Friendica. |
| 136 | + |
| 137 | +Friendica: |
| 138 | + |
| 139 | +- `/var/www/html/` folder where all Friendica data lives |
| 140 | + |
| 141 | +```console |
| 142 | +$ docker run -d \ |
| 143 | + -v friendica-vol-1:/var/www/html \ |
| 144 | + friendica/server |
| 145 | +``` |
| 146 | + |
| 147 | +Database: |
| 148 | + |
| 149 | +- `/var/lib/mysql` MySQL / MariaDB Data |
| 150 | + |
| 151 | +```console |
| 152 | +$ docker run -d \ |
| 153 | + -v mysql-vol-1:/var/lib/mysql \ |
| 154 | + mariadb |
| 155 | +``` |
| 156 | + |
| 157 | +## Automatic installation |
| 158 | + |
| 159 | +The Friendica image supports auto configuration via environment variables. |
| 160 | +You can preconfigure everything that is asked on the install page on first run. |
| 161 | +To enable the automatic installation, there are two possibilities: |
| 162 | + |
| 163 | +### Environment Variables |
| 164 | + |
| 165 | +You have to set at least the following environment variables (others are optional). |
| 166 | + |
| 167 | +- `FRIENDICA_ADMIN_MAIL` E-Mail address of the administrator. |
| 168 | +- `MYSQL_USERNAME` or `MYSQL_USER` Username for the database user using mysql/mariadb. |
| 169 | +- `MYSQL_PASSWORD` Password for the database user using mysql / mariadb. |
| 170 | +- `MYSQL_DATABASE` Name of the database using mysql / mariadb. |
| 171 | +- `MYSQL_HOST` Hostname of the database server using mysql / mariadb. |
| 172 | + |
| 173 | +### Using a predefined config file |
| 174 | + |
| 175 | +You can create a `local.config.php` and `COPY` it to `/usr/src/config`. |
| 176 | +If no other environment variable is set, this `local.config.php` will get copied to the config path. |
| 177 | + |
| 178 | +# Docker Secrets |
| 179 | + |
| 180 | +More information can be found here https://docs.docker.com/engine/swarm/secrets/. |
| 181 | + |
| 182 | +As an alternative to passing sensitive information via environment variables, _FILE may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. |
| 183 | +In particular, this can be used to load passwords from Docker secrets stored in /run/secrets/<secret_name> files. |
| 184 | +For example: |
| 185 | + |
| 186 | +```yaml |
| 187 | +version: '3.2' |
| 188 | +services: |
| 189 | + db: |
| 190 | + image: mariadb |
| 191 | + restart: always |
| 192 | + volumes: |
| 193 | + - db:/var/lib/mysql/ |
| 194 | + environment: |
| 195 | + - MYSQL_DATABASE=friendica |
| 196 | + - MYSQL_USERNAME=friendica |
| 197 | + - MYSQL_PASSWORD_FILE=/run/secrets/mysql_password |
| 198 | + - MYSQL_RANDOM_ROOT_PASSWORD=yes |
| 199 | + secrets: |
| 200 | + - mysql_password |
| 201 | + app: |
| 202 | + image: friendica |
| 203 | + restart: always |
| 204 | + ports: |
| 205 | + - 8080:80 |
| 206 | + volumes: |
| 207 | + - friendica:/var/www/html |
| 208 | + environment: |
| 209 | + - MYSQL_HOST=db |
| 210 | + - MYSQL_USER=friendica |
| 211 | + - MYSQL_PASSWORD_FILE=/run/secrets/mysql_password |
| 212 | + - MYSQL_DATABASE=friendica |
| 213 | + |
| 214 | + - SITENAME=Friendica PWD Test Node |
| 215 | + - FRIENDICA_NO_VALIDATION=true |
| 216 | + hostname: friendica.local |
| 217 | + depends_on: |
| 218 | + - db |
| 219 | + secrets: |
| 220 | + - mysql_password |
| 221 | +volumes: |
| 222 | + db: |
| 223 | + friendica: |
| 224 | + |
| 225 | +secrets: |
| 226 | + mysql_password: |
| 227 | + file: ./mysql_password.txt # put mysql password to this file using docker-secrets to manage it |
| 228 | +``` |
| 229 | +Currently, this is only supported for `MYSQL_PASSWORD`. |
| 230 | + |
| 231 | +# Maintenance of the image |
| 232 | + |
| 233 | +## Updating to a newer version |
| 234 | + |
| 235 | +There are differences between the deveop (everything which ends with `-rc` or `-dev`) and the stable (the rest) branches. |
| 236 | + |
| 237 | +### Updating stable |
| 238 | + |
| 239 | +You have to pull the latest image from the hub (`docker pull friendica`). |
| 240 | +The stable branch gets checked at every startup and will get updated if no installation was found or a new image is used. |
| 241 | + |
| 242 | +### Updating develop |
| 243 | + |
| 244 | +You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/). |
| 245 | +Instead, the develop branch will get updated if no installation was found or the environment variable `FRIENDICA_UPGRADE` is set to `true`. |
| 246 | + |
| 247 | +It will clone the latest Friendica version and copy it to your working directory. |
| 248 | + |
| 249 | +# Running this image with docker-compose |
| 250 | + |
| 251 | +The easiest way to get a fully featured and functional setup is using a `docker-compose` file. |
| 252 | +There are too many different possibilities to setup your system, so here are only some examples what you have to look for. |
| 253 | + |
| 254 | +At first make sure you have chosen the right base image (fpm or apache) and added the features you wanted (see below). |
| 255 | +In every case you want to add a database container and docker volumes to get easy access to your persistent data. |
| 256 | +When you want your server reachable from the internet adding HTTPS-encryption is mandatory! |
| 257 | +See below for more information. |
| 258 | + |
| 259 | +## Base version - apache |
| 260 | + |
| 261 | +This version will use the apache image and add a mariaDB container. |
| 262 | +The volumes are set to keep your data persistent. |
| 263 | +This setup provides **no ssl encryption** and is intended to run behind a proxy. |
| 264 | + |
| 265 | +Make sure to set the variable `MYSQL_PASSWORD` before run this setup. |
| 266 | + |
| 267 | +```yaml |
| 268 | +version: '2' |
| 269 | +
|
| 270 | +services: |
| 271 | + db: |
| 272 | + image: mariadb |
| 273 | + restart: always |
| 274 | + volumes: |
| 275 | + - db:/var/lib/mysql |
| 276 | + environment: |
| 277 | + - MYSQL_USER=friendica |
| 278 | + - MYSQL_PASSWORD= |
| 279 | + - MYSQL_DATABASE=friendica |
| 280 | + - MYSQL_RANDOM_ROOT_PASSWORD=yes |
| 281 | +
|
| 282 | + app: |
| 283 | + image: friendica/server |
| 284 | + restart: always |
| 285 | + volumes: |
| 286 | + - friendica:/var/www/html |
| 287 | + ports: |
| 288 | + - "8080:80" |
| 289 | + environment: |
| 290 | + - MYSQL_HOST=db |
| 291 | + - MYSQL_USER=friendica |
| 292 | + - MYSQL_PASSWORD= |
| 293 | + - MYSQL_DATABASE=friendica |
| 294 | + |
| 295 | + hostname: friendica.local |
| 296 | + depends_on: |
| 297 | + - db |
| 298 | +
|
| 299 | +volumes: |
| 300 | + db: |
| 301 | + friendica: |
| 302 | +``` |
| 303 | + |
| 304 | +Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system. |
| 305 | + |
| 306 | +## Base version - FPM |
| 307 | + |
| 308 | +When using the FPM image you need another container that acts as web server on port 80 and proxies requests to the Friendica container. |
| 309 | +In this example a simple nginx container is combined with the Friendica-fpm image and a MariaDB database container. |
| 310 | +The data is stored in docker volumes. |
| 311 | +The nginx container also need access to static files from your Friendica installation. |
| 312 | +It gets access to all the volumes mounted to Friendica via the `volumes_from` option. |
| 313 | +The configuration for nginx is stored in the configuration file `nginx.conf` that is mounted into the container. |
| 314 | + |
| 315 | +An example can be found in the [examples section](https://github.com/friendica/docker/tree/master/.examples). |
| 316 | + |
| 317 | +As this setup does **not include encryption** it should to be run behind a proxy. |
| 318 | + |
| 319 | +Prerequisites for this example: |
| 320 | +- Make sure to set the variable `MYSQL_PASSWORD` before you run the setup. |
| 321 | +- Create a `nginx.conf` in the same directory as the docker-compose.yml file (take it from [example](https://github.com/friendica/docker/tree/master/.examples/docker-compose/with-traefik-proxy/mariadb-cron-smtp/fpm/web/nginx.conf)) |
| 322 | + |
| 323 | +```yaml |
| 324 | +version: '2' |
| 325 | +
|
| 326 | +services: |
| 327 | + db: |
| 328 | + image: mariadb |
| 329 | + restart: always |
| 330 | + volumes: |
| 331 | + - db:/var/lib/mysql |
| 332 | + environment: |
| 333 | + - MYSQL_USER=friendica |
| 334 | + - MYSQL_PASSWORD= |
| 335 | + - MYSQL_DATABASE=friendica |
| 336 | + - MYSQL_RANDOM_ROOT_PASSWORD=yes |
| 337 | +
|
| 338 | + app: |
| 339 | + image: friendica/server:fpm |
| 340 | + restart: always |
| 341 | + volumes: |
| 342 | + - friendica:/var/www/html |
| 343 | + environment: |
| 344 | + - MYSQL_HOST=db |
| 345 | + - MYSQL_USER=friendica |
| 346 | + - MYSQL_PASSWORD= |
| 347 | + - MYSQL_DATABASE=friendica |
| 348 | + |
| 349 | + hostname: friendica.local |
| 350 | + networks: |
| 351 | + - proxy-tier |
| 352 | + - default |
| 353 | +
|
| 354 | + web: |
| 355 | + image: nginx |
| 356 | + ports: |
| 357 | + - 8080:80 |
| 358 | + links: |
| 359 | + - app |
| 360 | + volumes: |
| 361 | + - ./nginx.conf:/etc/nginx/nginx.conf:ro |
| 362 | + restart: always |
| 363 | + networks: |
| 364 | + - proxy-tier |
| 365 | +
|
| 366 | +volumes: |
| 367 | + db: |
| 368 | + friendica: |
| 369 | +
|
| 370 | +networks: |
| 371 | + proxy-tier: |
| 372 | +``` |
| 373 | + |
| 374 | +Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system. |
| 375 | + |
| 376 | +# Questions / Issues |
| 377 | + |
| 378 | +If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue. |
0 commit comments