Skip to content

Commit 38cafc8

Browse files
committed
install postgres client for prod build
1 parent c767ad0 commit 38cafc8

File tree

3 files changed

+47
-9
lines changed

3 files changed

+47
-9
lines changed

docker/Dockerfile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
FROM node:24-slim AS base
22

3-
# 基础环境
4-
ENV PNPM_HOME="/home/node/.pnpm-store"
5-
ENV PATH="$PNPM_HOME:$PATH"
6-
7-
USER root
8-
9-
# 安装 pnpm
10-
RUN corepack enable && corepack prepare pnpm@latest --activate
11-
3+
# ================== postgres client install begin ==================
124
# 安装基础依赖
135
RUN apt-get update && apt-get install -y \
146
curl \
@@ -25,6 +17,14 @@ RUN curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmo
2517
RUN apt-get update && \
2618
apt-get install -y postgresql-client-18 && \
2719
rm -rf /var/lib/apt/lists/*
20+
# ================== postgres client install end ==================
21+
22+
# 基础环境
23+
ENV PNPM_HOME="/home/node/.pnpm-store"
24+
ENV PATH="$PNPM_HOME:$PATH"
25+
26+
# 安装 pnpm
27+
RUN corepack enable && corepack prepare pnpm@latest --activate
2828

2929
# 依赖安装阶段
3030
FROM base AS deps

docker/Dockerfile.prod

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
FROM node:24-slim
22

3+
# ================== postgres client install begin ==================
4+
# 安装基础依赖
5+
RUN apt-get update && apt-get install -y \
6+
curl \
7+
ca-certificates \
8+
gnupg \
9+
lsb-release \
10+
--no-install-recommends
11+
12+
# 导入 PostgreSQL 官方 GPG 密钥并设置存储库
13+
RUN curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg && \
14+
echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
15+
16+
# 安装 PostgreSQL 18 客户端
17+
RUN apt-get update && \
18+
apt-get install -y postgresql-client-18 && \
19+
rm -rf /var/lib/apt/lists/*
20+
# ================== postgres client install end ==================
21+
322
WORKDIR /app
423
ENV NODE_ENV=production
524

docker/Dockerfile.prod.standalone

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
FROM node:24-slim
22

3+
# ================== postgres client install begin ==================
4+
# 安装基础依赖
5+
RUN apt-get update && apt-get install -y \
6+
curl \
7+
ca-certificates \
8+
gnupg \
9+
lsb-release \
10+
--no-install-recommends
11+
12+
# 导入 PostgreSQL 官方 GPG 密钥并设置存储库
13+
RUN curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg && \
14+
echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
15+
16+
# 安装 PostgreSQL 18 客户端
17+
RUN apt-get update && \
18+
apt-get install -y postgresql-client-18 && \
19+
rm -rf /var/lib/apt/lists/*
20+
# ================== postgres client install end ==================
21+
322
WORKDIR /app
423
ENV NODE_ENV=production
524

0 commit comments

Comments
 (0)