|
| 1 | +## ref: https://schneide.blog/2019/10/21/using-parameterized-docker-builds/ |
| 2 | +## https://pythonspeed.com/articles/multi-stage-docker-python/ |
| 3 | +## ref: https://www.server-world.info/en/note?os=CentOS_Stream_9&p=docker&f=1 |
| 4 | + |
| 5 | +#FROM centos:9 |
| 6 | +FROM quay.io/centos/centos:stream9 |
| 7 | + |
| 8 | +ARG BUILD_DATE |
| 9 | +ARG BUILD_ID=devel |
| 10 | +LABEL build=$BUILD_ID |
| 11 | + |
| 12 | +ENV container=docker |
| 13 | + |
| 14 | +## Install systemd |
| 15 | +## ref: https://linuxopsys.com/topics/install-systemd |
| 16 | +RUN yum groupinstall -y "Development Tools" && \ |
| 17 | + dnf install -y \ |
| 18 | + libcap-devel \ |
| 19 | + gperf \ |
| 20 | + glib2-devel \ |
| 21 | + jq \ |
| 22 | + which \ |
| 23 | + python3-pip |
| 24 | + |
| 25 | +## use --global option instead |
| 26 | +#ENV PIPX_HOME="/opt/pipx" |
| 27 | +#ENV PIPX_BIN_DIR="/usr/local/bin" |
| 28 | + |
| 29 | +## not necessary since /usr/local/bin is already in the PATH |
| 30 | +#ENV PATH="${PIPX_BIN_DIR}:${PATH}" |
| 31 | +RUN echo "PATH: ${PATH}" |
| 32 | +RUN echo "export PATH=$PATH" >> /etc/profile |
| 33 | +ENV PATH="/root/.local/bin:${PATH}" |
| 34 | + |
| 35 | +## ref: https://pipx.pypa.io/stable/installation/ |
| 36 | +RUN python3 -m pip install --user pipx jinja2 |
| 37 | + |
| 38 | +## not necessary since /usr/local/bin is already in PATH |
| 39 | +#RUN pipx ensurepath --global |
| 40 | +#RUN python3 -m pipx ensurepath |
| 41 | + |
| 42 | +#RUN pip install meson ninja jinja2 |
| 43 | +## ref: https://stackoverflow.com/questions/75608323/how-do-i-solve-error-externally-managed-environment-every-time-i-use-pip-3 |
| 44 | +## ref: https://github.com/pypa/pipx/issues/754#issuecomment-951162846 |
| 45 | +RUN pipx install --global meson ninja |
| 46 | +#RUN python3 -m pipx install --global meson ninja |
| 47 | + |
| 48 | +## Install systemd |
| 49 | +## ref: https://linuxopsys.com/topics/install-systemd |
| 50 | +## ref: https://stackoverflow.com/questions/48098671/build-with-docker-and-privileged#57077772 |
| 51 | +COPY ./install-systemd.sh /var/tmp/ |
| 52 | +RUN bash -x /var/tmp/install-systemd.sh |
| 53 | + |
| 54 | +RUN systemctl set-default multi-user.target |
| 55 | + |
| 56 | +# The machine-id should be generated when creating the container. This will be |
| 57 | +# done automatically if the file is not present, so let's delete it. |
| 58 | +RUN rm -f \ |
| 59 | + /etc/machine-id \ |
| 60 | + /var/lib/dbus/machine-id |
| 61 | + |
| 62 | +RUN echo "alias ll='ls -Fla'" >> ~/.bashrc |
| 63 | +RUN echo "alias la='ls -alrt'" >> ~/.bashrc |
| 64 | + |
| 65 | +# The host's cgroup filesystem need's to be mounted (read-only) in the |
| 66 | +# container. '/run', '/run/lock' and '/tmp' need to be tmpfs filesystems when |
| 67 | +# running the container without 'CAP_SYS_ADMIN'. |
| 68 | +# |
| 69 | +# NOTE: For running Debian stretch, 'CAP_SYS_ADMIN' still needs to be added, as |
| 70 | +# stretch's version of systemd is not recent enough. Buster will run just |
| 71 | +# fine without 'CAP_SYS_ADMIN'. |
| 72 | +#VOLUME [ "/sys/fs/cgroup" ] |
| 73 | +VOLUME ["/sys/fs/cgroup", "/tmp", "/run"] |
| 74 | + |
| 75 | +# A different stop signal is required, so systemd will initiate a shutdown when |
| 76 | +# running 'docker stop <container>'. |
| 77 | +STOPSIGNAL SIGRTMIN+3 |
| 78 | + |
| 79 | +## ref: https://unix.stackexchange.com/questions/276340/linux-command-systemctl-status-is-not-working-inside-a-docker-container |
| 80 | +CMD ["/sbin/init"] |
| 81 | +#CMD ["/usr/sbin/init"] |
| 82 | +#CMD ["/usr/lib/systemd/systemd"] |
0 commit comments