fix: multiple improvements in docker image

* Reduce image size again, to 894MB
* Adjust permissions and remove need to run xhost
* Run appflowy as unprivileged user
* Add README file for more information
This commit is contained in:
Pablo Castellano 2022-02-23 11:59:35 +01:00
parent b8a4897056
commit 0b2bb33b73
2 changed files with 28 additions and 15 deletions

View File

@ -6,7 +6,7 @@ RUN pacman -Syu --needed --noconfirm git xdg-user-dirs
# makepkg user and workdir # makepkg user and workdir
ARG user=makepkg ARG user=makepkg
ENV PATH="/home/makepkg/.pub-cache/bin:/home/makepkg/.local/flutter/bin:/home/makepkg/.local/flutter/bin/cache/dart-sdk/bin:${PATH}" ENV PATH="/home/$user/.pub-cache/bin:/home/$user/.local/flutter/bin:/home/$user/.local/flutter/bin/cache/dart-sdk/bin:${PATH}"
RUN useradd --system --create-home $user \ RUN useradd --system --create-home $user \
&& echo "$user ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/$user && echo "$user ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/$user
USER $user USER $user
@ -15,9 +15,7 @@ WORKDIR /home/$user
# Install yay # Install yay
RUN git clone https://aur.archlinux.org/yay.git \ RUN git clone https://aur.archlinux.org/yay.git \
&& cd yay \ && cd yay \
&& makepkg -sri --needed --noconfirm \ && makepkg -sri --needed --noconfirm
&& cd \
&& rm -rf .cache yay
RUN yay -S --noconfirm curl base-devel sqlite openssl clang cmake ninja pkg-config gtk3 unzip RUN yay -S --noconfirm curl base-devel sqlite openssl clang cmake ninja pkg-config gtk3 unzip
RUN xdg-user-dirs-update RUN xdg-user-dirs-update
@ -40,21 +38,25 @@ cargo make -p production-linux-x86 appflowy-linux
CMD ["/home/makepkg/appflowy/frontend/app_flowy/build/linux/x64/release/bundle/app_flowy"] CMD ["/home/makepkg/appflowy/frontend/app_flowy/build/linux/x64/release/bundle/app_flowy"]
################# #################
FROM archlinux/archlinux:base-devel FROM archlinux/archlinux
RUN pacman -Syy RUN pacman -Syy && \
RUN pacman -Syu --needed --noconfirm xdg-user-dirs pacman -Syu --needed --noconfirm xdg-user-dirs && \
pacman -Scc --noconfirm
RUN xdg-user-dirs-update RUN xdg-user-dirs-update
ARG user=makepkg
RUN useradd --system --create-home $user \
&& echo "$user ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/$user
USER $user
WORKDIR /home/$user
COPY --from=builder /usr/sbin/yay /usr/sbin/yay COPY --from=builder /usr/sbin/yay /usr/sbin/yay
RUN yay -S --noconfirm gtk3 RUN yay -S --noconfirm gtk3
COPY --from=builder /home/makepkg/appflowy/frontend/app_flowy/build/linux/x64/release/bundle ./AppFlowy ARG user=appflowy
ARG uid=1000
ARG gid=1000
CMD ["/home/makepkg/AppFlowy/app_flowy"] RUN groupadd --gid $gid appflowy
RUN useradd --create-home --uid $uid --gid $gid $user
USER $user
WORKDIR /home/$user
COPY --from=builder /home/makepkg/appflowy/frontend/app_flowy/build/linux/x64/release/bundle/ .
CMD ["./app_flowy"]

View File

@ -0,0 +1,11 @@
# Docker image
Build AppFlowy docker image using the following command:
```
docker-compose build --build-arg uid=$(id -u) --build-arg gid=$(id -g)
```
For more information, check out our documentation:
https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/installing-with-docker