Skip to content

Commit

Permalink
build(docker): update and fix dockerfile, add pre-commit to dev deps
Browse files Browse the repository at this point in the history
Signed-off-by: David Wallace <[email protected]>
  • Loading branch information
David Wallace committed Feb 9, 2025
1 parent dc7abe0 commit 0f37a9c
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 25 deletions.
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.venv/
# Ignore the 'data' and 'output' directories
data/
output/
examples/

# Ignore Python bytecode files and cache directories
*.pyc
*.pyo
__pycache__/

# Ignore any other unnecessary files (e.g., logs, test outputs)
*.log
*.bak
*.swp

# Optionally, ignore other common file types you don't want in the image
*.git
*.gitignore
48 changes: 24 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# set base image (host OS)
FROM python:3.12
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot
# Install the project into `/app`
WORKDIR /app

USER nonroot
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

# set the working directory in the container
WORKDIR /code
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy

# copy the dependencies file to the working directory
COPY ./raman-fitting ./raman-fitting
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project

# copy setup.cfg to work dir
# COPY setup.cfg .
# COPY setup.py .
# install package test, maybe not possible because only src
# RUN pip install -e ./
# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
ADD . /app

RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen

# install dependencies
RUN pip install -r requirements.txt
# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"

RUN pip install --upgrade build
RUN build ./
RUN pip install -e ./
# Reset the entrypoint, don't invoke `uv`
ENTRYPOINT ["uv", "run"]

# copy the content of the local src directory to the working directory
#COPY src/ .

# command to run on container start
CMD [ "raman_fitting run examples" ]
# Default command
CMD ["raman_fitting", "run", "examples"]
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
{name = "David Wallace", email = "[email protected]"},
]
description = "Python framework for the batch processing and deconvolution of raman spectra."
readme = {file = "README.md", content-type = "text/markdown"}
readme = "README.md"
keywords = ["spectroscopy", "Raman", "fitting", "deconvolution", "batch processing", "carbonaceous materials"]
classifiers = [
"License :: OSI Approved :: MIT License",
Expand Down Expand Up @@ -57,6 +57,7 @@ dev = [
"pydocstyle",
"black",
"ruff",
"pre-commit",
"bump-my-version",
{include-group = "pytest"}
]
Expand Down
105 changes: 105 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f37a9c

Please sign in to comment.