From e9e5b15d39d590bdd725ee9cae5e7ad2c28d45cd Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Wed, 16 Jan 2019 11:56:58 +0100 Subject: [PATCH] Fix #614: added alternative funkwhale/all-in-one docker image --- .gitlab-ci.yml | 30 ++++++++++- changes/changelog.d/614.enhancement | 1 + changes/notes.rst | 13 +++++ docs/installation/docker.rst | 77 ++++++++++++++++++++++++++++- 4 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 changes/changelog.d/614.enhancement diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e34164930..4182ac853 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,8 @@ variables: IMAGE_NAME: funkwhale/funkwhale IMAGE: $IMAGE_NAME:$CI_COMMIT_REF_NAME - IMAGE_LATEST: $IMAGE_NAME:latest + ALL_IN_ONE_IMAGE_NAME: funkwhale/all-in-one + ALL_IN_ONE_IMAGE: $ALL_IN_ONE_IMAGE_NAME:$CI_COMMIT_REF_NAME PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache" PYTHONDONTWRITEBYTECODE: "true" REVIEW_DOMAIN: preview.funkwhale.audio @@ -201,6 +202,7 @@ build_front: - tags@funkwhale/funkwhale - master@funkwhale/funkwhale - develop@funkwhale/funkwhale + tags: - docker @@ -245,6 +247,32 @@ docker_release: tags: - docker-build +docker_all_in_one_release: + stage: deploy + image: bash + variables: + ALL_IN_ONE_REF: master + ALL_IN_ONE_ARTIFACT_URL: https://github.com/thetarkus/docker-funkwhale/archive/$ALL_IN_ONE_REF.zip + BUILD_PATH: all_in_one + before_script: + - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD + - (if [ "$CI_COMMIT_REF_NAME" == "develop" ]; then ./scripts/set-api-build-metadata.sh $(echo $CI_COMMIT_SHA | cut -c 1-8); fi); + script: + - wget $ALL_IN_ONE_ARTIFACT_URL -O all_in_one.zip + - unzip -o all_in_one.zip -d tmpdir + - mv tmpdir/docker-funkwhale-$ALL_IN_ONE_REF $BUILD_PATH && rmdir tmpdir + - cp -r api $BUILD_PATH/src/api + - cp -r front $BUILD_PATH/src/front + - cd $BUILD_PATH + - ./scripts/download-nginx-template.sh src/ $CI_COMMIT_REF_NAME + - docker build -t $ALL_IN_ONE_IMAGE . + - docker push $ALL_IN_ONE_IMAGE + only: + - develop@funkwhale/funkwhale + - tags@funkwhale/funkwhale + tags: + - docker-build + build_api: # Simply publish a zip containing api/ directory stage: deploy diff --git a/changes/changelog.d/614.enhancement b/changes/changelog.d/614.enhancement new file mode 100644 index 000000000..359fd1905 --- /dev/null +++ b/changes/changelog.d/614.enhancement @@ -0,0 +1 @@ +Added alternative funkwhale/all-in-one docker image (#614) diff --git a/changes/notes.rst b/changes/notes.rst index 79e5158b1..70b4df452 100644 --- a/changes/notes.rst +++ b/changes/notes.rst @@ -184,3 +184,16 @@ and replace the ``location /api/`` and `location /` blocks by the following snip Replace ``${FUNKWHALE_FRONTEND_PATH}`` by the corresponding variable from your .env file, which should be ``/srv/funkwhale/front/dist`` by default, then reload your nginx process with ``sudo systemctl reload nginx``. + + +Alternative docker deployment method +------------------------------------ + +Thanks to the awesome done by @thetarkus at https://github.com/thetarkus/docker-funkwhale, +we're now able to provide an alternative and easier Docker deployment method! + +In contrast with our current, multi-container offer, this method integrates +all Funkwhale processes and services (database, redis, etc.) into a single, easier to deploy container. + +Both method will coexist in parallel, as each one has pros and cons. You can learn more +about this exciting new deployment option by visiting https://docs.funkwhale.audio/installation/docker.html! diff --git a/docs/installation/docker.rst b/docs/installation/docker.rst index 8491f7f05..a63ffee90 100644 --- a/docs/installation/docker.rst +++ b/docs/installation/docker.rst @@ -1,8 +1,83 @@ Docker installation -==================== +=================== Docker is the easiest way to get a Funkwhale instance up and running. +We support two types of Docker deployments: + +- :ref:`Mono-container `: all processes live in the same container (database, nginx, redis, etc.). It's easier to deploy and to integrate with container management systems like Portainer. However, it's not possible to scale this type of deployment on multiple servers. +- :ref:`Multi-container `: each process lives in a dedicated container. This setup is more involved but also more flexible and scalable. + +.. _docker-mono-container: + +Mono-container installation +--------------------------- + +.. note:: + + This installation method was contributed by @thetarkus, at https://github.com/thetarkus/docker-funkwhale + +First, ensure you have `Docker `_ installed. + +Then set up a directory for your data:: + + mkdir /srv/funkwhale + cd /srv/funkwhale + +Export the version you want to deploy: + +.. parsed-literal:: + + export FUNKWHALE_VERSION="|version|" + +Create an env file to store a few important configuration options: + +.. code-block:: shell + + touch .env + echo "FUNKWHALE_HOSTNAME=yourdomain.funkwhale" >> .env + echo "FUNKWHALE_PROTOCOL=https" >> .env # or http + echo "DJANGO_SECRET_KEY=$(openssl rand -hex 45)" >> .env # generate and store a secure secret key for your instance + +Then start the container: + +.. code-block:: shell + + docker run \ + --name=funkwhale \ + --restart=unless-stopped \ + --env-file=/srv/funkwhale/.env \ + -v /srv/funkwhale/data:/data \ + -v /path/to/your/music/dir:/music:ro \ + -e PUID=$UID \ + -e PGID=$GID \ + -p 5000:80 \ + -d \ + funkwhale/all-in-one:$FUNKWHALE_VERSION + +.. note:: + + - ``-e PUID`` and ``-e PGID`` are optional but useful to prevent permission issues with docker volumes + - ``-v /path/to/your/music/dir`` should point to a path on your host were is located music you want to import in your Funkwhale instance. You can safely remove the volume if you don't want to import music that way. + +Your container should start in the background, and your instance be available at ``yourip:5000`` shortly. + +You will need an admin account to login and manage your account, create one using the following command: ``docker exec -it funkwhale manage createsuperuser`` + +Useful commands: + +- You can examine the logs by running ``docker logs -f --tail=50 funkwhale`` +- You can start and stop your instance using ``docker start funkwhale`` and ``docker stop funkwhale``, respectively +- To have a better idea of the resource usage of your instance (CPU, memory), run ``docker stats funkwhale`` + + + + +.. _docker-multi-container: + +Multi-container installation +---------------------------- + First, ensure you have `Docker `_ and `docker-compose `_ installed. Download the sample docker-compose file: