Skip to content

Commit

Permalink
add container Makefile targets
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgerstmayr committed Feb 6, 2025
1 parent e5dc9cf commit a0aa043
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
frontend/node_modules
29 changes: 29 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:24.04
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
RUN apt-get update && apt-get install -y \
git make npm

# Chromium dependencies
RUN apt-get install -y fonts-noto-color-emoji libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon0 libxdamage1 libpango-1.0-0 libcairo2 libasound2t64

ENV LC_ALL="en_US.UTF-8"
USER ubuntu

WORKDIR /usr/src/app
RUN mkdir frontend

# Python dependencies
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=cache,target=/home/ubuntu/.cache/uv,uid=1000 \
uv sync --frozen --no-install-project

# Node.js dependencies
RUN --mount=type=bind,source=frontend/package.json,target=frontend/package.json \
--mount=type=bind,source=frontend/package-lock.json,target=frontend/package-lock.json \
--mount=type=cache,target=/home/ubuntu/.npm,uid=1000 \
cd frontend && npm ci && npx puppeteer browsers install chrome

COPY --chown=ubuntu:ubuntu . .
RUN make build
CMD ["make", "run"]
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,19 @@ ci:
make test
make format
git diff --exit-code

## Container
container-run:
docker build -t fava-portfolio-returns -f Dockerfile.test .
docker run -d --name fava-portfolio-returns-test fava-portfolio-returns

container-stop:
docker rm -f fava-portfolio-returns-test

container-test: container-run
docker exec fava-portfolio-returns-test make test
make container-stop

container-test-js-update: container-run
docker exec fava-portfolio-returns-test make test-js-update
make container-stop

0 comments on commit a0aa043

Please sign in to comment.