Skip to content

Commit

Permalink
add sass build steps to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidneys1 committed Jun 4, 2024
1 parent 6b4fe74 commit 9de7d80
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ jobs:
pip install
hatch
--user
- name: Compile CSS from SCSS files
uses: gha-utilities/sass-build@v0.4.7
with:
source: |
./src/memoria/web/www/static/styles.scss
./src/memoria/web/www/templates/settings.scss
./src/memoria/web/www/templates/index.scss
destination: |
./src/memoria/web/www/static/styles.css
./src/memoria/web/www/templates/settings.css
./src/memoria/web/www/templates/index.css
- name: Build a binary wheel and a source tarball
run: python3 -m hatch build
- name: Store the distribution packages
Expand Down
12 changes: 11 additions & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ FROM scratch AS source
COPY pyproject.toml README.md hatch_build.py /
COPY src/ /src/

FROM alpine:latest AS sass
ARG DART_SASS_VERSION=1.77.4
ARG DART_SASS_TAR=dart-sass-${DART_SASS_VERSION}-linux-x64-musl.tar.gz
ARG DART_SASS_URL=https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/${DART_SASS_TAR}
ADD ${DART_SASS_URL} /opt/
RUN cd /opt/ && tar -xzf ${DART_SASS_TAR} && rm ${DART_SASS_TAR}
RUN --mount=type=bind,from=source,target=/memoria,source=/,rw \
cd /memoria/src/memoria/web/www && /opt/dart-sass/sass static/:static/ templates/:templates/ \
&& find . -iname '*.scss' -delete

FROM python:3.12-alpine
CMD ["uvicorn", "memoria.web:APP", "--host", "0.0.0.0", "--port", "80"]
EXPOSE 80
RUN --mount=type=bind,from=source,target=/memoria,source=/,rw --mount=type=cache,target=/cache --mount=type=tmpfs,target=/temp \
RUN --mount=type=bind,from=source,target=/memoria,source=/,rw --mount=type=bind,from=sass,target=/sass,source=/opt/dart-sass,ro --mount=type=cache,target=/cache --mount=type=tmpfs,target=/temp \
TMPDIR=/temp python -m pip install --cache-dir=/cache /memoria[uvicorn] \
&& mkdir /data
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ one of the methods below you can access the web interface at `http://localhost/`
<details><summary>Running With Python</summary>

```sh
# Install from PyPI:
python3 -m pip install memoria_search
# Or from source code:
python3 -m pip install .

# Run:
python3 -m memoria.web --port 80

# Or without installing:
# Or run from source code without installing (you may need to install some dependencies):
PYTHONPATH=./src python -m memoria.web --port 80
```

Expand Down
24 changes: 20 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,31 @@ path = "src/memoria/__about__.py"
[tool.hatch.metadata.hooks.custom]

[tool.hatch.build.targets.sdist]
ignore-vcs = true
exclude = [
"allowlist.txt",
"denylist.txt",
".vscode/",
".editorconfig"
"allowlist.txt",
"denylist.txt",
".vscode/",
".editorconfig",
".python-version",
"__pycache__/",
"dist/",
"*.code-workspace"
]

[tool.hatch.build.targets.wheel]
ignore-vcs = true
packages = ["src/memoria"]
exclude = [
"allowlist.txt",
"denylist.txt",
".vscode/",
".editorconfig",
".python-version",
"__pycache__/",
"dist/",
"*.code-workspace"
]

[tool.isort]
line_length = 120
Expand Down

0 comments on commit 9de7d80

Please sign in to comment.