Skip to content

Commit b59be58

Browse files
committed
chore: remove legacy files and update project standards
- Delete obsolete configuration and metadata (tox.ini, etc) - Replace `README.rst` with `README.md` - Remove unused Makefile and entrypoint script - Update `.dockerignore` to include commonly ignored artifacts - Modernize and clean up `compose.yml` setup - Upgrade Python and dependency versions in `uv.lock` - Enhance token generator script with new helper functions
1 parent d758421 commit b59be58

File tree

317 files changed

+4297
-4204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

317 files changed

+4297
-4204
lines changed

.dockerignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
**/__pycache__
22
.git
3+
.github
34
.idea
45
.mypy_cache
56
.pytest_cache
67
.ruff_cache
78
.venv
9+
.tmp
10+
dist
11+
docs
12+
htmlcov
13+
lemur.egg-info
814
lemur/static/dist
915
node_modules
1016
bower_components
11-
.tmp
12-
migrations
17+
*.md
18+
*.rst

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [ main ]
5+
6+
jobs:
7+
check:
8+
name: Run checks on codebase
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- name: Install system deps
12+
run: |
13+
sudo apt-get update
14+
sudo apt-get install -y \
15+
libsasl2-dev \
16+
libldap2-dev
17+
- uses: actions/checkout@v6
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v7
20+
- name: Sync dev dependencies
21+
run: uv sync --frozen --dev --group tests
22+
- name: Ruff check
23+
run: uv run ruff check lemur
24+
- name: Ruff format check
25+
run: uv run ruff format --check lemur
26+
- name: mypy check
27+
run: uv run mypy lemur
28+
29+
test:
30+
needs: check
31+
name: Tests (py${{ matrix.python }} / pg${{ matrix.postgres }})
32+
runs-on: ubuntu-22.04
33+
34+
strategy:
35+
matrix:
36+
python: [ "3.10", "3.11", "3.12" ]
37+
postgres: [ 14, 15, 16, 17, 18 ]
38+
39+
services:
40+
postgres:
41+
image: postgres:${{ matrix.postgres }}
42+
env:
43+
POSTGRES_USER: lemur
44+
POSTGRES_PASSWORD: lemur
45+
POSTGRES_DB: lemur
46+
options: >-
47+
--health-cmd "pg_isready -U lemur"
48+
--health-interval 5s
49+
--health-timeout 5s
50+
--health-retries 3
51+
ports:
52+
- 5432:5432
53+
54+
env:
55+
SQLALCHEMY_DATABASE_URI: postgresql://lemur:lemur@localhost:5432/lemur
56+
BOTO_CONFIG: /doesnotexist
57+
PY_COLORS: "1"
58+
FORCE_COLOR: "1"
59+
60+
steps:
61+
- uses: actions/checkout@v6
62+
63+
- name: Install uv
64+
uses: astral-sh/setup-uv@v7
65+
66+
- name: Set Python ${{ matrix.python }}
67+
run: uv python install ${{ matrix.python }}
68+
69+
- name: Install system deps
70+
run: |
71+
sudo apt-get update
72+
sudo apt-get install -y \
73+
libsasl2-dev \
74+
libldap2-dev
75+
76+
- name: Sync runtime + dev deps
77+
run: uv sync --frozen --dev --group tests
78+
79+
- name: Run tests
80+
run: |
81+
uv run pytest --cov=lemur --cov-report=xml

.hadolint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignored:
2+
- DL3018

.pre-commit-config.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
default_language_version:
33
python: python3.10
44

5+
exclude: ^(\.git|\.[^/]+|lemur/migrations|docs|lemur/static/dist)(/|$)|.*\.(md|rst)$
6+
57
repos:
6-
# - repo: https://github.com/pre-commit/pre-commit-hooks
7-
# rev: v6.0.0
8-
# hooks:
9-
# - id: trailing-whitespace
10-
# - id: check-merge-conflict
11-
# - id: mixed-line-ending
12-
# - id: end-of-file-fixer
13-
# - id: check-yaml
14-
# - id: check-toml
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v6.0.0
10+
hooks:
11+
- id: check-added-large-files
12+
- id: check-executables-have-shebangs
13+
- id: check-shebang-scripts-are-executable
14+
- id: trailing-whitespace
15+
- id: mixed-line-ending
16+
- id: end-of-file-fixer
17+
- id: fix-byte-order-marker
1518

1619
- repo: https://github.com/gitleaks/gitleaks
1720
rev: v8.30.0

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

AUTHORS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
- Kevin Glisson <[email protected]>
22
- Jeremy Heffner <[email protected]>
3-

Dockerfile

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,69 @@
1-
FROM python:3.10-slim-bookworm AS builder
1+
FROM python:3.10-alpine3.22 AS builder
22

