Skip to content

Commit e663830

Browse files
committed
cleanup & ARG
1 parent 77784a3 commit e663830

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

12/Dockerfile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
FROM postgres:12 AS extension_builder
1+
ARG postgres_version=12
2+
3+
# extension builder
4+
FROM postgres:${postgres_version} AS extension_builder
25

3-
# Already download extension code
46
RUN cd / && mkdir external_extensions && mkdir /external_extensions/sequential-uuids
57
COPY lib/sequential-uuids/ /external_extensions/sequential-uuids/
68
WORKDIR /external_extensions/sequential-uuids/
79

8-
# additional: change sources.list, but postgres source is still slow. don't need if proxy is used.
9-
# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free" > /etc/apt/sources.list
10-
# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free" >> /etc/apt/sources.list
11-
# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free" >> /etc/apt/sources.list
12-
# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free" >> /etc/apt/sources.list
13-
14-
1510
RUN apt-get update && apt install build-essential libicu-dev postgresql-server-dev-all -y --no-install-recommends
1611
RUN make clean && make install
1712

18-
FROM postgres:12
13+
# main image
14+
FROM postgres:${postgres_version}
15+
16+
ARG pg_version_in_path=12
1917

2018
LABEL maintainer="[email protected]"
2119

2220
# run find / -name 'sequential_uuids*' to find newly compiled files and copy to next stage
23-
COPY --from=extension_builder /usr/lib/postgresql/12/lib /usr/lib/postgresql/12/lib
24-
COPY --from=extension_builder /usr/share/postgresql/12/extension /usr/share/postgresql/12/extension
21+
COPY --from=extension_builder /usr/lib/postgresql/${pg_version_in_path}/lib /usr/lib/postgresql/${pg_version_in_path}/lib
22+
COPY --from=extension_builder /usr/share/postgresql/${pg_version_in_path}/extension /usr/share/postgresql/${pg_version_in_path}/extension
2523

2624
# ref: https://github.com/docker-library/postgres/issues/340
2725

13/Dockerfile

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
FROM postgres:13 AS extension_builder
1+
ARG postgres_version=13
2+
3+
# extension builder
4+
FROM postgres:${postgres_version} AS extension_builder
25

3-
# Already download extension code
46
RUN cd / && mkdir external_extensions && mkdir /external_extensions/sequential-uuids
57
COPY lib/sequential-uuids/ /external_extensions/sequential-uuids/
68
WORKDIR /external_extensions/sequential-uuids/
79

8-
# additional: change sources.list, but postgres source is still slow. don't need if proxy is used.
9-
# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free" > /etc/apt/sources.list
10-
# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free" >> /etc/apt/sources.list
11-
# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free" >> /etc/apt/sources.list
12-
# RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free" >> /etc/apt/sources.list
13-
14-
1510
RUN apt-get update && apt install build-essential libicu-dev postgresql-server-dev-all -y --no-install-recommends
1611
RUN make clean && make install
1712

18-
FROM postgres:13
13+
# main image
14+
FROM postgres:${postgres_version}
15+
16+
ARG pg_version_in_path=13
1917

2018
LABEL maintainer="[email protected]"
2119

2220
# run find / -name 'sequential_uuids*' to find newly compiled files and copy to next stage
23-
COPY --from=extension_builder /usr/lib/postgresql/13/lib /usr/lib/postgresql/13/lib
24-
COPY --from=extension_builder /usr/share/postgresql/13/extension /usr/share/postgresql/13/extension
21+
COPY --from=extension_builder /usr/lib/postgresql/${pg_version_in_path}/lib /usr/lib/postgresql/${pg_version_in_path}/lib
22+
COPY --from=extension_builder /usr/share/postgresql/${pg_version_in_path}/extension /usr/share/postgresql/${pg_version_in_path}/extension
2523

2624
# ref: https://github.com/docker-library/postgres/issues/340
2725

2826
# after in sql:
2927
# CREATE EXTENSION sequential_uuids;
30-
31-

0 commit comments

Comments
 (0)