我想自己构建bitnami postgresql容器(我想添加一些自定义功能,我想将zhparser插件添加到postgresql容器中),我面临的问题是,从官方地址下载包是如此之低(我已经等了几个小时),似乎不可能完成构建如果使用官方地址获取包,是否有可能在docker构建阶段使用镜像地址?这样我就可以从镜像地址下载,以加快构建过程。这是Dockefile:
FROM docker.io/bitnami/minideb:bullseye
ENV HOME="/"
OS_ARCH="amd64"
OS_FLAVOUR="debian-11"
OS_NAME="linux"
ARG EXTRA_LOCALES=""
ARG WITH_ALL_LOCALES="no"
COPY prebuildfs /
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Install required system packages and dependencies
RUN install_packages acl ca-certificates curl gzip libbsd0 libbz2-1.0 libc6 libedit2 libffi7 libgcc-s1 libgmp10 libgnutls30 libhogweed6 libicu67 libidn2-0 libldap-2.4-2 liblz4-1 liblzma5 libmd0 libncurses6 libnettle8 libp11-kit0 libpcre3 libreadline8 libsasl2-2 libsqlite3-0 libssl1.1 libstdc++6 libtasn1-6 libtinfo6 libunistring2 libuuid1 libxml2 libxslt1.1 libzstd1 locales procps tar zlib1g
RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "gosu" "1.14.0-152" --checksum 0c751c7e2ec0bc900a19dbec0306d6294fe744ddfb0fa64197ba1a36040092f0
RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "postgresql" "13.7.0-155" --checksum 0aeb44b6993a10dd3915599405c871d438509ffbb818ff548b644c627b9dd1c0
RUN apt-get update && apt-get upgrade -y &&
rm -r /var/lib/apt/lists /var/cache/apt/archives
RUN chmod g+rwX /opt/bitnami
RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8
RUN update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX &&
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales
RUN echo 'en_GB.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen
RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen
COPY rootfs /
RUN /opt/bitnami/scripts/postgresql/postunpack.sh
RUN /opt/bitnami/scripts/locales/add-extra-locales.sh
ENV APP_VERSION="13.7.0"
BITNAMI_APP_NAME="postgresql"
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"
NSS_WRAPPER_LIB="/opt/bitnami/common/lib/libnss_wrapper.so"
PATH="/opt/bitnami/common/bin:/opt/bitnami/postgresql/bin:$PATH"
VOLUME [ "/bitnami/postgresql", "/docker-entrypoint-initdb.d", "/docker-entrypoint-preinitdb.d" ]
EXPOSE 5432
USER 1001
ENTRYPOINT [ "/opt/bitnami/scripts/postgresql/entrypoint.sh" ]
CMD [ "/opt/bitnami/scripts/postgresql/run.sh" ]
最后发现可以使用镜像地址,只需添加源代码。列出并放置这些内容(用不同的位置替换镜像地址):
deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb http://mirrors.aliyun.com/debian-security buster/updates main
deb-src http://mirrors.aliyun.com/debian-security buster/updates main
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
然后添加源。如下所示:
FROM docker.io/bitnami/minideb:bullseye
ADD sources.list /etc/apt/