Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79cdf83c9e | ||
|
|
5b691a577b | ||
|
|
aeee758718 |
+15
-6
@@ -69,28 +69,37 @@ WORKDIR /app/
|
||||
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
# Pass version from Makefile to setuptools-scm since .git is not in context
|
||||
ARG SETUPTOOLS_SCM_PRETEND_VERSION_FOR_BREWMAN
|
||||
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_BREWMAN=$SETUPTOOLS_SCM_PRETEND_VERSION_FOR_BREWMAN
|
||||
# Pass the version from the Makefile. The build context has no usable .git
|
||||
# (a git-URL build is a tag-less shallow clone and git is not installed), so
|
||||
# hatch-vcs cannot discover the version itself. hatch-vcs calls
|
||||
# setuptools_scm without a dist name, so only the generic
|
||||
# SETUPTOOLS_SCM_PRETEND_VERSION is honored - the
|
||||
# SETUPTOOLS_SCM_PRETEND_VERSION_FOR_<NAME> variant is silently ignored.
|
||||
ARG SETUPTOOLS_SCM_PRETEND_VERSION
|
||||
ENV SETUPTOOLS_SCM_PRETEND_VERSION=$SETUPTOOLS_SCM_PRETEND_VERSION
|
||||
|
||||
# Install dependencies
|
||||
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
--mount=type=bind,source=brewman/uv.lock,target=uv.lock \
|
||||
--mount=type=bind,source=brewman/pyproject.toml,target=pyproject.toml \
|
||||
--mount=source=.git,target=.git,type=bind \
|
||||
uv sync --locked --no-install-project
|
||||
|
||||
COPY /brewman ./
|
||||
|
||||
# hatch-vcs generates _version.py only inside uv's isolated wheel build, so
|
||||
# the source tree copied here lacks it. Write it ourselves (from the same
|
||||
# build arg) so importing brewman from /app works identically to the
|
||||
# installed wheel package in .venv.
|
||||
RUN printf '__version__ = version = "%s"\n' "$SETUPTOOLS_SCM_PRETEND_VERSION" > brewman/_version.py
|
||||
|
||||
COPY --from=builder /frontend/browser /app/frontend
|
||||
RUN ls -lah
|
||||
|
||||
# Sync the project
|
||||
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
--mount=type=bind,source=brewman/uv.lock,target=uv.lock \
|
||||
--mount=type=bind,source=brewman/pyproject.toml,target=pyproject.toml \
|
||||
--mount=source=.git,target=.git,type=bind \
|
||||
uv sync --locked --no-editable
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
.PHONY: build-production
|
||||
build-production: ## Build the production container image. Usage: make build-production TAG=15.4.0
|
||||
@test -n "$(TAG)" || { echo "Usage: make build-production TAG=15.4.0" >&2; exit 1; }
|
||||
@echo "Building image..."
|
||||
@podman manifest rm registry.tanshu.com/brewman:latest 2>/dev/null || true
|
||||
@podman build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--manifest registry.tanshu.com/brewman:latest \
|
||||
--pull \
|
||||
--build-arg SETUPTOOLS_SCM_PRETEND_VERSION_FOR_BREWMAN=$(TAG) \
|
||||
--build-arg SETUPTOOLS_SCM_PRETEND_VERSION=$(TAG) \
|
||||
https://git.tanshu.com/tanshu/brewman.git#v$(TAG)
|
||||
|
||||
@echo "Pushing manifests..."
|
||||
@@ -15,11 +16,25 @@ build-production: ## Build the production container image. Usage: make build-pro
|
||||
|
||||
.PHONY: build-check
|
||||
build-check: ## Multi-arch build without push (compile check). Usage: make build-check TAG=15.4.0
|
||||
@test -n "$(TAG)" || { echo "Usage: make build-check TAG=15.4.0" >&2; exit 1; }
|
||||
@echo "Building image..."
|
||||
@podman manifest rm brewman:test 2>/dev/null || true
|
||||
@podman build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--manifest brewman:test \
|
||||
--pull \
|
||||
--build-arg SETUPTOOLS_SCM_PRETEND_VERSION_FOR_BREWMAN=$(TAG) \
|
||||
--build-arg SETUPTOOLS_SCM_PRETEND_VERSION=$(TAG) \
|
||||
https://git.tanshu.com/tanshu/brewman.git#v$(TAG)
|
||||
|
||||
.PHONY: build-check-local
|
||||
# Defaults the version when built without a tag; an explicit TAG still wins.
|
||||
build-check-local: TAG = 0.0.0
|
||||
build-check-local: ## Single-arch build without push (compile check). Usage: make build-check-local [TAG=15.4.0]
|
||||
@echo "Building image..."
|
||||
@podman manifest rm brewman:test 2>/dev/null || true
|
||||
@podman build \
|
||||
--platform linux/amd64 \
|
||||
--manifest brewman:test \
|
||||
--no-cache \
|
||||
--build-arg SETUPTOOLS_SCM_PRETEND_VERSION=$(TAG) \
|
||||
.
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
env_file: "/var/lib/{{ host_directory }}/.env"
|
||||
networks:
|
||||
- name: "brewman_{{ instance }}_net"
|
||||
# volumes:
|
||||
# - "/var/lib/{{ host_directory }}/frontend:/frontend"
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -fsS http://localhost/health || kill -s 15 1"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
start_period: 30s
|
||||
retries: 3
|
||||
|
||||
@@ -14,7 +14,10 @@ def report_start_date(request: Request, s: str | date | None = None) -> date:
|
||||
return d
|
||||
if "start" not in session:
|
||||
session["start"] = get_first_day(date.today()).isoformat()
|
||||
return date.fromisoformat(session["start"])
|
||||
try:
|
||||
return date.fromisoformat(session["start"])
|
||||
except ValueError:
|
||||
return get_first_day(date.today())
|
||||
|
||||
|
||||
def report_finish_date(request: Request, f: str | date | None = None) -> date:
|
||||
@@ -28,7 +31,10 @@ def report_finish_date(request: Request, f: str | date | None = None) -> date:
|
||||
return d
|
||||
if "finish" not in session:
|
||||
session["finish"] = get_last_day(date.today()).isoformat()
|
||||
return date.fromisoformat(session["finish"])
|
||||
try:
|
||||
return date.fromisoformat(session["finish"])
|
||||
except ValueError:
|
||||
return get_last_day(date.today())
|
||||
|
||||
|
||||
def report_date(request: Request, d: str | date | None = None) -> date:
|
||||
@@ -42,7 +48,10 @@ def report_date(request: Request, d: str | date | None = None) -> date:
|
||||
return parsed_date
|
||||
if "date" not in session:
|
||||
session["date"] = get_last_day(date.today()).isoformat()
|
||||
return date.fromisoformat(session["date"])
|
||||
try:
|
||||
return date.fromisoformat(session["date"])
|
||||
except ValueError:
|
||||
return get_last_day(date.today())
|
||||
|
||||
|
||||
def get_first_day(dt: date, d_years: int = 0, d_months: int = 0) -> date:
|
||||
|
||||
Reference in New Issue
Block a user