Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build failure: Change beanprice installation path from SSH to HTTPS #49

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
56 changes: 0 additions & 56 deletions .github/workflows/push-to-docker-hub.yaml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/push-to-ghcr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Publish Docker image

on:
push:
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: duquewu/fava

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

71 changes: 27 additions & 44 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
ARG BEANCOUNT_VERSION=2.3.6
ARG FAVA_VERSION=v1.27.3

ARG NODE_BUILD_IMAGE=16-bullseye
FROM node:${NODE_BUILD_IMAGE} as node_build_env
ARG FAVA_VERSION

FROM node:22-alpine3.20 as node_build_env
RUN apk add --no-cache python3 py3-pip python3-dev build-base git
WORKDIR /tmp/build
RUN git clone https://github.com/beancount/fava

RUN apt-get update
RUN apt-get install -y python3-babel

WORKDIR /tmp/build/fava
RUN git checkout ${FAVA_VERSION}
RUN make
RUN rm -rf .*cache && \
# RUN git clone https://github.com/beancount/beancount
RUN python3 -mvenv /app
# ADD requirements.txt .
# RUN . /app/bin/activate && pip3 install --require-hashes -U -r requirements.txt
# RUN . /app/bin/activate && pip3 install git+https://github.com/beancount/beanprice.git@41576e2ac889e4825e4985b6f6c56aa71de28304
# RUN . /app/bin/activate && pip3 install git+https://github.com/andreasgerstmayr/fava-portfolio-returns.git@152a1057c065c2ecd0e91ef62c9d73081f833329

RUN cd /tmp/build/fava && \
git checkout v1.28 && \
make && \
rm -rf .*cache && \
rm -rf .eggs && \
rm -rf .tox && \
rm -rf build && \
Expand All @@ -23,43 +21,28 @@ RUN rm -rf .*cache && \
find . -type f -name '*.py[c0]' -delete && \
find . -type d -name "__pycache__" -delete

FROM debian:bullseye as build_env
ARG BEANCOUNT_VERSION

RUN apt-get update
RUN apt-get install -y build-essential libxml2-dev libxslt-dev curl \
python3 libpython3-dev python3-pip git python3-venv
RUN cd /tmp/build/fava && \
. /app/bin/activate && \
pip3 install /tmp/build/fava

# RUN cd /tmp/build/beancount && \
# git checkout 3.0.0 && \
# . /app/bin/activate && \
# CFLAGS=-s pip3 install /tmp/build/beancount


ENV PATH "/app/bin:$PATH"
RUN python3 -mvenv /app
COPY --from=node_build_env /tmp/build/fava /tmp/build/fava

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 install -U /tmp/build/fava
ADD requirements.txt .
RUN pip3 install --require-hashes -U -r requirements.txt
RUN pip3 install git+https://github.com/beancount/beanprice.git@41576e2ac889e4825e4985b6f6c56aa71de28304
RUN pip3 install git+https://github.com/andreasgerstmayr/fava-portfolio-returns.git@de68b54f3ac517adfde3a4ccb41fdb09a0da41d1

RUN pip3 uninstall -y pip

RUN apk del jansson zstd-libs binutils libmagic file libgomp libatomic gmp isl26 mpfr4 mpc1 gcc libstdc++-dev musl-dev g++ make fortify-headers patch build-base libbz2 libexpat libffi gdbm xz-libs mpdecimal ncurses-terminfo-base libncursesw libpanelw readline sqlite-libs python3 pyc py3-setuptools-pyc py3-pip-pyc py3-parsing py3-parsing-pyc py3-packaging-pyc python3-pyc py3-packaging py3-setuptools py3-pip pkgconf python3-dev ca-certificates brotli-libs c-ares libunistring libidn2 nghttp2-libs libpsl libcurl pcre2 git git-init-template
RUN rm -rf /tmp/build
RUN find /app -name __pycache__ -exec rm -rf -v {} +

FROM gcr.io/distroless/python3-debian11
COPY --from=build_env /app /app
FROM alpine:3.20
RUN apk add --no-cache py3-pip
COPY --from=node_build_env /app /app

# Default fava port number
EXPOSE 5000

ENV BEANCOUNT_FILE ""

ENV BEANCOUNT_FILE "/bean/main.bean"
ENV FAVA_HOST "0.0.0.0"
ENV PATH "/app/bin:$PATH"

Expand Down
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ You can get started creating a container from this image, you can either use doc

Assuming you have `example.bean` in the current directory:

### Docker Image Tags
* [v1.28](https://github.com/duquewu/fava-docker/pkgs/container/fava/277479719?tag=v1.28), [latest](https://github.com/duquewu/fava-docker/pkgs/container/fava/277479719?tag=latest)

### Docker Cli

```bash
docker run -d \
--name=syncthing \
--name=fava \
-v $PWD:/bean \
-e BEANCOUNT_FILE=/bean/example.bean \
-p 5000:5000 \
--restart unless-stopped \
yegle/fava
ghcr.io/duquewu/fava:latest
```

### Docker Compose
Expand All @@ -29,7 +32,7 @@ version: "3.0"
services:
fava:
container_name: fava
image: yegle/fava
image: ghcr.io/duquewu/fava:latest
ports:
- 5000:5000
environment:
Expand All @@ -44,11 +47,3 @@ services:
| Parameter | Value |
| :----: | --- |
| `BEANCOUNT_FILE` | path to your beancount file. Default to empty string. |

## Note on auto build

The [docker image](https://hub.docker.com/r/yegle/fava) was switched
from build by Docker Hub to Github Actions. The image label pattern is
changed: instead of labeled `version-1.xx` it's now labeled `v1.xx`.

You can check the auto build logs at https://github.com/yegle/fava-docker/actions.