优化docker镜像大小#23
This commit is contained in:
parent
19862e8e71
commit
8c8b635f2e
|
|
@ -5,9 +5,6 @@ services:
|
||||||
image: xdbin/beancount-gs:latest
|
image: xdbin/beancount-gs:latest
|
||||||
ports:
|
ports:
|
||||||
- "10000:80"
|
- "10000:80"
|
||||||
# volumes 挂载目录会导 /app/public/icons 中的图标被覆盖,这里将默认图标在挂载后重新拷贝图标
|
|
||||||
command: >
|
|
||||||
sh -c "cp -rn /app/public/default_icons/* /app/public/icons && ./beancount-gs -p 80"
|
|
||||||
volumes:
|
volumes:
|
||||||
- "${dataPath:-/data/beancount}:${dataPath:-/data/beancount}"
|
- "${dataPath:-/data/beancount}:${dataPath:-/data/beancount}"
|
||||||
- "${dataPath:-/data/beancount}/icons:/app/public/icons"
|
- "${dataPath:-/data/beancount}/icons:/app/public/icons"
|
||||||
|
|
|
||||||
51
dockerfile
51
dockerfile
|
|
@ -1,23 +1,52 @@
|
||||||
# syntax=docker/dockerfile:1
|
ARG BEANCOUNT_VERSION=2.3.5
|
||||||
FROM golang:1.17.3 AS builder
|
ARG GOLANG_VERSION=1.17.3
|
||||||
|
|
||||||
|
FROM golang:${GOLANG_VERSION} AS go_build_env
|
||||||
|
|
||||||
ENV GO111MODULE=on \
|
ENV GO111MODULE=on \
|
||||||
GOPROXY=https://goproxy.cn,direct \
|
GOPROXY=https://goproxy.cn,direct \
|
||||||
GIN_MODE=release \
|
GIN_MODE=release \
|
||||||
|
CGO_ENABLED=0 \
|
||||||
PORT=80
|
PORT=80
|
||||||
|
|
||||||
WORKDIR /builder
|
WORKDIR /tmp/build
|
||||||
COPY . .
|
RUN git clone https://github.com/BaoXuebin/beancount-gs.git
|
||||||
COPY public/icons ./public/default_icons
|
|
||||||
|
WORKDIR /tmp/build/beancount-gs
|
||||||
|
RUN mkdir -p public/default_icons && cp -rn public/icons/* public/default_icons
|
||||||
|
|
||||||
RUN go build .
|
RUN go build .
|
||||||
|
|
||||||
FROM python:latest
|
FROM python:latest as build_env
|
||||||
RUN pip3 install beancount -i https://pypi.tuna.tsinghua.edu.cn/simple
|
ARG BEANCOUNT_VERSION
|
||||||
|
|
||||||
|
ENV PATH "/app/bin:$PATH"
|
||||||
|
RUN python3 -mvenv /app
|
||||||
|
|
||||||
|
WORKDIR /tmp/build
|
||||||
|
RUN git clone https://github.com/beancount/beancount
|
||||||
|
|
||||||
|
WORKDIR /tmp/build/beancount
|
||||||
|
RUN git checkout ${BEANCOUNT_VERSION}
|
||||||
|
|
||||||
|
RUN CFLAGS=-s pip3 install -U /tmp/build/beancount
|
||||||
|
|
||||||
|
RUN pip3 uninstall -y pip
|
||||||
|
|
||||||
|
RUN find /app -name __pycache__ -exec rm -rf -v {} +
|
||||||
|
|
||||||
|
FROM python:3.10-alpine
|
||||||
|
|
||||||
|
COPY --from=build_env /app /app
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder ./builder/public ./public
|
COPY --from=go_build_env /tmp/build/beancount-gs /app
|
||||||
COPY --from=builder ./builder/config ./config
|
|
||||||
COPY --from=builder ./builder/template ./template
|
# volumes 挂载目录会导 /app/public/icons 中的图标被覆盖,这里将默认图标在挂载后重新拷贝图标
|
||||||
COPY --from=builder ./builder/beancount-gs* ./
|
RUN cp -rn /app/public/default_icons/* /app/public/icons
|
||||||
|
|
||||||
|
ENV PATH "/app/bin:$PATH"
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["/app/beancount-gs", "-p", "80"]
|
||||||
Loading…
Reference in New Issue