-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (51 loc) · 2.07 KB
/
Dockerfile
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
FROM golang:1.20-bullseye as stage-script-build
WORKDIR /opt/behemoth
COPY ./apps/libs/exec_scripts .
ARG GOPROXY=https://goproxy.io
ENV GO111MODULE=on
ENV CGO_ENABLED=0
ENV GOOS=linux
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/go/pkg/mod \
go mod download -x
RUN go build -o behemoth-cli .
FROM python:3.11.9-bullseye
ARG DEPENDENCIES=" \
ca-certificates \
curl \
libssl-dev \
locales \
vim"
ARG APT_MIRROR=http://mirrors.ustc.edu.cn
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=behemoth \
sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
&& rm -f /etc/apt/apt.conf.d/docker-clean \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& apt-get update \
&& apt-get -y install --no-install-recommends ${DEPENDENCIES} \
&& mkdir -p /root/.ssh/ \
&& echo "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null" > /root/.ssh/config \
&& echo "set mouse-=a" > ~/.vimrc \
&& echo "no" | dpkg-reconfigure dash \
&& echo "zh_CN.UTF-8" | dpkg-reconfigure locales \
&& sed -i "s@# export @export @g" ~/.bashrc \
&& sed -i "s@# alias @alias @g" ~/.bashrc \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/behemoth
ADD . .
RUN echo > /opt/behemoth/config.yml
ARG PIP_MIRROR=https://pypi.tuna.tsinghua.edu.cn/simple
RUN --mount=type=cache,target=/root/.cache,sharing=locked,id=behemoth \
--mount=type=bind,source=poetry.lock,target=/opt/behemoth/poetry.lock \
--mount=type=bind,source=pyproject.toml,target=/opt/behemoth/pyproject.toml \
set -ex \
&& python3 -m venv /opt/py3 \
&& pip install poetry -i ${PIP_MIRROR} \
&& poetry config virtualenvs.create false \
&& . /opt/py3/bin/activate \
&& poetry install
COPY --from=stage-script-build /opt/behemoth/behemoth-cli /opt/behemoth/apps/libs/exec_scripts/behemoth-cli
RUN chmod +x ./entrypoint.sh
ENV LANG=zh_CN.UTF-8
EXPOSE 9988
CMD ["./entrypoint.sh"]