优化docker镜像大小#23
This commit is contained in:
parent
19862e8e71
commit
8c8b635f2e
|
|
@ -1,15 +1,12 @@
|
|||
version: "3.9"
|
||||
services:
|
||||
app:
|
||||
container_name: beancount-gs
|
||||
image: xdbin/beancount-gs: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}:${dataPath:-/data/beancount}"
|
||||
- "${dataPath:-/data/beancount}/icons:/app/public/icons"
|
||||
- "${dataPath:-/data/beancount}/config:/app/config"
|
||||
version: "3.9"
|
||||
services:
|
||||
app:
|
||||
container_name: beancount-gs
|
||||
image: xdbin/beancount-gs:latest
|
||||
ports:
|
||||
- "10000:80"
|
||||
volumes:
|
||||
- "${dataPath:-/data/beancount}:${dataPath:-/data/beancount}"
|
||||
- "${dataPath:-/data/beancount}/icons:/app/public/icons"
|
||||
- "${dataPath:-/data/beancount}/config:/app/config"
|
||||
- "${dataPath:-/data/beancount}/bak:/app/bak"
|
||||
75
dockerfile
75
dockerfile
|
|
@ -1,23 +1,52 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM golang:1.17.3 AS builder
|
||||
|
||||
ENV GO111MODULE=on \
|
||||
GOPROXY=https://goproxy.cn,direct \
|
||||
GIN_MODE=release \
|
||||
PORT=80
|
||||
|
||||
WORKDIR /builder
|
||||
COPY . .
|
||||
COPY public/icons ./public/default_icons
|
||||
RUN go build .
|
||||
|
||||
FROM python:latest
|
||||
RUN pip3 install beancount -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder ./builder/public ./public
|
||||
COPY --from=builder ./builder/config ./config
|
||||
COPY --from=builder ./builder/template ./template
|
||||
COPY --from=builder ./builder/beancount-gs* ./
|
||||
|
||||
EXPOSE 80
|
||||
ARG BEANCOUNT_VERSION=2.3.5
|
||||
ARG GOLANG_VERSION=1.17.3
|
||||
|
||||
FROM golang:${GOLANG_VERSION} AS go_build_env
|
||||
|
||||
ENV GO111MODULE=on \
|
||||
GOPROXY=https://goproxy.cn,direct \
|
||||
GIN_MODE=release \
|
||||
CGO_ENABLED=0 \
|
||||
PORT=80
|
||||
|
||||
WORKDIR /tmp/build
|
||||
RUN git clone https://github.com/BaoXuebin/beancount-gs.git
|
||||
|
||||
WORKDIR /tmp/build/beancount-gs
|
||||
RUN mkdir -p public/default_icons && cp -rn public/icons/* public/default_icons
|
||||
|
||||
RUN go build .
|
||||
|
||||
FROM python:latest as build_env
|
||||
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
|
||||
COPY --from=go_build_env /tmp/build/beancount-gs /app
|
||||
|
||||
# volumes 挂载目录会导 /app/public/icons 中的图标被覆盖,这里将默认图标在挂载后重新拷贝图标
|
||||
RUN cp -rn /app/public/default_icons/* /app/public/icons
|
||||
|
||||
ENV PATH "/app/bin:$PATH"
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["/app/beancount-gs", "-p", "80"]
|
||||
Loading…
Reference in New Issue