Commit 086a7984 authored by Jakob Moser's avatar Jakob Moser
Browse files

Merge branch 'uv' into 'master'

Migrate to uv instead of Pipenv

See merge request !29
parents f7031901 56bfd49c
Loading
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ lint-openapi:
    allow_failure: true

test-frontend:
    image: python:3.12
    image: ghcr.io/astral-sh/uv:python3.12-bookworm
    stage: test
    before_script:
        - apt-get update
@@ -24,17 +24,13 @@ test-frontend:
        - echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
        - apt-get update
        - apt-get install -y nodejs libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
        - pip install --upgrade pip setuptools
        - pip install pipenv
        - pipenv requirements > requirements.txt
        - pip uninstall --yes pipenv
        - pip install -r requirements.txt
        - uv sync --locked
        - npm install cypress
    script:
        - mkdir instance
        - cp tests/resources/portal.test.db instance/portal.db
        - export FLASK_APP=portal
        - faketime '2024-09-26 13:37:00' flask run &
        - faketime '2024-09-26 13:37:00' uv run flask run &
        - faketime '2024-09-26 13:37:00' npx cypress run
    artifacts:
        when: always
@@ -44,18 +40,13 @@ test-frontend:
        expire_in: 1 week

test-python:
    image: python:3.12
    image: ghcr.io/astral-sh/uv:python3.12-bookworm
    stage: test
    cache: 
      paths:
        - .cache/pip
    before_script:
        - pip install pipenv
        - pipenv requirements --dev > requirements.txt
        - pip install -r requirements.txt 
        - uv sync --locked
    script:
        - black --check $CI_PROJECT_DIR
        - mypy .
        - uv run black --check $CI_PROJECT_DIR
        - uv run mypy .

# This snippet is copied and modified from the GitLab Documentation (as of 2021-01-10, the contents of the script seem to have changed by now)
#   * Title of the documentation page: "Building a Docker image with kaniko"
+5 −8
Original line number Diff line number Diff line
FROM python:3.12 AS base
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# We will use /app as our main directory within the Docker container
WORKDIR /app
@@ -9,14 +10,10 @@ ARG USERNAME="portaluser"
# First, copy and install only the requirements...
RUN useradd -ms /bin/bash ${USERNAME} && chown -R ${USERNAME}:${USERNAME} /app
USER ${USERNAME}
# The modified PATH is needed so that the pipenv executaable is found.
ENV PATH="$PATH:/home/${USERNAME}/.local/bin"
RUN pip install --upgrade pip setuptools
RUN pip install pipenv
COPY Pipfile.lock .
RUN pipenv requirements > requirements.txt
RUN pip uninstall --yes pipenv
RUN pip install -r requirements.txt
COPY pyproject.toml .
COPY uv.lock .
RUN uv sync --locked

# ... then the rest of the application. This allows the installation stage to be cached most of the time
# (so we don't have reinstall of all dependencies every time the container is rebuilt)
COPY --chown=${USERNAME}:${USERNAME} . .

Pipfile

deleted100644 → 0
+0 −23
Original line number Diff line number Diff line
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
alembic = "*"
argon2-cffi = "*"
flask-sqlalchemy = "*"
flask = "*"
ldap3 = "*"
requests = "*"
sqlalchemy = "*"

[dev-packages]
black = "*"
mypy = "*"
types-requests = "*"
types-ldap3 = "*"

[requires]
python_version = "3.12"
python_full_version = "3.12.4"

Pipfile.lock

deleted100644 → 0
+0 −687

File deleted.

Preview size limit exceeded, changes collapsed.

+3 −3
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
if [ -z $SKIP_ALEMBIC_MIGRATIONS ]
then
  # Run alembic migrations, unless SKIP_ALEMBIC_MIGRATIONS is set
  alembic upgrade head
  uv run alembic upgrade head
fi

# We expose the application to every interface (0.0.0.0) within the container.
@@ -14,9 +14,9 @@ fi

case ${SERVER_TYPE} in
  "flask")
    flask run --host 0.0.0.0;;
    uv run flask run --host 0.0.0.0;;
  "uwsgi")
    uwsgi --http 0.0.0.0:5000 --enable-threads -w "portal:create_app()";;
    uv run uwsgi -H .venv --http 0.0.0.0:5000 --enable-threads -w "portal:create_app()";;
  *)
    exit 1;;
esac
Loading