mviereck / dockerfile-x11docker-deepin

3D desktop deepin from China
MIT License
33 stars 11 forks source link

Building the deepin lion docker image in an elegant way. #28

Closed hongyi-zhao closed 3 years ago

hongyi-zhao commented 3 years ago

I try to build the deepin desktop docker image with the following Dockerfile:

FROM debian

ENV DEBIAN_FRONTEND=noninteractive \
    TERM=xterm \
    LANG=en_US.utf8 \
    PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/games:/usr/games

COPY stable /usr/share/debootstrap/scripts/lion
RUN apt-get update && apt-get install -y debootstrap && \
    debootstrap --variant=minbase --no-check-gpg --arch=amd64 lion basicsystem http://packages.deepin.com/deepin/ && \
    apt-get install -y curl && \
    cd /tmp && curl -O -Lx socks5://127.0.0.1:18888 http://packages.deepin.com/deepin/pool/main/d/deepin-keyring/deepin-keyring_2020.03.13-1_all.deb && \
    dpkg -x deepin-keyring_2020.03.13-1_all.deb /basicsystem

    # The following form can't work either. 
    # curl -Lx socks5://127.0.0.1:18888 http://packages.deepin.com/deepin/pool/main/d/deepin-keyring/deepin-keyring_2020.03.13-1_all.deb | dpkg -x - /basicsystem

FROM scratch
LABEL maintainer='Hongyi Zhao <hongyi.zhao@gmail.com>'
COPY --from=0 /basicsystem /

RUN rm /bin/sh && \
    ln -s /bin/bash /bin/sh && \
    sed -i "s/mesg n/tty -s \&\& mesg n/" /root/.profile && \
    apt-get update && \
    apt --fix-broken -y install && \
    apt-get -y autoremove --purge && apt-get autoclean -y && apt-get clean -y

# choose a mirror
RUN echo "deb http://packages.deepin.com/deepin/ lion main non-free contrib" > /etc/apt/sources.list

