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