3-
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4-
5-
# Install build dependencies
6-
RUN apt update && apt upgrade -y && apt install -y --no-install-recommends \
7-
curl \
8-
git \
9-
build-essential \
10-
libldap2-dev \
11-
libsasl2-dev && \
12-
rm -rf /var/lib/apt/lists/*
13-
14-
# Install nodejs 18 with npm
15-
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
16-
apt update && \
17-
apt install -y --no-install-recommends nodejs && \
18-
rm -rf /var/lib/apt/lists/*
19-
20-
# Download the latest uv installer
21-
ADD https://astral.sh/uv/install.sh /uv-installer.sh
22-
23-
# Run the installer then remove it
24-
RUN sh /uv-installer.sh && rm /uv-installer.sh
3+
COPY --from=ghcr.io/astral-sh/uv:0.9 /uv /uvx /bin/
254

26-
# Ensure the installed uv binary is on the `PATH`
27-
ENV PATH="/root/.local/bin/:$PATH"
5+
ENV PATH="/root/.local/bin/:$PATH" \
6+
CFLAGS="-Os -fomit-frame-pointer" \
7+
LDFLAGS="-Wl,--strip-all"
288

29-
# Copy dependency files & set workdir
309
WORKDIR /opt/lemur
3110
COPY . .
3211

33-
# Install Python dependencies with uv
34-
RUN uv sync --frozen
35-
36-
RUN npm install \
37-
&& npm run build_static \
38-
&& node_modules/.bin/gulp package --urlContextPath="" \
39-
&& rm -rf node_modules bower_components .tmp
12+
RUN apk add --update --no-cache --virtual build-dependencies \
13+
curl \
14+
bash \
15+
git \
16+
tar \
17+
musl-dev \
18+
gcc \
19+
openldap-dev \
20+
binutils \
21+
npm \
22+
&& uv sync --no-dev --frozen --compile-bytecode
4023

24+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4125

42-
FROM python:3.10-slim-bookworm AS runtime
26+
RUN curl -sSL https://github.com/caddyserver/caddy/releases/download/v2.10.2/caddy_2.10.2_linux_amd64.tar.gz | tar xz -C /usr/bin \
27+
&& npm config set cache /tmp/npm-cache \
28+
&& npm install \
29+
&& node_modules/.bin/gulp build \
30+
&& node_modules/.bin/gulp package --urlContextPath="" \
31+
&& rm -rf node_modules bower_components .tmp /tmp/npm-cache \
32+
/usr/lib/python3.10/ensurepip \
33+
/usr/lib/python3.10/idlelib \
34+
/usr/lib/python3.10/test \
35+
/usr/lib/python3.10/lib2to3 \
36+
/usr/lib/python3.10/pydoc_data \
37+
/usr/lib/python3.10/tkinter \
38+
&& strip /usr/bin/caddy \
39+
&& strip /opt/lemur/.venv/lib/python*/site-packages/**/*.so || true \
40+
&& find /opt/lemur/.venv -name "*.so" -exec strip --strip-unneeded {} + || true \
41+
&& apk del build-dependencies
42+
43+
44+
FROM python:3.10-alpine3.22 AS runtime
45+
46+
ENV uid=1337
47+
ENV gid=1337
48+
ENV user=lemur
49+
ENV group=lemur
4350

4451
ENV PATH="/opt/lemur/.venv/bin:${PATH}" \
4552
PYTHONUNBUFFERED=1 \
4653
PYTHONDONTWRITEBYTECODE=1
4754

48-
RUN apt update && apt upgrade -y && apt install -y --no-install-recommends \
49-
debian-keyring debian-archive-keyring apt-transport-https curl libldap-2.5-0 make gnupg && \
50-
rm -rf /var/lib/apt/lists/*
51-
52-
RUN curl -1sLf https://dl.cloudsmith.io/public/caddy/stable/gpg.key | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg && \
53-
curl -1sLf https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt | tee /etc/apt/sources.list.d/caddy-stable.list && \
54-
chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg && \
55-
chmod o+r /etc/apt/sources.list.d/caddy-stable.list && \
56-
apt update && apt install caddy && \
57-
rm -rf /var/lib/apt/lists/*
55+
RUN apk add --no-cache curl libldap bash openssl
5856

59-
# Create lemur user
60-
RUN useradd --create-home --shell /bin/bash lemur
57+
RUN addgroup -S ${group} -g ${gid} \
58+
&& adduser -D -S ${user} -G ${group} -u ${uid}
6159

62-
# Copy built project
63-
COPY --from=builder --chown=lemur:lemur /opt/lemur /opt/lemur
60+
COPY --from=builder --chown=${uid}:${gid} /opt/lemur /opt/lemur
61+
COPY --from=builder --chown=${uid}:${gid} /usr/bin/caddy /usr/bin/caddy
6462

65-
# Ensure entrypoint is executable
66-
RUN chmod +x /opt/lemur/entrypoint
63+
RUN chmod +x /opt/lemur/docker/entrypoint.sh
6764

68-
# Switch to the user
6965
USER lemur
7066

71-
# Expose port
7267
EXPOSE 80
7368

74-
# Default command
75-
ENTRYPOINT ["/opt/lemur/entrypoint"]
69+
ENTRYPOINT ["/opt/lemur/docker/entrypoint.sh"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include pyproject.toml package.json bower.json gulpfile.js README.md MANIFEST.in LICENSE AUTHORS
2+
recursive-include lemur/plugins/lemur_email/templates *
3+
recursive-include lemur/static *
4+
global-exclude *~

0 commit comments

Comments
 (0)