# basics
RUN rm -rf /var/lib/apt/lists/* && \
    apt-get clean && \
    apt-get update && \
    apt-mark hold iptables && \
    apt-get dist-upgrade -y && \
    apt-get -y autoremove && \
    apt-get clean && \
    apt-get install -y \
    dbus-x11 \
    libxv1 \
    locales-all \
    mesa-utils \
    mesa-utils-extra \
    procps \
    psmisc

# deepin desktop
RUN apt-get install -y --no-install-recommends \
    dde \
    at-spi2-core \
    gnome-themes-standard \
    gtk2-engines-murrine \
    gtk2-engines-pixbuf \
    pciutils

# additional applications
RUN apt-get install -y \
    deepin-calculator \
    deepin-image-viewer \
    deepin-screenshot \
    deepin-system-monitor \
    deepin-terminal \
    deepin-movie \
    gedit \
    oneko \
    sudo \
    synaptic \
    apt-transport-https

# chinese fonts
RUN env DEBIAN_FRONTEND=noninteractive apt-get install -y \
    xfonts-wqy fonts-wqy-microhei fonts-wqy-zenhei

ENV DEBIAN_FRONTEND ''  
ENV TERM ''

The used image build command and the error are shown as below:

$ docker build --network host -f Dockerfiles/lion . -t deepin/lion
[...]
Processing triggers for libc-bin (2.28-10) ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   146  100   146    0     0   2027      0 --:--:-- --:--:-- --:--:--  2027
dpkg-deb: error: 'deepin-keyring_2020.03.13-1_all.deb' is not a Debian format archive
The command '/bin/sh -c rm /bin/sh &&     ln -s /bin/bash /bin/sh &&     apt-get update && apt-get install -y debootstrap &&     debootstrap --variant=minbase --no-check-gpg --arch=amd64 lion basicsystem http://packages.deepin.com/deepin/ &&     apt-get install -y curl &&     cd /tmp && curl -O -Lx socks5://127.0.0.1:18888 http://packages.deepin.com/deepin/pool/main/d/deepin-keyring/deepin-keyring_2020.03.13-1_all.deb &&     dpkg -x deepin-keyring_2020.03.13-1_all.deb /basicsystem' returned a non-zero code: 2

But I can run the corresponding command successfully from within the host's shell terminal as following:

$ curl -Lx socks5://127.0.0.1:18888 http://packages.deepin.com/deepin/pool/main/d/deepin-keyring/deepin-keyring_2020.03.13-1_all.deb | dpkg -x - path/to/store/keyring
or
$ curl -Lx socks5://127.0.0.1:18888 http://packages.deepin.com/deepin/pool/main/d/deepin-keyring/deepin-keyring_2020.03.13-1_all.deb -O
$ dpkg -x deepin-keyring_2020.03.13-1_all.deb path/to/store/keyring

Any hints for this problem?

Regards, HY

mviereck commented 3 years ago

I is confusing that you try to extract the archive with dpkg -x. I recommend to just download it in stage 0/debian (that seems to succeed), copy it to the deepin file system, and run dpkg -i in stage 1/deepin. Or, maybe even better than dpkg -i, use apt-get install -y ./deepin-keyring_2020.03.13-1_all.deb.

hongyi-zhao commented 3 years ago

I is confusing that you try to extract the archive with dpkg -x.

This is the best, cleanest and almost the only way for solving/installing the deepin-keyring package needed by deepin/scratch stage. See my following explanations.

I recommend to just download it in stage 0/debian (that seems to succeed), copy it to the deepin file system, and run dpkg -i in stage 1/deepin. Or, maybe even better than dpkg -i, use apt-get install -y ./deepin-keyring_2020.03.13-1_all.deb.

In the deepin/scratch stage, all the packages installed/available in the debian stage will be removed. OTOH, the deepin-keyring package's installation require gnupg package which may be not available in the rootfs base system created by debootstrap and can't be installed before the deepin-keyring package has been installed. In this case, the deadlock loop is formed. As a result, the following error will occur if you try to install this package at the scratch stage of deepin image creation:

The following packages have unmet dependencies:
 deepin-keyring : Depends: gnupg but it is not installable
E: Unable to correct problems, you have held broken packages.

I've rewritten the Dockerfile as the following which can be used to create the image successfully:

FROM debian

# set proxy
ARG http_proxy
ARG https_proxy
ARG no_proxy
ENV http_proxy=$http_proxy \
    https_proxy=$http_proxy \
    no_proxy=$no_proxy \  
    DEBIAN_FRONTEND=noninteractive \
    TERM=xterm-256color \
    LANG=en_US.utf8 \
    PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/games:/usr/games

COPY stable /usr/share/debootstrap/scripts/lion
RUN sed -ri 's|^(deb(-src)?[[:blank:]]+https?://)([^/]+)|\1mirrors.ustc.edu.cn|' /etc/apt/sources.list && \
    apt-get update && apt-get install -y debootstrap curl && \
    debootstrap --variant=minbase --no-check-gpg --arch=amd64 lion rootfs http://packages.deepin.com/deepin/ && \
    curl -fsSL http://mirrors.ustc.edu.cn/deepin/pool/main/d/deepin-keyring/deepin-keyring_2020.03.13-1_all.deb | dpkg -x - /rootfs  

#Use the rootfs directory name based on the naming convention used by the Dockerfile here:
# https://github.com/debuerreotype/docker-debian-artifacts/blob/794e462d2825fb1ebb3d54ff5c93dd401cf28b9a/stable/Dockerfile   
FROM scratch
LABEL maintainer='Hongyi Zhao <hongyi.zhao@gmail.com>'
COPY --from=0 /rootfs /

RUN rm /bin/sh && \
    ln -s /bin/bash /bin/sh && \
    sed -i "s/mesg n/tty -s \&\& mesg n/" /root/.profile && \
    apt-get update && \
    apt --fix-broken -y install && \
    apt-get -y autoremove --purge && apt-get autoclean -y && apt-get clean -y && \
    find /var/lib/apt/lists -type f -delete && \
    find /var/cache -type f -delete

# choose a mirror
RUN echo "deb http://packages.deepin.com/deepin/ lion main non-free contrib" > /etc/apt/sources.list

# basics
RUN rm -rf /var/lib/apt/lists/* && \
    apt-get clean && \
    apt-get update && \
    apt-get dist-upgrade -y && \
    apt-get -y autoremove && \
    apt-get clean && \
    apt-get install -y gnupg \
    dbus-x11 \
    libxv1 \
    locales-all \
    mesa-utils \
    mesa-utils-extra \
    procps \
    psmisc

# deepin desktop
RUN apt-get install -y --no-install-recommends \
    dde \
    at-spi2-core \
    gnome-themes-standard \
    gtk2-engines-murrine \
    gtk2-engines-pixbuf \
    pciutils

# additional applications
RUN apt-get install -y \
    deepin-calculator \
    deepin-image-viewer \
    deepin-screenshot \
    deepin-system-monitor \
    deepin-terminal \
    deepin-movie \
    gedit \
    oneko \
    sudo \
    synaptic \
    apt-transport-https

# chinese fonts
RUN apt-get install -y \
    xfonts-wqy fonts-wqy-microhei fonts-wqy-zenhei

#https://github.com/mviereck/dockerfile-x11docker-deepin/issues/27#issuecomment-730034961
# unset proxy
ENV http_proxy= \
    https_proxy= \
    no_proxy= \
    DEBIAN_FRONTEND=

# If commented out the folloiwng line, see the issue dissussed here: 
#https://github.com/mviereck/dockerfile-x11docker-deepin/issues/17#issuecomment-723879088
#https://github.com/mviereck/dockerfile-x11docker-deepin/issues/17#issuecomment-723893642
CMD ["startdde"]

Build the image with the following command:

docker build --network host -f Dockerfiles/lion --build-arg http_proxy='' --build-arg https_proxy='' -t deepin/lion --no-cache .

There are still the following problems which I can't figure out the solution/fix/workaround:

Setting up lastore-daemon (0.14.6-1+comsta) ...
Failed to disable: No such file or directory.
Failed to connect to bus: No such file or directory
Try updating from "http://cdn.packages.deepin.com/deepin/tree/lastore" to "/var/lib/lastore/tree"

error: Server returned status 404: Not Found
pullRepo: exit status 1
E: gzip: invalid header
E: GenerateCategory failed EOF

mirrorsUrl: http://packages.deepin.com/mirrors/community.json
E: EOF
mviereck commented 3 years ago

error: Server returned status 404: Not Found

This is obviously a server error from deepin, or a wrong setup of lastore. You should report it there. Does the build fail?

Edit:

debootstrap --no-check-gpg

You run debootstrap with option --no-check-gpg. Does it fail without this option? It might help to install ca-certificates first.

curl -fsSL http://

If possible, try to use https instead. ca-certificates might help here, too.

hongyi-zhao commented 3 years ago

error: Server returned status 404: Not Found

This is obviously a server error from deepin, or a wrong setup of lastore. You should report it there. Does the build fail?

Anyway, the docker image can be created successfully. I just want to fix the problem. Thanks for your suggestion.

Edit:

debootstrap --no-check-gpg

You run debootstrap with option --no-check-gpg. Does it fail without this option?

Yes, it still can work smoothly. So, I decide to remove this option now.

It might help to install ca-certificates first.

This package has already included in the base debian system, see the following info:

Setting up ca-certificates (20200601~deb10u1) ...

curl -fsSL http://

If possible, try to use https instead.

Thanks. I agree with you.

ca-certificates might help here, too.

This package has been installed automatically in the debian stage as mentioned above.

mviereck commented 3 years ago

There is no lion in the repository anymore: http://packages.deepin.com/deepin/dists/ So I assume the build fails now?

hongyi-zhao commented 3 years ago

I don't know why they deleted this release from the repo and I haven't tried again since this issue has been filed here.

mviereck commented 3 years ago

I don't know why they deleted this release

I assume it is the same reason why they decided to outsource many packages to a community repository: copyright issues with several packages in the repository.

Recently, deepin community team has received feedback from users that there were some third-party commercial applications and redistribution authorization issues in the official repository. We responded immediately and carried out actions such as cleaning, removal, and migration

https://www.deepin.org/en/2020/11/19/statements/

hongyi-zhao commented 3 years ago

https://www.deepin.org/en/2020/11/19/statements/

Thanks for letting me know this.

mviereck commented 3 years ago

Thanks for letting me know this.

This is pretty new, I found it by your links about the apricot community edition. So I have to thank you.

Closing here because lion is not available anymore.