#docker file
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
#COPY /tmp/build/beancount-gs/public/icons /tmp/build/beancount-gs/public/default_icons
RUN mkdir -p public/default_icons && cp -rn public/icons/* public/default_icons && ls -l public
RUN go build .
FROM python:latest as build_env
ENV PATH "/app/bin:$PATH"
RUN python3 -mvenv /app
WORKDIR /tmp/build
RUN git clone https://github.com/beancount/beancount
WORKDIR /tmp/build/beancount
ARG BEANCOUNT_VERSION
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
RUN cp -rn /app/public/default_icons/* /app/public/icons
ENV PATH "/app/bin:$PATH"
EXPOSE 80
CMD ["/app/beancount-gs", "-p", "80"]