Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert back to poetry #2171

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@ on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Check out repo
uses: actions/checkout@v3

- name: "Install rye"
id: setup-rye
uses: eifinger/setup-rye@v4
- name: Install poetry
run: pipx install poetry

- uses: actions/setup-python@v4
with:
version: '0.37.0'
checksum: 'fc7c150acc844fd86d709de1428ca96b585f8340edebc5b537ee9fa231f40884'
enable-cache: true
python-version: '3.10'
cache: 'poetry'

- name: Install OS dependencies
if: ${{ matrix.python-version }} == '3.10'
run: |
sudo apt update
sudo apt install -y libre2-dev libpq-dev

- name: Install dependencies
if: steps.setup-rye.outputs.cache-hit != 'true'
run: rye sync --no-lock
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction

- name: Check formatting & linting
run: |
rye run pre-commit run --all-files
poetry run pre-commit run --all-files


test:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: true
matrix:
python-version: ["3.10"]

# service containers to run with `postgres-job`
services:
Expand Down Expand Up @@ -69,14 +69,13 @@ jobs:
- name: Check out repo
uses: actions/checkout@v3

- name: Install rye
id: setup-rye
uses: eifinger/setup-rye@v4
- name: Install poetry
run: pipx install poetry

- uses: actions/setup-python@v4
with:
version: '0.37.0'
checksum: 'fc7c150acc844fd86d709de1428ca96b585f8340edebc5b537ee9fa231f40884'
enable-cache: true
cache-prefix: 'rye-cache'
python-version: ${{ matrix.python-version }}
cache: 'poetry'

- name: Install OS dependencies
if: ${{ matrix.python-version }} == '3.10'
Expand All @@ -85,8 +84,9 @@ jobs:
sudo apt install -y libre2-dev libpq-dev

- name: Install dependencies
if: steps.setup-rye.outputs.cache-hit != 'true'
run: rye sync --no-lock
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction


- name: Start Redis v6
uses: superchargejs/redis-github-action@1.1.0
Expand All @@ -95,8 +95,7 @@ jobs:

- name: Run db migration
run: |
rye install alembic
CONFIG=tests/test.env rye run alembic upgrade head
CONFIG=tests/test.env poetry run alembic upgrade head

- name: Prepare version file
run: |
Expand All @@ -105,7 +104,7 @@ jobs:

- name: Test with pytest
run: |
rye run pytest
poetry run pytest
env:
GITHUB_ACTIONS_TEST: true

Expand Down
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

50 changes: 24 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,43 @@ WORKDIR /code
COPY ./static/package*.json /code/static/
RUN cd /code/static && npm ci

FROM --platform=linux/amd64 ubuntu:22.04

ARG RYE_VERSION="0.37.0"
ARG RYE_HASH="fc7c150acc844fd86d709de1428ca96b585f8340edebc5b537ee9fa231f40884"
# Main image
FROM python:3.10

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
ENV PYTHONUNBUFFERED 1

# Add poetry to PATH
ENV PATH="${PATH}:/root/.local/bin"

WORKDIR /code

# Copy dependency files
COPY pyproject.toml requirements.lock requirements-dev.lock .python-version ./

# Install deps
RUN apt-get update \
&& apt-get install -y curl netcat-traditional gcc python3-dev gnupg git libre2-dev build-essential pkg-config cmake ninja-build bash clang \
&& curl -sSL "https://github.com/astral-sh/rye/releases/download/${RYE_VERSION}/rye-x86_64-linux.gz" > rye.gz \
&& echo "${RYE_HASH} rye.gz" | sha256sum -c - \
&& gunzip rye.gz \
&& chmod +x rye \
&& mv rye /usr/bin/rye \
&& rye toolchain fetch `cat .python-version` \
&& rye sync --no-lock --no-dev \
&& apt-get autoremove -y \
&& apt-get purge -y curl netcat-traditional build-essential pkg-config cmake ninja-build python3-dev clang\
&& apt-get autoremove -y \
# Copy poetry files
COPY poetry.lock pyproject.toml ./

# Install and setup poetry
RUN pip install -U pip \
&& apt-get update \
&& apt install -y curl netcat-traditional gcc python3-dev gnupg git libre2-dev cmake ninja-build\
&& curl -sSL https://install.python-poetry.org | python3 - \
# Remove curl and netcat from the image
&& apt-get purge -y curl netcat-traditional \
# Run poetry
&& poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi --no-root \
# Clear apt cache \
&& apt-get purge -y libre2-dev cmake ninja-build\
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy code
COPY . .

# copy npm packages
COPY --from=npm /code /code

ENV PATH="/code/.venv/bin:$PATH"
# copy everything else into /code
COPY . .

EXPOSE 7777

#gunicorn wsgi:app -b 0.0.0.0:7777 -w 2 --timeout 15 --log-level DEBUG
Expand Down
Loading
Loading