From e663830aab6f0b9b64499a6935ba94e0c7df3391 Mon Sep 17 00:00:00 2001 From: yuxt Date: Tue, 20 Oct 2020 23:21:56 +0800 Subject: [PATCH] cleanup & ARG --- 12/Dockerfile | 22 ++++++++++------------ 13/Dockerfile | 24 ++++++++++-------------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/12/Dockerfile b/12/Dockerfile index 60308db..7a4f733 100644 --- a/12/Dockerfile +++ b/12/Dockerfile @@ -1,27 +1,25 @@ -FROM postgres:12 AS extension_builder +ARG postgres_version=12 + +# extension builder +FROM postgres:${postgres_version} AS extension_builder -# Already download extension code RUN cd / && mkdir external_extensions && mkdir /external_extensions/sequential-uuids COPY lib/sequential-uuids/ /external_extensions/sequential-uuids/ WORKDIR /external_extensions/sequential-uuids/ -# additional: change sources.list, but postgres source is still slow. don't need if proxy is used. -# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free" > /etc/apt/sources.list -# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free" >> /etc/apt/sources.list -# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free" >> /etc/apt/sources.list -# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free" >> /etc/apt/sources.list - - RUN apt-get update && apt install build-essential libicu-dev postgresql-server-dev-all -y --no-install-recommends RUN make clean && make install -FROM postgres:12 +# main image +FROM postgres:${postgres_version} + +ARG pg_version_in_path=12 LABEL maintainer="yuxtonline@outlook.com" # run find / -name 'sequential_uuids*' to find newly compiled files and copy to next stage -COPY --from=extension_builder /usr/lib/postgresql/12/lib /usr/lib/postgresql/12/lib -COPY --from=extension_builder /usr/share/postgresql/12/extension /usr/share/postgresql/12/extension +COPY --from=extension_builder /usr/lib/postgresql/${pg_version_in_path}/lib /usr/lib/postgresql/${pg_version_in_path}/lib +COPY --from=extension_builder /usr/share/postgresql/${pg_version_in_path}/extension /usr/share/postgresql/${pg_version_in_path}/extension # ref: https://github.com/docker-library/postgres/issues/340 diff --git a/13/Dockerfile b/13/Dockerfile index 541adda..52ccf3a 100644 --- a/13/Dockerfile +++ b/13/Dockerfile @@ -1,31 +1,27 @@ -FROM postgres:13 AS extension_builder +ARG postgres_version=13 + +# extension builder +FROM postgres:${postgres_version} AS extension_builder -# Already download extension code RUN cd / && mkdir external_extensions && mkdir /external_extensions/sequential-uuids COPY lib/sequential-uuids/ /external_extensions/sequential-uuids/ WORKDIR /external_extensions/sequential-uuids/ -# additional: change sources.list, but postgres source is still slow. don't need if proxy is used. -# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free" > /etc/apt/sources.list -# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free" >> /etc/apt/sources.list -# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free" >> /etc/apt/sources.list -# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free" >> /etc/apt/sources.list - - RUN apt-get update && apt install build-essential libicu-dev postgresql-server-dev-all -y --no-install-recommends RUN make clean && make install -FROM postgres:13 +# main image +FROM postgres:${postgres_version} + +ARG pg_version_in_path=13 LABEL maintainer="yuxtonline@outlook.com" # run find / -name 'sequential_uuids*' to find newly compiled files and copy to next stage -COPY --from=extension_builder /usr/lib/postgresql/13/lib /usr/lib/postgresql/13/lib -COPY --from=extension_builder /usr/share/postgresql/13/extension /usr/share/postgresql/13/extension +COPY --from=extension_builder /usr/lib/postgresql/${pg_version_in_path}/lib /usr/lib/postgresql/${pg_version_in_path}/lib +COPY --from=extension_builder /usr/share/postgresql/${pg_version_in_path}/extension /usr/share/postgresql/${pg_version_in_path}/extension # ref: https://github.com/docker-library/postgres/issues/340 # after in sql: # CREATE EXTENSION sequential_uuids; - -