michaelmob / docker-funkwhale

All-in-one funkwhale docker image.
92 stars 18 forks source link

Flexible build (to prepare for CI automated builds) #8

Closed agateblue closed 5 years ago

agateblue commented 5 years ago

This PR contains several changes:

  1. Docker cache improvements (to avoid reinstalling all the APK if only the configuration file are modified, for instance)
  2. Reduced the number of layers, by merging ENV instructions
  3. Use artifacts from context (via COPY) instead of downloading files from the network
  4. Use the official (and versionned) nginx template file

Let me elaborate a bit on 3 and 4, since those are the biggest changes.

COPY instead of ADD

When we'll build the image from CI, we won't necessarily have a download URL for the artifacts, because we'll be in the process of actually releasing them. Also, they will be available in the current filesystem, so downloading them is not needed.

To support this, I had to remove the ADD instructions, and use COPY on src/front and src/api instead. I've also provided a util script to do the download/unzipping job automatically, as shown in the updated readme.

One of the other benefits of using COPY on plain directories is that if we ever need to debug an issue, we can edit Funkwhale's source code locally and rebuild the image. That would not be possible if we had to download the artifacts.

Switch to official nginx template

This one was needed because the image will be built for various releases (and also for the develop branch). Since the nginx file evolves from release to release, we cannot rely on the hardcoded one to work with any version. To fix that, we now copy the nginx template file from context (as for the artifacts), and I've provided a small script to download the official template file and convert it to a working version for this image.

I've tried a local build, on the develop branch and it worked. If you are satisfied with this, we can merge and I'll work on the automatic build pipeline (which should be fairly easy).

Let me know if you have any question :)

agateblue commented 5 years ago

Here is the corresponding PR on Funkwhale side: https://dev.funkwhale.audio/funkwhale/funkwhale/merge_requests/539

And you can try the built image like that:

Start the container:

docker run \
  --rm \
  --name=funkwhale-test \
  -e PUID=1000 \
  -e PGID=1000 \
  -e FUNKWHALE_HOSTNAME=localhost \
  -p 3030:80 \
  funkwhale/all-in-one:614-all-in-one-docker-deployment

Create an admin user: docker exec -it funkwhale-test manage createsuperuser

Then visit http://localhost:3030 :)