From 1de382ff186b571a31e10797ce83a50634d32827 Mon Sep 17 00:00:00 2001 From: que <1131692+trover@user.noreply.gitee.com> Date: Thu, 4 Jul 2024 17:32:16 +0800 Subject: [PATCH] =?UTF-8?q?:arrow=5Fup:=20:wrench:=20=E6=9B=B4=E6=96=B0pyt?= =?UTF-8?q?hon=E7=89=88=E6=9C=AC=E8=87=B33.7.16=20=20=E4=BF=AE=E6=94=B9Doc?= =?UTF-8?q?kerfile=E6=89=93=E5=8C=85=E6=B5=81=E7=A8=8B=EF=BC=8C=E5=87=8F?= =?UTF-8?q?=E5=B0=8F=E5=8C=85=E4=BD=93=E7=A7=AF=EF=BC=9B=E4=BF=AE=E6=94=B9?= =?UTF-8?q?docker-compose=E5=90=AF=E5=8A=A8=E8=84=9A=E6=9C=AC=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=EF=BC=8C=E4=BF=AE=E6=94=B9README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 --- docker-compose.yml | 3 --- dockerfile | 48 +++++++++++++++++++++++++--------------------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index db60eb8..0acd412 100644 --- a/README.md +++ b/README.md @@ -65,9 +65,6 @@ services: image: xdbin/beancount-gs:${tag:-latest} ports: - "10000:80" - # volumes 挂载目录会导 /app/public/icons 中的图标被覆盖,这里将默认图标在挂载后重新拷贝图标 - command: > - sh -c "cp -rn /app/public/default_icons/* /app/public/icons && ./beancount-gs -p 80" volumes: - "${dataPath:-/data/beancount}:/data/beancount" - "${dataPath:-/data/beancount}/icons:/app/public/icons" diff --git a/docker-compose.yml b/docker-compose.yml index e9320d1..442529c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,6 @@ services: image: xdbin/beancount-gs:${tag:-latest} ports: - "10000:80" - # volumes 挂载目录会导 /app/public/icons 中的图标被覆盖,这里将默认图标在挂载后重新拷贝图标 - command: > - sh -c "cp -rn /app/public/default_icons/* /app/public/icons && ./beancount-gs -p 80" volumes: - "${dataPath:-/data/beancount}:/data/beancount" - "${dataPath:-/data/beancount}/icons:/app/public/icons" diff --git a/dockerfile b/dockerfile index 2ed1d9f..7903c5d 100644 --- a/dockerfile +++ b/dockerfile @@ -1,15 +1,5 @@ -# 构建 beancount -FROM python:3.7.16 as beancount_builder -WORKDIR /build -ENV PATH "/app/bin:$PATH" -RUN python3 -mvenv /app -RUN wget https://github.com/beancount/beancount/archive/refs/tags/2.3.5.tar.gz -RUN tar -zxvf 2.3.5.tar.gz -RUN python3 -m pip install ./beancount-2.3.5 -i https://mirrors.aliyun.com/pypi/simple/ -RUN find /app -name __pycache__ -exec rm -rf -v {} + - # 构建 beancount-gs -FROM golang:1.17.3 AS go_builder +FROM golang:1.17.3-alpine AS go_builder ENV GO111MODULE=on \ GOPROXY=https://goproxy.cn,direct \ @@ -19,20 +9,34 @@ ENV GO111MODULE=on \ WORKDIR /build COPY . . -COPY public/icons ./public/default_icons +COPY public/icons /build/public/default_icons RUN go build . # 镜像 -FROM python:3.7.16-alpine - -COPY --from=beancount_builder /app /app +FROM python:3.11.9-alpine3.19 WORKDIR /app -COPY --from=go_builder /build/beancount-gs ./ -COPY --from=go_builder /build/template ./template -COPY --from=go_builder /build/config ./config -COPY --from=go_builder /build/public ./public -COPY --from=go_builder /build/logs ./logs -ENV PATH "/app/bin:$PATH" -EXPOSE 80 \ No newline at end of file +RUN echo "https://mirrors.aliyun.com/alpine/v3.16/main/" > /etc/apk/repositories \ + && echo "https://mirrors.aliyun.com/alpine/v3.16/community/" >> /etc/apk/repositories \ + && set -x \ + && apk update \ + && apk add --no-cache gcc musl-dev \ + && python3 -mvenv /app/beancount \ + && /app/beancount/bin/pip install --no-cache-dir beanquery -i https://mirrors.aliyun.com/pypi/simple/ \ + && apk del gcc musl-dev + +COPY --from=go_builder /build/beancount-gs /app +COPY --from=go_builder /build/template /app/template +COPY --from=go_builder /build/config /app/config +COPY --from=go_builder /build/public /app/public +COPY --from=go_builder /build/logs /app/logs + +ENV LANG=C.UTF-8 \ + SHELL=/bin/bash \ + PS1="\u@\h:\w \$ " \ + PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/bin" + +EXPOSE 80 + +ENTRYPOINT [ "/bin/sh", "-c", "cp -rn /app/public/default_icons/* /app/public/icons && /app/beancount-gs -p 80" ] \ No newline at end of file