hedgedoc / container

HedgeDoc container image resources
https://docs.hedgedoc.org/setup/docker/
196 stars 52 forks source link

BuildKit/buildx required for building docker images (with ansible) #417

Closed christian-heusel closed 1 year ago

christian-heusel commented 1 year ago

The --platform=$BUILDPLATFORM breaks the build for regular (non buildx) docker-compose

https://github.com/hedgedoc/container/blob/4b8a7d4b094fe7ef7e052d528abb045b24b82bd3/debian/Dockerfile#L1

Error is:

$ docker-compose build
database uses an image, skipping
Building app
Step 1/43 : FROM --platform=$BUILDPLATFORM node:16.19.1-bullseye-slim@sha256:15ea844ec458ab40d10cd469352b86d82e16c3919fd1660bbfbec565fb6853a5 AS builder
ERROR: Service 'app' failed to build: failed to parse platform : "" is an invalid component of "": platform specifier component must match "^[A-Za-z0-9_-]+$": invalid argument
christian-heusel commented 1 year ago

This especially breaks for me because ansibles community.docker.docker_compose module uses regular docker compose (?) apparently.

christian-heusel commented 1 year ago

Problem is introduced in https://github.com/hedgedoc/container/commit/217b903f7fb8fb0bf7f57d408c7f99a33e051ffa

christian-heusel commented 1 year ago

Also --mount in https://github.com/hedgedoc/container/commit/6893f0e28cd847088ae9fe728511d001eb073e00 causes this to fail

ErikMichelson commented 1 year ago

Yes, it's right that we rely on docker buildkit (buildx) now. If you want to build the container from source for yourself, you'll need something similar to:

- name: Build image
  shell: |
    docker buildx build ...

Otherwise keep in mind, that we have pre-built images that regularly get rebuilded (to receive base image updates): https://quay.io/repository/hedgedoc/hedgedoc?tab=tags

christian-heusel commented 1 year ago

Yes we do some small modifications to the hedgedoc sourcecode of only one could be upstreamed: https://github.com/FachschaftMathPhysInfo/hedgedoc/tree/1.9.7_guest https://github.com/FachschaftMathPhysInfo/hedgedoc/tree/1.9.7

But thank you for the input, I will have a look at your suggestion to use buildx directly.

ErikMichelson commented 1 year ago

Which of the modifications are you talking about? The guest user name or the login message?

For the login message, HedgeDoc 2 will provide a better UI where it will be possible to customize more content.

The guest user name thing sounds interesing and I absolutely see your use-case, however as HedgeDoc 1.x is in "maintenance only", we won't introduce such a config option. Anyway you could create an issue for that for HedgeDoc 2 if you're interested in that.

christian-heusel commented 1 year ago

Which of the modifications are you talking about? The guest user name or the login message?

I just referenced our modifications because that hinders us from using the upstream docker image (which obviously would also solve the problem) 😄 Should have been more clear on that, sorry!

For the login message, HedgeDoc 2 will provide a better UI where it will be possible to customize more content.

Thats sounds great!

The guest user name thing sounds interesing and I absolutely see your use-case, however as HedgeDoc 1.x is in "maintenance only", we won't introduce such a config option. Anyway you could create an issue for that for HedgeDoc 2 if you're interested in that.

We host one HedgeDoc instance behind a Kerberos Login and Users Automatically get their name like that. 😊 The way it is done currently with the hacked guest note is not so nice, but it would be great if HedgeDoc 2 would have something like that targeted at a more general usecase. 😄

christian-heusel commented 1 year ago

Thanks a lot for your help @ErikMichelson, I have now decided to with the solution you suggested! ❤️

- name: checkout the container repo
  ansible.builtin.git:
    repo: 'https://github.com/hedgedoc/container.git'
    dest: "/opt/docker/hedgedoc-container-build"

- name: build the containers
  ansible.builtin.shell: >
    docker buildx build
    --build-arg "VERSION={{ item.version }}"
    --build-arg "HEDGEDOC_REPOSITORY=https://github.com/FachschaftMathPhysInfo/hedgedoc.git"
    --file "/opt/docker/hedgedoc-container-build/debian/Dockerfile"
    --tag "local.image/fachschaftmathphysinfo/hedgedoc:{{ item.version }}"
    "/opt/docker/hedgedoc-container-build"
  with_items:
    - version: "1.9.7"
    - version: "1.9.7_guest"