refactor: Dockerfile updates

pull/106/head
Jeff Culverhouse 3 months ago
parent bb6acf4074
commit b3fe517158

@ -22,27 +22,29 @@ ENV APP_PRETEND_VERSION=${VERSION}
# ===== System Dependencies ===== # ===== System Dependencies =====
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y --no-install-recommends git && \ apt-get install -y --no-install-recommends git && \
apt-get upgrade -y && \
pip install --no-cache-dir uv && \ pip install --no-cache-dir uv && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# ===== Copy Source and Metadata ===== # ===== Copy Project Metadata =====
COPY pyproject.toml uv.lock ./ COPY pyproject.toml uv.lock ./
COPY . .
# ===== Build & Install ===== # ===== Build & Install =====
# 1. Create isolated virtual environment # 1. Create isolated virtual environment
RUN uv venv RUN uv venv
ENV PATH="/app/.venv/bin:${PATH}"
# 2. Export locked dependencies (with pretend version active) # 2. Export locked dependencies (with pretend version active)
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${VERSION} uv export --no-dev --format=requirements-txt > /tmp/reqs.all.txt RUN SETUPTOOLS_SCM_PRETEND_VERSION=${VERSION} uv export --no-dev --format=requirements-txt > /tmp/reqs.all.txt
# 3. Strip the local project from deps list so setuptools-scm isnt triggered during deps install # 3. Strip the local project from deps list so setuptools-scm isnt triggered during deps install
RUN grep -v -E "(^-e\s+file://|^file://|/app)" /tmp/reqs.all.txt > /tmp/reqs.deps.txt || true RUN grep -v -E "(^-e\s+(\.|file://)|@\s+file://|^file://|/app)" /tmp/reqs.all.txt > /tmp/reqs.deps.txt || true
# 4. Install dependencies # 4. Install dependencies
RUN uv pip install --no-cache-dir -r /tmp/reqs.deps.txt RUN uv pip install --no-cache-dir -r /tmp/reqs.deps.txt
# ===== Copy Application Source =====
COPY . .
# 5. Install the app itself (pretend version visible, no deps) # 5. Install the app itself (pretend version visible, no deps)
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${VERSION} uv pip install --no-cache-dir . --no-deps RUN SETUPTOOLS_SCM_PRETEND_VERSION=${VERSION} uv pip install --no-cache-dir . --no-deps
@ -62,5 +64,5 @@ LABEL org.opencontainers.image.title=${APP_NAME} \
org.opencontainers.image.description=${SERVICE_DESC} \ org.opencontainers.image.description=${SERVICE_DESC} \
org.opencontainers.image.version=${VERSION} org.opencontainers.image.version=${VERSION}
ENTRYPOINT ["/bin/sh", "-c", "/app/.venv/bin/python -m $APP_NAME \"$@\"", "sh"] ENTRYPOINT ["python", "-m", "amcrest2mqtt"]
CMD ["-c", "/config"] CMD ["-c", "/config"]

Loading…
Cancel
Save