Skip to content

Commit

Permalink
Back to debian based image
Browse files Browse the repository at this point in the history
  • Loading branch information
grostim authored Aug 19, 2019
1 parent 2bf535c commit 869ea2f
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# we use SOURCE_BRANCH to indicate the fava version.
ARG SOURCE_BRANCH=master
ARG FAVA_VERSION=${SOURCE_BRANCH}
ARG BEANCOUNT_VERSION=2.2.1
ARG NODE_BUILD_IMAGE=10.16.0-stretch
ARG PYTHON_DIR=/usr/local/lib/python3.5/dist-packages
ARG PYTHON_BUILD_IMAGE=3.7.3-stretch
ARG PYTHON_BASE_IMAGE=3.7.3-slim
ARG PYTHON_DIR=/usr/local/lib/python3.7/site-packages

FROM node:${NODE_BUILD_IMAGE} as node_build_env
ARG SOURCE_BRANCH
ENV FAVA_VERSION=${SOURCE_BRANCH:-v1.10}
ARG FAVA_VERSION

WORKDIR /tmp/build
RUN git clone https://github.com/beancount/fava
Expand All @@ -13,34 +17,29 @@ RUN git checkout ${FAVA_VERSION}
RUN make
RUN make mostlyclean

FROM debian:stretch as build_env
FROM python:${PYTHON_BUILD_IMAGE} as build_env
ARG BEANCOUNT_VERSION
ARG PYTHON_DIR

ENV BEANCOUNT_URL https://bitbucket.org/blais/beancount/get/${BEANCOUNT_VERSION}.tar.gz

RUN apt-get update
RUN apt-get install -y build-essential libxml2-dev libxslt-dev curl \
python3 libpython3-dev python3-pip git
RUN apt-get install -y build-essential libxml2-dev libxslt-dev

WORKDIR /tmp/build

RUN pip3 install -U setuptools
RUN pip3 install m3-cdecimal

RUN curl -J -L ${BEANCOUNT_URL} -o beancount-${BEANCOUNT_VERSION}.tar.gz
RUN tar xvf beancount-${BEANCOUNT_VERSION}.tar.gz
RUN CFLAGS=-s pip3 install ./beancount-*
RUN python3 -mpip install ./beancount-*

COPY --from=node_build_env /tmp/build/fava /tmp/build/fava
RUN ls ./fava/.git
RUN pip3 install ./fava
RUN python3 -mpip install ./fava

RUN find ${PYTHON_DIR} -name *.so -print0|xargs -0 strip -v
RUN find ${PYTHON_DIR} -name __pycache__ -exec rm -rf -v {} +
RUN python3 -mpip uninstall -y wheel pip

# Note: this is python3.5, which barely meet the requirement of beancount. We
# will need to update to newer version once it's supported.
FROM gcr.io/distroless/python3
FROM python:${PYTHON_BASE_IMAGE}
ARG PYTHON_DIR
COPY --from=build_env ${PYTHON_DIR} ${PYTHON_DIR}
COPY --from=build_env /usr/local/bin/fava /usr/local/bin/fava
Expand All @@ -67,11 +66,7 @@ COPY --from=build_env \
# Default fava port number
EXPOSE 5000

ENV BEANCOUNT_FILE ""

# Required by Click library.
# See https://click.palletsprojects.com/en/7.x/python3/
ENV LC_ALL "C.UTF-8"
ENV LANG "C.UTF-8"
ENV BEANCOUNT_INPUT_FILE ""
ENV FAVA_OPTIONS "-H 0.0.0.0"

ENTRYPOINT ["/usr/local/bin/fava", "-H", "0.0.0.0"]
CMD fava ${FAVA_OPTIONS} ${BEANCOUNT_INPUT_FILE}

0 comments on commit 869ea2f

Please sign in to comment.