-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (30 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
39 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
FROM ubuntu:22.04
# 设置环境变量
ENV DEBIAN_FRONTEND=noninteractive
ENV MONGODB_VERSION=8.0
ENV MONGODB_PACKAGE=mongodb-org
# 安装必要的工具
RUN apt-get update && apt-get install -y \
wget \
unzip \
curl \
gnupg \
systemctl \
supervisor \
openssl \
&& rm -rf /var/lib/apt/lists/*
# 添加 MongoDB GPG 密钥
RUN curl -fsSL https://www.mongodb.org/static/pgp/server-${MONGODB_VERSION}.asc | gpg -o /usr/share/keyrings/mongodb-server-${MONGODB_VERSION}.gpg --dearmor
# 添加 MongoDB 仓库
RUN echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-${MONGODB_VERSION}.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/${MONGODB_VERSION} multiverse" | tee /etc/apt/sources.list.d/mongodb-org-${MONGODB_VERSION}.list
# 安装 MongoDB
RUN apt-get update && apt-get install -y ${MONGODB_PACKAGE} \
&& rm -rf /var/lib/apt/lists/*
# 复制启动脚本
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
# 设置二进制文件执行权限
RUN chmod +x /usr/bin/mongod /usr/local/bin/entrypoint.sh
# 暴露端口
EXPOSE 8080
# 启动 Supervisor
CMD ["/usr/local/bin/entrypoint.sh"]